From 3d9b2b11bcb960082b0c12808618739c99c86282 Mon Sep 17 00:00:00 2001 From: Nico Ritschel Date: Mon, 19 Oct 2026 13:30:32 -0700 Subject: [PATCH 1/2] Keep filter popovers visible and usable --- .../sidemantic/sidemantic-ui-static.js | 136 +++++++++++------- .../components/sidemantic/sidemantic-ui.css | 2 +- .../assets/ui-dist/sidemantic-ui-static.js | 136 +++++++++++------- .../assets/ui-dist/sidemantic-ui.css | 2 +- .../assets/ui-dist/sidemantic-ui.js | 44 +++++- sidemantic-rs/ui/assets/index-BCalwD9m.css | 1 + sidemantic-rs/ui/assets/index-DnTdRyzm.css | 1 - .../{index-pE1zWf5r.js => index-gv_X5qC6.js} | 26 ++-- sidemantic-rs/ui/index.html | 4 +- .../ui/static/assets/index-BCalwD9m.css | 1 + .../ui/static/assets/index-DnTdRyzm.css | 1 - .../{index-pE1zWf5r.js => index-gv_X5qC6.js} | 26 ++-- sidemantic/ui/static/index.html | 4 +- sidemantic/widget/static/widget.css | 2 +- sidemantic/widget/static/widget.js | 14 +- webapp/playwright.ui.config.ts | 16 +++ webapp/src/components/AddFilter.tsx | 8 +- webapp/src/components/AppShell.tsx | 6 +- webapp/src/components/FilterEditor.tsx | 12 +- webapp/src/components/useFilterPopover.ts | 34 +++++ webapp/tests/filter-popovers.spec.ts | 112 +++++++++++++++ 21 files changed, 429 insertions(+), 159 deletions(-) create mode 100644 sidemantic-rs/ui/assets/index-BCalwD9m.css delete mode 100644 sidemantic-rs/ui/assets/index-DnTdRyzm.css rename sidemantic-rs/ui/assets/{index-pE1zWf5r.js => index-gv_X5qC6.js} (74%) create mode 100644 sidemantic/ui/static/assets/index-BCalwD9m.css delete mode 100644 sidemantic/ui/static/assets/index-DnTdRyzm.css rename sidemantic/ui/static/assets/{index-pE1zWf5r.js => index-gv_X5qC6.js} (74%) create mode 100644 webapp/playwright.ui.config.ts create mode 100644 webapp/src/components/useFilterPopover.ts create mode 100644 webapp/tests/filter-popovers.spec.ts diff --git a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js index 9a3b62a0e..64e225643 100644 --- a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js +++ b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js @@ -7659,7 +7659,7 @@ var require_jsx_runtime = __commonJS(function(exports, module) { }); // webapp/src/static-api.tsx -var import_react10 = __toESM(require_react(), 1); +var import_react11 = __toESM(require_react(), 1); var import_client = __toESM(require_client(), 1); var import_react_dom = __toESM(require_react_dom(), 1); @@ -7954,7 +7954,7 @@ function DataTable({ } // webapp/src/components/FilterPill.tsx -var import_react6 = __toESM(require_react(), 1); +var import_react7 = __toESM(require_react(), 1); // webapp/src/data/types.ts function aliasOf(ref) { @@ -7990,7 +7990,7 @@ function filterSummary(filter) { } // webapp/src/components/FilterEditor.tsx -var import_react5 = __toESM(require_react(), 1); +var import_react6 = __toESM(require_react(), 1); // webapp/src/lib/catalog.ts function graphMetricsForModel(catalog, modelName) { @@ -8262,6 +8262,39 @@ function useQueryResult(backend, query) { return { ...state, queryKey: key ?? undefined }; } +// webapp/src/components/useFilterPopover.ts +var import_react5 = __toESM(require_react(), 1); +function useFilterPopover(ref, open = true) { + import_react5.useLayoutEffect(() => { + const panel = ref.current; + const anchor = panel?.parentElement; + if (!open || !panel || !anchor) + return; + function position() { + if (!panel || !anchor) + return; + const bounds = anchor.getBoundingClientRect(); + const gutter = 8; + const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); + panel.style.left = `${left - bounds.left}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + } + position(); + const observer = new ResizeObserver(position); + observer.observe(panel); + observer.observe(anchor); + if (anchor.parentElement) + observer.observe(anchor.parentElement); + window.addEventListener("resize", position); + window.addEventListener("scroll", position, true); + return () => { + observer.disconnect(); + window.removeEventListener("resize", position); + window.removeEventListener("scroll", position, true); + }; + }); +} + // webapp/src/components/FilterEditor.tsx var jsx_runtime2 = __toESM(require_jsx_runtime(), 1); var MODES = [ @@ -8272,8 +8305,8 @@ var MODES = [ var VALUE_LIMIT = 50; var SEARCH_DEBOUNCE_MS = 200; function useDebounced(value, delayMs) { - const [debounced, setDebounced] = import_react5.useState(value); - import_react5.useEffect(() => { + const [debounced, setDebounced] = import_react6.useState(value); + import_react6.useEffect(() => { const timer = setTimeout(() => setDebounced(value), delayMs); return () => clearTimeout(timer); }, [value, delayMs]); @@ -8285,24 +8318,25 @@ function FilterEditor({ onClose }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); - const configured = import_react5.useMemo(() => dashboardTabConfig(catalog, dashboard, state.dashboardTab), [catalog, dashboard, state.dashboardTab]); + const configured = import_react6.useMemo(() => dashboardTabConfig(catalog, dashboard, state.dashboardTab), [catalog, dashboard, state.dashboardTab]); const filter = state.filters[dim.ref]; - const [mode, setModeState] = import_react5.useState(filter?.mode ?? "include"); - const selected = import_react5.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); - const panelRef = import_react5.useRef(null); - const searchRef = import_react5.useRef(null); - const labelId = import_react5.useId(); - const [search, setSearch] = import_react5.useState(""); + const [mode, setModeState] = import_react6.useState(filter?.mode ?? "include"); + const selected = import_react6.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); + const panelRef = import_react6.useRef(null); + useFilterPopover(panelRef); + const searchRef = import_react6.useRef(null); + const labelId = import_react6.useId(); + const [search, setSearch] = import_react6.useState(""); const debouncedSearch = useDebounced(search, SEARCH_DEBOUNCE_MS); const pattern = filter?.mode === "contains" ? filter.pattern ?? "" : ""; - const [patternDraft, setPatternDraft] = import_react5.useState(pattern); + const [patternDraft, setPatternDraft] = import_react6.useState(pattern); const debouncedPattern = useDebounced(patternDraft, SEARCH_DEBOUNCE_MS); - import_react5.useEffect(() => { + import_react6.useEffect(() => { const opener = document.activeElement; searchRef.current?.focus(); return () => opener?.focus?.(); }, []); - import_react5.useEffect(() => { + import_react6.useEffect(() => { function onKey(event) { if (event.key === "Escape") { event.stopPropagation(); @@ -8320,7 +8354,7 @@ function FilterEditor({ document.removeEventListener("mousedown", onPointer, true); }; }, [onClose]); - import_react5.useEffect(() => { + import_react6.useEffect(() => { if (mode !== "contains") return; if (debouncedPattern === pattern) @@ -8329,8 +8363,8 @@ function FilterEditor({ }, [debouncedPattern, mode, dim.ref, dispatch]); const primaryModel = catalog.models.find((candidate) => candidate.name === state.model) ?? model; const timeRef = configured?.timeDimension?.ref ?? primaryModel.timeDimension?.ref; - const types = import_react5.useMemo(() => catalogDimTypes(catalog), [catalog]); - const valueFilters = import_react5.useMemo(() => { + const types = import_react6.useMemo(() => catalogDimTypes(catalog), [catalog]); + const valueFilters = import_react6.useMemo(() => { const base = [ ...configured?.filters ?? [], ...composeFilters(state.filters, { timeRef, range: state.dateRange, excludeDim: dim.ref, types, dialect: catalog.dialect }) @@ -8343,7 +8377,7 @@ function FilterEditor({ const listMode = mode !== "contains"; const { result, loading, error } = useQueryResult(backend, listMode ? distinctValues(dim.ref, valueFilters, VALUE_LIMIT, configured?.segments, configured?.usePreaggregations) : null); const dimAlias = aliasOf(dim.ref); - const values = import_react5.useMemo(() => { + const values = import_react6.useMemo(() => { if (!result) return []; return result.rows.map((row) => { @@ -8382,21 +8416,21 @@ function FilterEditor({ "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg", + className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsx_runtime2.jsxs("div", { id: labelId, className: "mb-2 flex items-baseline justify-between gap-2", children: [ /* @__PURE__ */ jsx_runtime2.jsx("span", { - className: "truncate font-semibold text-ink", + className: "min-w-0 break-words font-semibold text-ink", children: dim.label }), /* @__PURE__ */ jsx_runtime2.jsx("button", { type: "button", "aria-label": "Close filter editor", onClick: onClose, - className: "grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", + className: "grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", children: "×" }) ] @@ -8456,10 +8490,10 @@ function FilterEditor({ type: "checkbox", checked, onChange: () => dispatch({ type: "toggleFilter", dim: dim.ref, value, mode }), - className: "size-3 accent-[var(--accent)]" + className: "size-3 shrink-0 accent-[var(--accent)]" }), /* @__PURE__ */ jsx_runtime2.jsx("span", { - className: "min-w-0 truncate text-ink", + className: "min-w-0 break-words text-ink", children: displayDimValue(value) }) ] @@ -8492,7 +8526,7 @@ function FilterEditor({ // webapp/src/components/FilterPill.tsx var jsx_runtime3 = __toESM(require_jsx_runtime(), 1); function FilterPill(props) { - const [open, setOpen] = import_react6.useState(false); + const [open, setOpen] = import_react7.useState(false); if (!("dim" in props)) { return /* @__PURE__ */ jsx_runtime3.jsxs("span", { "data-dimension": props.dimension, @@ -8701,13 +8735,13 @@ function Leaderboard({ } // webapp/src/components/MetricCard.tsx -var import_react9 = __toESM(require_react(), 1); +var import_react10 = __toESM(require_react(), 1); // webapp/src/components/Sparkline.tsx -var import_react8 = __toESM(require_react(), 1); +var import_react9 = __toESM(require_react(), 1); // webapp/src/components/ChartTooltip.tsx -var import_react7 = __toESM(require_react(), 1); +var import_react8 = __toESM(require_react(), 1); var jsx_runtime5 = __toESM(require_jsx_runtime(), 1); function ChartTooltip({ tip, @@ -8737,15 +8771,15 @@ function Sparkline({ onHover, onBrush }) { - const containerRef = import_react8.useRef(null); - const gradientId = import_react8.useId(); - const svgRef = import_react8.useRef(null); - const dragStart = import_react8.useRef(null); - const [width, setWidth] = import_react8.useState(200); - const [hover, setHover] = import_react8.useState(null); - const [brush, setBrush] = import_react8.useState(null); - const [tip, setTip] = import_react8.useState(null); - import_react8.useEffect(() => { + const containerRef = import_react9.useRef(null); + const gradientId = import_react9.useId(); + const svgRef = import_react9.useRef(null); + const dragStart = import_react9.useRef(null); + const [width, setWidth] = import_react9.useState(200); + const [hover, setHover] = import_react9.useState(null); + const [brush, setBrush] = import_react9.useState(null); + const [tip, setTip] = import_react9.useState(null); + import_react9.useEffect(() => { const node = containerRef.current; if (!node || typeof ResizeObserver === "undefined") return; @@ -8945,7 +8979,7 @@ function MetricCard({ onSparkHover, onSparkBrush }) { - const [sparkHover, setSparkHover] = import_react9.useState(null); + const [sparkHover, setSparkHover] = import_react10.useState(null); const summary = /* @__PURE__ */ jsx_runtime7.jsxs(jsx_runtime7.Fragment, { children: [ /* @__PURE__ */ jsx_runtime7.jsxs("div", { @@ -9309,10 +9343,10 @@ function toComponentQuery({ dimensions = [], metrics = [], result, outputAliases } function renderMetricCards(container, query, options = {}) { const row = rowsOf(query)[0] ?? {}; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...(query.metrics ?? []).map((metric) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...(query.metrics ?? []).map((metric) => { const key = aliasFor(query, metric); const format = typeof options.valueFormat === "function" ? options.valueFormat({ metric, key, value: row[key] }) : options.valueFormat; - return import_react10.createElement(MetricCard, { + return import_react11.createElement(MetricCard, { key: metric, metric, label: options.labels?.[metric] ?? aliasForSemanticRef(metric).replaceAll("_", " "), @@ -9327,10 +9361,10 @@ function renderMetricCards(container, query, options = {}) { function renderMetricSummaryCards(container, config = {}) { const totals = config.totals?.rows?.[0] ?? {}; const series = config.seriesRows ?? []; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...(config.metrics ?? []).map((metric) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...(config.metrics ?? []).map((metric) => { const key = metric.key; const alias = aliasForSemanticRef(key); - return import_react10.createElement(MetricCard, { + return import_react11.createElement(MetricCard, { key, metric: key, label: metric.label ?? alias.replaceAll("_", " "), @@ -9351,7 +9385,7 @@ function renderLeaderboard(container, query, options = {}) { const metricKey = aliasFor(query, metric); const allRows = rowsOf(query); const expanded = options.expanded ?? container.__sdmExpanded ?? false; - mount(container, import_react10.createElement(Leaderboard, { + mount(container, import_react11.createElement(Leaderboard, { dimension, title: options.dimensionLabel ?? dimensionKey.replaceAll("_", " "), metricLabel: options.metricLabel ?? metricKey.replaceAll("_", " "), @@ -9371,13 +9405,13 @@ function renderLeaderboard(container, query, options = {}) { function renderDimensionLeaderboardCards(container, dimensions, config = {}) { const expandedDimension = container.__sdmExpandedDim; const visible = expandedDimension ? dimensions.filter((item) => (item.key ?? item) === expandedDimension) : dimensions; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...visible.map((item) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...visible.map((item) => { const dimension = item.key ?? item; const result = config.resultForDimension?.(item) ?? { rows: [] }; const query = toComponentQuery({ dimensions: [dimension], metrics: [config.metricRef], result }); const rows = rowsOf(query); const expanded = expandedDimension === dimension; - return import_react10.createElement(Leaderboard, { + return import_react11.createElement(Leaderboard, { key: dimension, dimension, title: item.label ?? aliasForSemanticRef(dimension).replaceAll("_", " "), @@ -9398,10 +9432,10 @@ function renderDimensionLeaderboardCards(container, dimensions, config = {}) { function renderFilterPills(container, filters, onRemove, options = {}) { const pills = Object.entries(filters ?? {}).flatMap(([dimension, values]) => (values ?? []).map((value) => { const normalized = normalizeFilterValue(value); - return import_react10.createElement(FilterPill, { key: `${dimension}:${normalized}`, dimension, value: normalized, onRemove: onRemove ? () => onRemove({ dimension, value: normalized }) : undefined }); + return import_react11.createElement(FilterPill, { key: `${dimension}:${normalized}`, dimension, value: normalized, onRemove: onRemove ? () => onRemove({ dimension, value: normalized }) : undefined }); })); for (const extra of options.extraPills ?? []) { - pills.push(import_react10.createElement(FilterPill, { + pills.push(import_react11.createElement(FilterPill, { key: extra.key ?? `${extra.dimension}:${extra.value}`, dimension: extra.dimension, dimensionLabel: extra.dimensionLabel, @@ -9409,15 +9443,15 @@ function renderFilterPills(container, filters, onRemove, options = {}) { onRemove: extra.onRemove })); } - mount(container, pills.length ? import_react10.createElement(import_react10.Fragment, null, ...pills) : options.emptyLabel ? import_react10.createElement("span", { className: "text-faint" }, options.emptyLabel) : null); + mount(container, pills.length ? import_react11.createElement(import_react11.Fragment, null, ...pills) : options.emptyLabel ? import_react11.createElement("span", { className: "text-faint" }, options.emptyLabel) : null); } function renderHighlightedQueryDebug(container, queries) { - mount(container, import_react10.createElement(QueryDebugPanel, { queries: Object.fromEntries(Object.entries(queries ?? {}).map(([name, query]) => [name, typeof query === "string" ? query : query?.sql])) })); + mount(container, import_react11.createElement(QueryDebugPanel, { queries: Object.fromEntries(Object.entries(queries ?? {}).map(([name, query]) => [name, typeof query === "string" ? query : query?.sql])) })); } var renderQueryDebug = renderHighlightedQueryDebug; function renderDataPreview(container, result, options = {}) { const columns = result?.columns ?? []; - mount(container, import_react10.createElement(DataTable, { + mount(container, import_react11.createElement(DataTable, { columns: columns.map((key) => ({ key, label: key.replaceAll("_", " "), numeric: (result.sample_rows ?? result.rows ?? []).some((row) => typeof row[key] === "number") })), rows: result.sample_rows ?? result.rows ?? [], pageSize: options.pageSize || 50, @@ -9426,7 +9460,7 @@ function renderDataPreview(container, result, options = {}) { } function renderState(container, state) { const Component = state.kind === "error" ? ErrorState : state.kind === "loading" ? LoadingState : EmptyState; - mount(container, import_react10.createElement(Component, { message: state.message })); + mount(container, import_react11.createElement(Component, { message: state.message })); } function renderValidationState(stateElement, listElement, errors = []) { stateElement.textContent = errors.length ? "Invalid" : "Valid"; diff --git a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css index 1b770b2a1..8b6236f17 100644 --- a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css +++ b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css @@ -1 +1 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-48{width:12rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:h-9{height:2.25rem}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:py-0{padding-top:0;padding-bottom:0}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js index 9a3b62a0e..64e225643 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js @@ -7659,7 +7659,7 @@ var require_jsx_runtime = __commonJS(function(exports, module) { }); // webapp/src/static-api.tsx -var import_react10 = __toESM(require_react(), 1); +var import_react11 = __toESM(require_react(), 1); var import_client = __toESM(require_client(), 1); var import_react_dom = __toESM(require_react_dom(), 1); @@ -7954,7 +7954,7 @@ function DataTable({ } // webapp/src/components/FilterPill.tsx -var import_react6 = __toESM(require_react(), 1); +var import_react7 = __toESM(require_react(), 1); // webapp/src/data/types.ts function aliasOf(ref) { @@ -7990,7 +7990,7 @@ function filterSummary(filter) { } // webapp/src/components/FilterEditor.tsx -var import_react5 = __toESM(require_react(), 1); +var import_react6 = __toESM(require_react(), 1); // webapp/src/lib/catalog.ts function graphMetricsForModel(catalog, modelName) { @@ -8262,6 +8262,39 @@ function useQueryResult(backend, query) { return { ...state, queryKey: key ?? undefined }; } +// webapp/src/components/useFilterPopover.ts +var import_react5 = __toESM(require_react(), 1); +function useFilterPopover(ref, open = true) { + import_react5.useLayoutEffect(() => { + const panel = ref.current; + const anchor = panel?.parentElement; + if (!open || !panel || !anchor) + return; + function position() { + if (!panel || !anchor) + return; + const bounds = anchor.getBoundingClientRect(); + const gutter = 8; + const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); + panel.style.left = `${left - bounds.left}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + } + position(); + const observer = new ResizeObserver(position); + observer.observe(panel); + observer.observe(anchor); + if (anchor.parentElement) + observer.observe(anchor.parentElement); + window.addEventListener("resize", position); + window.addEventListener("scroll", position, true); + return () => { + observer.disconnect(); + window.removeEventListener("resize", position); + window.removeEventListener("scroll", position, true); + }; + }); +} + // webapp/src/components/FilterEditor.tsx var jsx_runtime2 = __toESM(require_jsx_runtime(), 1); var MODES = [ @@ -8272,8 +8305,8 @@ var MODES = [ var VALUE_LIMIT = 50; var SEARCH_DEBOUNCE_MS = 200; function useDebounced(value, delayMs) { - const [debounced, setDebounced] = import_react5.useState(value); - import_react5.useEffect(() => { + const [debounced, setDebounced] = import_react6.useState(value); + import_react6.useEffect(() => { const timer = setTimeout(() => setDebounced(value), delayMs); return () => clearTimeout(timer); }, [value, delayMs]); @@ -8285,24 +8318,25 @@ function FilterEditor({ onClose }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); - const configured = import_react5.useMemo(() => dashboardTabConfig(catalog, dashboard, state.dashboardTab), [catalog, dashboard, state.dashboardTab]); + const configured = import_react6.useMemo(() => dashboardTabConfig(catalog, dashboard, state.dashboardTab), [catalog, dashboard, state.dashboardTab]); const filter = state.filters[dim.ref]; - const [mode, setModeState] = import_react5.useState(filter?.mode ?? "include"); - const selected = import_react5.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); - const panelRef = import_react5.useRef(null); - const searchRef = import_react5.useRef(null); - const labelId = import_react5.useId(); - const [search, setSearch] = import_react5.useState(""); + const [mode, setModeState] = import_react6.useState(filter?.mode ?? "include"); + const selected = import_react6.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); + const panelRef = import_react6.useRef(null); + useFilterPopover(panelRef); + const searchRef = import_react6.useRef(null); + const labelId = import_react6.useId(); + const [search, setSearch] = import_react6.useState(""); const debouncedSearch = useDebounced(search, SEARCH_DEBOUNCE_MS); const pattern = filter?.mode === "contains" ? filter.pattern ?? "" : ""; - const [patternDraft, setPatternDraft] = import_react5.useState(pattern); + const [patternDraft, setPatternDraft] = import_react6.useState(pattern); const debouncedPattern = useDebounced(patternDraft, SEARCH_DEBOUNCE_MS); - import_react5.useEffect(() => { + import_react6.useEffect(() => { const opener = document.activeElement; searchRef.current?.focus(); return () => opener?.focus?.(); }, []); - import_react5.useEffect(() => { + import_react6.useEffect(() => { function onKey(event) { if (event.key === "Escape") { event.stopPropagation(); @@ -8320,7 +8354,7 @@ function FilterEditor({ document.removeEventListener("mousedown", onPointer, true); }; }, [onClose]); - import_react5.useEffect(() => { + import_react6.useEffect(() => { if (mode !== "contains") return; if (debouncedPattern === pattern) @@ -8329,8 +8363,8 @@ function FilterEditor({ }, [debouncedPattern, mode, dim.ref, dispatch]); const primaryModel = catalog.models.find((candidate) => candidate.name === state.model) ?? model; const timeRef = configured?.timeDimension?.ref ?? primaryModel.timeDimension?.ref; - const types = import_react5.useMemo(() => catalogDimTypes(catalog), [catalog]); - const valueFilters = import_react5.useMemo(() => { + const types = import_react6.useMemo(() => catalogDimTypes(catalog), [catalog]); + const valueFilters = import_react6.useMemo(() => { const base = [ ...configured?.filters ?? [], ...composeFilters(state.filters, { timeRef, range: state.dateRange, excludeDim: dim.ref, types, dialect: catalog.dialect }) @@ -8343,7 +8377,7 @@ function FilterEditor({ const listMode = mode !== "contains"; const { result, loading, error } = useQueryResult(backend, listMode ? distinctValues(dim.ref, valueFilters, VALUE_LIMIT, configured?.segments, configured?.usePreaggregations) : null); const dimAlias = aliasOf(dim.ref); - const values = import_react5.useMemo(() => { + const values = import_react6.useMemo(() => { if (!result) return []; return result.rows.map((row) => { @@ -8382,21 +8416,21 @@ function FilterEditor({ "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg", + className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsx_runtime2.jsxs("div", { id: labelId, className: "mb-2 flex items-baseline justify-between gap-2", children: [ /* @__PURE__ */ jsx_runtime2.jsx("span", { - className: "truncate font-semibold text-ink", + className: "min-w-0 break-words font-semibold text-ink", children: dim.label }), /* @__PURE__ */ jsx_runtime2.jsx("button", { type: "button", "aria-label": "Close filter editor", onClick: onClose, - className: "grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", + className: "grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", children: "×" }) ] @@ -8456,10 +8490,10 @@ function FilterEditor({ type: "checkbox", checked, onChange: () => dispatch({ type: "toggleFilter", dim: dim.ref, value, mode }), - className: "size-3 accent-[var(--accent)]" + className: "size-3 shrink-0 accent-[var(--accent)]" }), /* @__PURE__ */ jsx_runtime2.jsx("span", { - className: "min-w-0 truncate text-ink", + className: "min-w-0 break-words text-ink", children: displayDimValue(value) }) ] @@ -8492,7 +8526,7 @@ function FilterEditor({ // webapp/src/components/FilterPill.tsx var jsx_runtime3 = __toESM(require_jsx_runtime(), 1); function FilterPill(props) { - const [open, setOpen] = import_react6.useState(false); + const [open, setOpen] = import_react7.useState(false); if (!("dim" in props)) { return /* @__PURE__ */ jsx_runtime3.jsxs("span", { "data-dimension": props.dimension, @@ -8701,13 +8735,13 @@ function Leaderboard({ } // webapp/src/components/MetricCard.tsx -var import_react9 = __toESM(require_react(), 1); +var import_react10 = __toESM(require_react(), 1); // webapp/src/components/Sparkline.tsx -var import_react8 = __toESM(require_react(), 1); +var import_react9 = __toESM(require_react(), 1); // webapp/src/components/ChartTooltip.tsx -var import_react7 = __toESM(require_react(), 1); +var import_react8 = __toESM(require_react(), 1); var jsx_runtime5 = __toESM(require_jsx_runtime(), 1); function ChartTooltip({ tip, @@ -8737,15 +8771,15 @@ function Sparkline({ onHover, onBrush }) { - const containerRef = import_react8.useRef(null); - const gradientId = import_react8.useId(); - const svgRef = import_react8.useRef(null); - const dragStart = import_react8.useRef(null); - const [width, setWidth] = import_react8.useState(200); - const [hover, setHover] = import_react8.useState(null); - const [brush, setBrush] = import_react8.useState(null); - const [tip, setTip] = import_react8.useState(null); - import_react8.useEffect(() => { + const containerRef = import_react9.useRef(null); + const gradientId = import_react9.useId(); + const svgRef = import_react9.useRef(null); + const dragStart = import_react9.useRef(null); + const [width, setWidth] = import_react9.useState(200); + const [hover, setHover] = import_react9.useState(null); + const [brush, setBrush] = import_react9.useState(null); + const [tip, setTip] = import_react9.useState(null); + import_react9.useEffect(() => { const node = containerRef.current; if (!node || typeof ResizeObserver === "undefined") return; @@ -8945,7 +8979,7 @@ function MetricCard({ onSparkHover, onSparkBrush }) { - const [sparkHover, setSparkHover] = import_react9.useState(null); + const [sparkHover, setSparkHover] = import_react10.useState(null); const summary = /* @__PURE__ */ jsx_runtime7.jsxs(jsx_runtime7.Fragment, { children: [ /* @__PURE__ */ jsx_runtime7.jsxs("div", { @@ -9309,10 +9343,10 @@ function toComponentQuery({ dimensions = [], metrics = [], result, outputAliases } function renderMetricCards(container, query, options = {}) { const row = rowsOf(query)[0] ?? {}; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...(query.metrics ?? []).map((metric) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...(query.metrics ?? []).map((metric) => { const key = aliasFor(query, metric); const format = typeof options.valueFormat === "function" ? options.valueFormat({ metric, key, value: row[key] }) : options.valueFormat; - return import_react10.createElement(MetricCard, { + return import_react11.createElement(MetricCard, { key: metric, metric, label: options.labels?.[metric] ?? aliasForSemanticRef(metric).replaceAll("_", " "), @@ -9327,10 +9361,10 @@ function renderMetricCards(container, query, options = {}) { function renderMetricSummaryCards(container, config = {}) { const totals = config.totals?.rows?.[0] ?? {}; const series = config.seriesRows ?? []; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...(config.metrics ?? []).map((metric) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...(config.metrics ?? []).map((metric) => { const key = metric.key; const alias = aliasForSemanticRef(key); - return import_react10.createElement(MetricCard, { + return import_react11.createElement(MetricCard, { key, metric: key, label: metric.label ?? alias.replaceAll("_", " "), @@ -9351,7 +9385,7 @@ function renderLeaderboard(container, query, options = {}) { const metricKey = aliasFor(query, metric); const allRows = rowsOf(query); const expanded = options.expanded ?? container.__sdmExpanded ?? false; - mount(container, import_react10.createElement(Leaderboard, { + mount(container, import_react11.createElement(Leaderboard, { dimension, title: options.dimensionLabel ?? dimensionKey.replaceAll("_", " "), metricLabel: options.metricLabel ?? metricKey.replaceAll("_", " "), @@ -9371,13 +9405,13 @@ function renderLeaderboard(container, query, options = {}) { function renderDimensionLeaderboardCards(container, dimensions, config = {}) { const expandedDimension = container.__sdmExpandedDim; const visible = expandedDimension ? dimensions.filter((item) => (item.key ?? item) === expandedDimension) : dimensions; - mount(container, import_react10.createElement(import_react10.Fragment, null, ...visible.map((item) => { + mount(container, import_react11.createElement(import_react11.Fragment, null, ...visible.map((item) => { const dimension = item.key ?? item; const result = config.resultForDimension?.(item) ?? { rows: [] }; const query = toComponentQuery({ dimensions: [dimension], metrics: [config.metricRef], result }); const rows = rowsOf(query); const expanded = expandedDimension === dimension; - return import_react10.createElement(Leaderboard, { + return import_react11.createElement(Leaderboard, { key: dimension, dimension, title: item.label ?? aliasForSemanticRef(dimension).replaceAll("_", " "), @@ -9398,10 +9432,10 @@ function renderDimensionLeaderboardCards(container, dimensions, config = {}) { function renderFilterPills(container, filters, onRemove, options = {}) { const pills = Object.entries(filters ?? {}).flatMap(([dimension, values]) => (values ?? []).map((value) => { const normalized = normalizeFilterValue(value); - return import_react10.createElement(FilterPill, { key: `${dimension}:${normalized}`, dimension, value: normalized, onRemove: onRemove ? () => onRemove({ dimension, value: normalized }) : undefined }); + return import_react11.createElement(FilterPill, { key: `${dimension}:${normalized}`, dimension, value: normalized, onRemove: onRemove ? () => onRemove({ dimension, value: normalized }) : undefined }); })); for (const extra of options.extraPills ?? []) { - pills.push(import_react10.createElement(FilterPill, { + pills.push(import_react11.createElement(FilterPill, { key: extra.key ?? `${extra.dimension}:${extra.value}`, dimension: extra.dimension, dimensionLabel: extra.dimensionLabel, @@ -9409,15 +9443,15 @@ function renderFilterPills(container, filters, onRemove, options = {}) { onRemove: extra.onRemove })); } - mount(container, pills.length ? import_react10.createElement(import_react10.Fragment, null, ...pills) : options.emptyLabel ? import_react10.createElement("span", { className: "text-faint" }, options.emptyLabel) : null); + mount(container, pills.length ? import_react11.createElement(import_react11.Fragment, null, ...pills) : options.emptyLabel ? import_react11.createElement("span", { className: "text-faint" }, options.emptyLabel) : null); } function renderHighlightedQueryDebug(container, queries) { - mount(container, import_react10.createElement(QueryDebugPanel, { queries: Object.fromEntries(Object.entries(queries ?? {}).map(([name, query]) => [name, typeof query === "string" ? query : query?.sql])) })); + mount(container, import_react11.createElement(QueryDebugPanel, { queries: Object.fromEntries(Object.entries(queries ?? {}).map(([name, query]) => [name, typeof query === "string" ? query : query?.sql])) })); } var renderQueryDebug = renderHighlightedQueryDebug; function renderDataPreview(container, result, options = {}) { const columns = result?.columns ?? []; - mount(container, import_react10.createElement(DataTable, { + mount(container, import_react11.createElement(DataTable, { columns: columns.map((key) => ({ key, label: key.replaceAll("_", " "), numeric: (result.sample_rows ?? result.rows ?? []).some((row) => typeof row[key] === "number") })), rows: result.sample_rows ?? result.rows ?? [], pageSize: options.pageSize || 50, @@ -9426,7 +9460,7 @@ function renderDataPreview(container, result, options = {}) { } function renderState(container, state) { const Component = state.kind === "error" ? ErrorState : state.kind === "loading" ? LoadingState : EmptyState; - mount(container, import_react10.createElement(Component, { message: state.message })); + mount(container, import_react11.createElement(Component, { message: state.message })); } function renderValidationState(stateElement, listElement, errors = []) { stateElement.textContent = errors.length ? "Invalid" : "Valid"; diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css index 1b770b2a1..8b6236f17 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css @@ -1 +1 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-48{width:12rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:h-9{height:2.25rem}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:py-0{padding-top:0;padding-bottom:0}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js index f051c1086..e7e482338 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js @@ -1557,6 +1557,39 @@ function useQueryResult(backend, query) { return { ...state, queryKey: key ?? undefined }; } +// webapp/src/components/useFilterPopover.ts +import { useLayoutEffect } from "react"; +function useFilterPopover(ref, open = true) { + useLayoutEffect(() => { + const panel = ref.current; + const anchor = panel?.parentElement; + if (!open || !panel || !anchor) + return; + function position() { + if (!panel || !anchor) + return; + const bounds = anchor.getBoundingClientRect(); + const gutter = 8; + const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); + panel.style.left = `${left - bounds.left}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + } + position(); + const observer = new ResizeObserver(position); + observer.observe(panel); + observer.observe(anchor); + if (anchor.parentElement) + observer.observe(anchor.parentElement); + window.addEventListener("resize", position); + window.addEventListener("scroll", position, true); + return () => { + observer.disconnect(); + window.removeEventListener("resize", position); + window.removeEventListener("scroll", position, true); + }; + }); +} + // webapp/src/components/FilterEditor.tsx import { jsx as jsx10, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime"; var MODES = [ @@ -1585,6 +1618,7 @@ function FilterEditor({ const [mode, setModeState] = useState8(filter?.mode ?? "include"); const selected = useMemo3(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); const panelRef = useRef7(null); + useFilterPopover(panelRef); const searchRef = useRef7(null); const labelId = useId(); const [search, setSearch] = useState8(""); @@ -1677,21 +1711,21 @@ function FilterEditor({ "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg", + className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsxs9("div", { id: labelId, className: "mb-2 flex items-baseline justify-between gap-2", children: [ /* @__PURE__ */ jsx10("span", { - className: "truncate font-semibold text-ink", + className: "min-w-0 break-words font-semibold text-ink", children: dim.label }), /* @__PURE__ */ jsx10("button", { type: "button", "aria-label": "Close filter editor", onClick: onClose, - className: "grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", + className: "grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink", children: "×" }) ] @@ -1751,10 +1785,10 @@ function FilterEditor({ type: "checkbox", checked, onChange: () => dispatch({ type: "toggleFilter", dim: dim.ref, value, mode }), - className: "size-3 accent-[var(--accent)]" + className: "size-3 shrink-0 accent-[var(--accent)]" }), /* @__PURE__ */ jsx10("span", { - className: "min-w-0 truncate text-ink", + className: "min-w-0 break-words text-ink", children: displayDimValue(value) }) ] diff --git a/sidemantic-rs/ui/assets/index-BCalwD9m.css b/sidemantic-rs/ui/assets/index-BCalwD9m.css new file mode 100644 index 000000000..d502892bd --- /dev/null +++ b/sidemantic-rs/ui/assets/index-BCalwD9m.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic-rs/ui/assets/index-DnTdRyzm.css b/sidemantic-rs/ui/assets/index-DnTdRyzm.css deleted file mode 100644 index 416f0789b..000000000 --- a/sidemantic-rs/ui/assets/index-DnTdRyzm.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-48{width:12rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:h-9{height:2.25rem}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:py-0{padding-top:0;padding-bottom:0}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic-rs/ui/assets/index-pE1zWf5r.js b/sidemantic-rs/ui/assets/index-gv_X5qC6.js similarity index 74% rename from sidemantic-rs/ui/assets/index-pE1zWf5r.js rename to sidemantic-rs/ui/assets/index-gv_X5qC6.js index 47cdc3335..706c5d746 100644 --- a/sidemantic-rs/ui/assets/index-pE1zWf5r.js +++ b/sidemantic-rs/ui/assets/index-gv_X5qC6.js @@ -1,4 +1,4 @@ -var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>lb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Be={};/** +var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>cb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Ee={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var im;function cb(){if(im)return Be;im=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.iterator;function b(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,C={};function T(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}T.prototype.isReactComponent={},T.prototype.setState=function(N,W){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,W,"setState")},T.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function $(){}$.prototype=T.prototype;function U(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}var E=U.prototype=new $;E.constructor=U,_(E,T.prototype),E.isPureReactComponent=!0;var F=Array.isArray,A=Object.prototype.hasOwnProperty,M={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function Y(N,W,J){var oe,te={},he=null,Ie=null;if(W!=null)for(oe in W.ref!==void 0&&(Ie=W.ref),W.key!==void 0&&(he=""+W.key),W)A.call(W,oe)&&!L.hasOwnProperty(oe)&&(te[oe]=W[oe]);var Fe=arguments.length-2;if(Fe===1)te.children=J;else if(1e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var am;function ub(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function db(){return lm||(lm=1,id.exports=ub()),id.exports}var u=db(),I=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** + */var am;function db(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function fb(){return lm||(lm=1,id.exports=db()),id.exports}var u=fb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var cm;function fb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,E(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(E(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),E(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function hb(){return um||(um=1,ld.exports=fb()),ld.exports}/** + */var cm;function hb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,B(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(B(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),B(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function pb(){return um||(um=1,ld.exports=hb()),ld.exports}/** * @license React * react-dom.production.min.js * @@ -30,26 +30,26 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var dm;function pb(){if(dm)return zt;dm=1;var n=Vd(),e=hb();function t(r){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+r,o=1;o"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function B(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2S||d[y]!==h[S]){var j=` -`+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&E(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Br=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Br?Pn?Pn.push(r):Pn=[r]:Br=r}function Nf(){if(Br){var r=Br,s=Pn;if(Pn=Br=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(_0(r)/N0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function M0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return nx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function sx(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ix(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function px(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function kx(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(B,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(B,ve),k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(B,ve),rt&&xs(B,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(B,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(B,ve),k=h(es,k,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(B,ve),rt&&xs(B,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(B,ze.value,ee),ze!==null&&(k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(B,De),pe}for(ve=l(B,ve);!ze.done;De++,ze=R.next())ze=se(ve,B,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ob){return s(B,ob)}),rt&&xs(B,De),pe}function ut(B,k,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=k;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(B,ge.sibling),k=d(ge,R.props.children),k.return=B,B=k;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Eh(pe)===ge.type){o(B,ge.sibling),k=d(ge,R.props),k.ref=yo(B,ge,R),k.return=B,B=k;break e}o(B,ge);break}else s(B,ge);ge=ge.sibling}R.type===L?(k=Is(R.props.children,B.mode,ee,R.key),k.return=B,B=k):(ee=il(R.type,R.key,R.props,null,B.mode,ee),ee.ref=yo(B,k,R),ee.return=B,B=ee)}return y(B);case M:e:{for(ge=R.key;k!==null;){if(k.key===ge)if(k.tag===4&&k.stateNode.containerInfo===R.containerInfo&&k.stateNode.implementation===R.implementation){o(B,k.sibling),k=d(k,R.children||[]),k.return=B,B=k;break e}else{o(B,k);break}else s(B,k);k=k.sibling}k=ed(R,B.mode,ee),k.return=B,B=k}return y(B);case ye:return ge=R._init,ut(B,k,ge(R._payload),ee)}if(Un(R))return ue(B,k,R,ee);if(G(R))return de(B,k,R,ee);Ba(B,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,k!==null&&k.tag===6?(o(B,k.sibling),k=d(k,R),k.return=B,B=k):(o(B,k),k=Xu(R,B.mode,ee),k.return=B,B=k),y(B)):o(B,k)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ea=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ea.current;et(Ea),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Cx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Fx(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Ox={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Cx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Dx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&B(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Er=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Er?Pn?Pn.push(r):Pn=[r]:Er=r}function Nf(){if(Er){var r=Er,s=Pn;if(Pn=Er=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(N0(r)/j0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function D0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return rx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ix(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ox(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function mx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Ix(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(E,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(E,ve),I=h(es,I,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(E,ze.value,ee),ze!==null&&(I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(E,De),pe}for(ve=l(E,ve);!ze.done;De++,ze=R.next())ze=se(ve,E,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ab){return s(E,ab)}),rt&&xs(E,De),pe}function ut(E,I,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(E,ge.sibling),I=d(ge,R.props.children),I.return=E,E=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Bh(pe)===ge.type){o(E,ge.sibling),I=d(ge,R.props),I.ref=yo(E,ge,R),I.return=E,E=I;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}R.type===L?(I=Is(R.props.children,E.mode,ee,R.key),I.return=E,E=I):(ee=il(R.type,R.key,R.props,null,E.mode,ee),ee.ref=yo(E,I,R),ee.return=E,E=ee)}return y(E);case M:e:{for(ge=R.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===R.containerInfo&&I.stateNode.implementation===R.implementation){o(E,I.sibling),I=d(I,R.children||[]),I.return=E,E=I;break e}else{o(E,I);break}else s(E,I);I=I.sibling}I=ed(R,E.mode,ee),I.return=E,E=I}return y(E);case ye:return ge=R._init,ut(E,I,ge(R._payload),ee)}if(Un(R))return ue(E,I,R,ee);if(G(R))return de(E,I,R,ee);Ea(E,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,I!==null&&I.tag===6?(o(E,I.sibling),I=d(I,R),I.return=E,E=I):(o(E,I),I=Xu(R,E.mode,ee),I.return=E,E=I),y(E)):o(E,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ba=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ba.current;et(Ba),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Fx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ox(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Tx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Fx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Cx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Px(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,$x=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function zx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,B=s.stateNode,k=B.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);B.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[Nx],delete s[jx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Bp(r){return r.tag===5||r.tag===3||r.tag===4}function Ep(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bp(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new $x),s.forEach(function(l){var d=qx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Wx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function Jx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function qx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Lx(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=Xx(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ea,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Zx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Zx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Xx(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function eb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new eb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function tb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=pb(),ad.exports}var hm;function yb(){if(hm)return hl;hm=1;var n=mb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var gb=yb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function vb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function xb(n,e={}){return _y(n,{...e,compact:!0})}function bb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return vb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return xb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function wb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function Sb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function _b(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Nb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function jb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of jb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function kb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Ib(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Mb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Db=new TextDecoder("utf-8"),Md=n=>Db.decode(n),Cb=new TextEncoder,Wd=n=>Cb.encode(n),Fb=n=>typeof n=="number",Ob=n=>typeof n=="boolean",At=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Go=n=>En(n)&&At(n.then),mc=n=>En(n)&&At(n[Symbol.iterator]),Hd=n=>En(n)&&At(n[Symbol.asyncIterator]),Dd=n=>En(n)&&En(n.schema),Dy=n=>En(n)&&"done"in n&&"value"in n,Cy=n=>En(n)&&At(n.stat)&&Fb(n.fd),Fy=n=>En(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>En(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>En(n)&&At(n.read)&&At(n.pipe)&&Ob(n.readable)&&!Oy(n),Tb=n=>En(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ab(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Eb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Rb=n=>Ay(Uint8Array,n);function Lb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Ub(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Eb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Vb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class By{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new By(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Wb=void 0;function Yo(n){if(n===null)return"null";if(n===Wb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Hb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Hb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Qb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Gb=BigInt(4294967296)*BigInt(4294967296),Yb=Gb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Bt extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Bt[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Bt.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Kb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Kb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Jb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Jb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function qb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Zb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=qb(t)},ew=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Zb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},tw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),nw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},rw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},iw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},ow=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),fw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?uw(e,t):t instanceof Je?cw(e,t):Array.isArray(t)?lw(e,t):dw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},hw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},pw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},mw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},yw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},gw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new vw(this[On],this[_i])}}class vw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const bw=(n,e)=>864e5*n[e],ww=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},Sw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<bw(n,e),Eg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],_w=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],Nw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},jw=({values:n},e)=>n[e],kw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Iw=(n,e)=>n.type.unit===bn.DAY?Bg(n,e):Eg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Mw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Cw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Fw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Ow=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Tw=(n,e)=>new Jd(n,e),Aw=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Ew=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Rw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Lw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(ww);xe.prototype.visitBool=je(Sw);xe.prototype.visitInt=je(jw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(kw);xe.prototype.visitFloat16=je(_w);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(Nw);xe.prototype.visitDate=je(Iw);xe.prototype.visitDateDay=je(Bg);xe.prototype.visitDateMillisecond=je(Eg);xe.prototype.visitTimestamp=je(Mw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Dw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Cw);xe.prototype.visitList=je(Fw);xe.prototype.visitStruct=je(Tw);xe.prototype.visitUnion=je(Aw);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Ew);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Rw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Lw);xe.prototype.visitMap=je(Ow);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new Pw)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Uw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Uw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Pw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Bi(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Lb(n,t):!1:n instanceof Map?zw(n):Array.isArray(n)?$w(n):n instanceof Je?Vw(n):Ww(n,!0)}function $w(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Hw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Gw(n,t):!1}}function Hw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Bd(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Bd(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Ed(n,e,a)+Ed(n,i,t)+Qw(n,a>>3,i-a>>3)}function Qw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Kw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Kw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Ed(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const Jw=new Vo;function Ee(n){return Jw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function Xw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return Xw(n,t)}const i=Qt.getVisitFn(n),a=Bi(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new e1(f)})}class e1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return qw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var t1=Ey,n1=Ii;class rf{static decode(e){e=new n1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new r1(i,t)}static encode(e){const t=new t1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class i1 extends s1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new o1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof i1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class o1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class l1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Bd(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?c1(i[t]):me.isBool(e)?Bd(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function c1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Et(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Et(n,e)}function Mr(n,e){return n===e||Et(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Et(n,e)&&n.precision===e.precision}function u1(n,e){return n===e||Et(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function d1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function f1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Et(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Et(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function p1(n,e){return n===e||Et(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function m1(n,e){return n===e||Et(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=u1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=d1;Se.prototype.visitStruct=f1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=h1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=p1;Se.prototype.visitMap=m1;const cs=new Se;function y1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return g1(n,e.map(t=>t.data.concat()))}function g1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Ee({type:new Bt(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function v1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Ee({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Bt)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!y1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+h.stack}return{value:r,source:s,stack:d,digest:null}}function Du(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Cu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Bx=typeof WeakMap=="function"?WeakMap:Map;function pp(r,s,o){o=fr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Xa||(Xa=!0,Hu=l),Cu(r,s)},o}function mp(r,s,o){o=fr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Cu(r,s)}}var h=r.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Cu(r,s),typeof l!="function"&&(Kr===null?Kr=new Set([this]):Kr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function yp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Bx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Jx.bind(null,r,s,o),s.then(r,r))}function gp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function vp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=fr(-1,1),s.tag=2,Yr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Rx=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Lh(s,null,o,l):Xs(s,r.child,o,l)}function xp(r,s,o,l,d){o=o.render;var h=s.ref;return ti(s,d),l=wu(r,s,o,l,h,d),o=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&o&&su(s),s.flags|=1,Ft(r,s,l,d),s.child)}function bp(r,s,o,l,d){if(r===null){var h=o.type;return typeof h=="function"&&!Zu(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=h,wp(r,s,h,l,d)):(r=il(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(h=r.child,(r.lanes&d)===0){var y=h.memoizedProps;if(o=o.compare,o=o!==null?o:lo,o(y,l)&&r.ref===s.ref)return hr(r,s,d)}return s.flags|=1,r=Xr(h,l),r.ref=s.ref,r.return=s,s.child=r}function wp(r,s,o,l,d){if(r!==null){var h=r.memoizedProps;if(lo(h,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=h,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,hr(r,s,d)}return Fu(r,s,o,l,d)}function Sp(r,s,o){var l=s.pendingProps,d=l.children,h=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(ii,Zt),Zt|=o;else{if((o&1073741824)===0)return r=h!==null?h.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(ii,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:o,qe(ii,Zt),Zt|=l}else h!==null?(l=h.baseLanes|o,s.memoizedState=null):l=o,qe(ii,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function _p(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Fu(r,s,o,l,d){var h=Lt(o)?gs:kt.current;return h=Ks(s,h),ti(s,d),o=wu(r,s,o,l,h,d),l=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&l&&su(s),s.flags|=1,Ft(r,s,o,d),s.child)}function Np(r,s,o,l,d){if(Lt(o)){var h=!0;Ca(s)}else h=!1;if(ti(s,d),s.stateNode===null)Qa(r,s),fp(s,o,l),Mu(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,P=o.contextType;typeof P=="object"&&P!==null?P=ln(P):(P=Lt(o)?gs:kt.current,P=Ks(s,P));var q=o.getDerivedStateFromProps,Z=typeof q=="function"||typeof y.getSnapshotBeforeUpdate=="function";Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==P)&&hp(s,y,l,P),Gr=!1;var K=s.memoizedState;y.state=K,Ua(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||Gr?(typeof q=="function"&&(Iu(s,o,q,l),j=s.memoizedState),(S=Gr||dp(s,o,S,l,K,j,P))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=P,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Ph(r,s),S=s.memoizedProps,P=s.type===s.elementType?S:jn(s.type,S),y.props=P,Z=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=ln(j):(j=Lt(o)?gs:kt.current,j=Ks(s,j));var se=o.getDerivedStateFromProps;(q=typeof se=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Z||K!==j)&&hp(s,y,l,j),Gr=!1,K=s.memoizedState,y.state=K,Ua(s,l,y,d);var ue=s.memoizedState;S!==Z||K!==ue||Rt.current||Gr?(typeof se=="function"&&(Iu(s,o,se,l),ue=s.memoizedState),(P=Gr||dp(s,o,P,l,K,ue,j)||!1)?(q||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=P):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Ou(r,s,o,l,h,d)}function Ou(r,s,o,l,d,h){_p(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Dh(s,o,!1),hr(r,s,h);l=s.stateNode,Rx.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=Xs(s,r.child,null,h),s.child=Xs(s,null,S,h)):Ft(r,s,S,h),s.memoizedState=l.state,d&&Dh(s,o,!0),s.child}function jp(r){var s=r.stateNode;s.pendingContext?Ih(r,s.pendingContext,s.pendingContext!==s.context):s.context&&Ih(r,s.context,!1),mu(r,s.containerInfo)}function kp(r,s,o,l,d){return Zs(),lu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Tu={dehydrated:null,treeContext:null,retryLane:0};function Au(r){return{baseLanes:r,cachePool:null,transitions:null}}function Ip(r,s,o){var l=s.pendingProps,d=it.current,h=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(h=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return au(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,h?(l=s.mode,h=s.child,y={mode:"hidden",children:y},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=y):h=ol(y,l,0,null),r=Is(r,l,o,null),h.return=s,r.return=s,h.sibling=r,s.child=h,s.child.memoizedState=Au(o),s.memoizedState=Tu,r):Eu(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Lx(r,s,y,l,S,d,o);if(h){h=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Xr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?h=Xr(S,h):(h=Is(h,y,o,null),h.flags|=2),h.return=s,l.return=s,l.sibling=h,s.child=l,l=h,h=s.child,y=r.child.memoizedState,y=y===null?Au(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},h.memoizedState=y,h.childLanes=r.childLanes&~o,s.memoizedState=Tu,l}return h=r.child,r=h.sibling,l=Xr(h,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Eu(r,s){return s=ol({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Ya(r,s,o,l){return l!==null&&lu(l),Xs(s,r.child,null,o),r=Eu(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Lx(r,s,o,l,d,h,y){if(o)return s.flags&256?(s.flags&=-257,l=Du(Error(t(422))),Ya(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(h=l.fallback,d=s.mode,l=ol({mode:"visible",children:l.children},d,0,null),h=Is(h,d,y,null),h.flags|=2,l.return=s,h.return=s,l.sibling=h,s.child=l,(s.mode&1)!==0&&Xs(s,r.child,null,y),s.child.memoizedState=Au(y),s.memoizedState=Tu,h);if((s.mode&1)===0)return Ya(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,h=Error(t(419)),l=Du(h,l,void 0),Ya(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,dr(r,d),Mn(l,r,d,-1))}return qu(),l=Du(Error(t(421))),Ya(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=qx.bind(null,r),d._reactRetry=s,null):(r=h.treeContext,qt=zr(d.nextSibling),Jt=s,rt=!0,Nn=null,r!==null&&(on[an++]=cr,on[an++]=ur,on[an++]=vs,cr=r.id,ur=r.overflow,vs=s),s=Eu(s,l.children),s.flags|=4096,s)}function Mp(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),fu(r.return,s,o)}function Bu(r,s,o,l,d){var h=r.memoizedState;h===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(h.isBackwards=s,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=o,h.tailMode=d)}function Dp(r,s,o){var l=s.pendingProps,d=l.revealOrder,h=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Mp(r,o,s);else if(r.tag===19)Mp(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Pa(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Bu(s,!1,d,o,h);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Pa(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Bu(s,!0,o,null,h);break;case"together":Bu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Qa(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function hr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),_s|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Xr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Xr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function Ux(r,s,o){switch(s.tag){case 3:jp(s),Zs();break;case 5:Vh(s);break;case 1:Lt(s.type)&&Ca(s);break;case 4:mu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ba,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?Ip(r,s,o):(qe(it,it.current&1),r=hr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Dp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,Sp(r,s,o)}return hr(r,s,o)}var Cp,Ru,Fp,Op;Cp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ru=function(){},Fp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,ws(Vn.current);var h=null;switch(o){case"input":d=or(r,d),l=or(r,l),h=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),h=[];break;case"textarea":d=Ui(r,d),l=Ui(r,l),h=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Ia)}fe(o,l);var y;o=null;for(P in d)if(!l.hasOwnProperty(P)&&d.hasOwnProperty(P)&&d[P]!=null)if(P==="style"){var S=d[P];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else P!=="dangerouslySetInnerHTML"&&P!=="children"&&P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(a.hasOwnProperty(P)?h||(h=[]):(h=h||[]).push(P,null));for(P in l){var j=l[P];if(S=d!=null?d[P]:void 0,l.hasOwnProperty(P)&&j!==S&&(j!=null||S!=null))if(P==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(h||(h=[]),h.push(P,o)),o=j;else P==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(h=h||[]).push(P,j)):P==="children"?typeof j!="string"&&typeof j!="number"||(h=h||[]).push(P,""+j):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&(a.hasOwnProperty(P)?(j!=null&&P==="onScroll"&&Xe("scroll",r),h||S===j||(h=[])):(h=h||[]).push(P,j))}o&&(h=h||[]).push("style",o);var P=h;(s.updateQueue=P)&&(s.flags|=4)}},Op=function(r,s,o,l){o!==l&&(s.flags|=4)};function No(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function Mt(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function Px(r,s,o){var l=s.pendingProps;switch(iu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mt(s),null;case 1:return Lt(s.type)&&Da(),Mt(s),null;case 3:return l=s.stateNode,ni(),et(Rt),et(kt),vu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Aa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Nn!==null&&(Qu(Nn),Nn=null))),Ru(r,s),Mt(s),null;case 5:yu(s);var d=ws(xo.current);if(o=s.type,r!==null&&s.stateNode!=null)Fp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return Mt(s),null}if(r=ws(Vn.current),Aa(s)){l=s.stateNode,o=s.type;var h=s.memoizedProps;switch(l[zn]=s,l[po]=h,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function $x(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,zx=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Vx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,I=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[jx],delete s[kx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ep(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ep(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new zx),s.forEach(function(l){var d=Zx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Hx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function Zx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ux(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=eb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ba,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Xx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Xx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function eb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function tb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new tb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function nb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=mb(),ad.exports}var hm;function gb(){if(hm)return hl;hm=1;var n=yb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var vb=gb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function xb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function bb(n,e={}){return _y(n,{...e,compact:!0})}function wb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return xb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return bb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function Sb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function _b(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function Nb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function jb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function kb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of kb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Ib(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Mb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Db(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Cb=new TextDecoder("utf-8"),Md=n=>Cb.decode(n),Fb=new TextEncoder,Wd=n=>Fb.encode(n),Ob=n=>typeof n=="number",Tb=n=>typeof n=="boolean",At=n=>typeof n=="function",Bn=n=>n!=null&&Object(n)===n,Go=n=>Bn(n)&&At(n.then),mc=n=>Bn(n)&&At(n[Symbol.iterator]),Hd=n=>Bn(n)&&At(n[Symbol.asyncIterator]),Dd=n=>Bn(n)&&Bn(n.schema),Dy=n=>Bn(n)&&"done"in n&&"value"in n,Cy=n=>Bn(n)&&At(n.stat)&&Ob(n.fd),Fy=n=>Bn(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>Bn(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>Bn(n)&&At(n.read)&&At(n.pipe)&&Tb(n.readable)&&!Oy(n),Ab=n=>Bn(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Rb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Lb=n=>Ay(Uint8Array,n);function Ub(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Pb(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Rb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Wb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Hb=void 0;function Yo(n){if(n===null)return"null";if(n===Hb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Gb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Gb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Kb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Yb=BigInt(4294967296)*BigInt(4294967296),Qb=Yb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Et extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Et[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Et.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Jb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Jb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function qb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Zb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Xb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=Zb(t)},tw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Xb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},nw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),rw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},ow=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},aw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),hw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?dw(e,t):t instanceof Je?uw(e,t):Array.isArray(t)?cw(e,t):fw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},pw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},mw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},yw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},gw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},vw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xw(this[On],this[_i])}}class xw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const ww=(n,e)=>864e5*n[e],Sw=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},_w=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<ww(n,e),Bg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],Nw=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],jw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},kw=({values:n},e)=>n[e],Iw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Mw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Bg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Fw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Ow=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Tw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Aw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Rw=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Lw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Uw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(Sw);xe.prototype.visitBool=je(_w);xe.prototype.visitInt=je(kw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(Iw);xe.prototype.visitFloat16=je(Nw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(jw);xe.prototype.visitDate=je(Mw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Bg);xe.prototype.visitTimestamp=je(Dw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Cw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Fw);xe.prototype.visitList=je(Ow);xe.prototype.visitStruct=je(Aw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Rw);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Lw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Uw);xe.prototype.visitMap=je(Tw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new $w)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Pw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Pw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class $w{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Ei(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Ub(n,t):!1:n instanceof Map?Vw(n):Array.isArray(n)?zw(n):n instanceof Je?Ww(n):Hw(n,!0)}function zw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Gw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Yw(n,t):!1}}function Gw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ed(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Ed(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Kw(n,a>>3,i-a>>3)}function Kw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Jw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Jw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const qw=new Vo;function Be(n){return qw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function e1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return e1(n,t)}const i=Qt.getVisitFn(n),a=Ei(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new t1(f)})}class t1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Zw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var n1=By,r1=Ii;class rf{static decode(e){e=new r1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new s1(i,t)}static encode(e){const t=new n1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class o1 extends i1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new a1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof o1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class a1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class c1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ed(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?u1(i[t]):me.isBool(e)?Ed(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function u1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function d1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function f1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function m1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function y1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=d1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=f1;Se.prototype.visitStruct=h1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=p1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=m1;Se.prototype.visitMap=y1;const cs=new Se;function g1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return v1(n,e.map(t=>t.data.concat()))}function v1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Be({type:new Et(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function x1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Be({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Et)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!g1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Ee({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ee({nullCount:0,type:new Bt(this.schema.fields),children:this.schema.fields.map(t=>Ee({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Ee({type:new Bt(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Ee({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Ee({type:new Bt(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Ee({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Ee({type:new Bt(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cEe({type:a.type})),i=Ee({type:new Bt(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class x1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new x1;function b1(n,e=new Map){return new We(S1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function w1(n){return new kr(bv(n.data),n.id,n.isDelta)}function S1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Bm(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Ei(t.count,_1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function N1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Bm(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Em(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Em(i):new Jo,e.set(t,f=Rm(n,Bm(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Em(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Bt(e||[]);case"struct_":return new Bt(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var j1=Ey,k1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=I1(e,t),i}static decode(e){e=new k1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=M1(t,c),f}static encode(e){const t=new j1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ei{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function I1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=U1;nt.decode=R1;nt.fromJSON=N1;We.encode=L1;We.decode=D1;We.fromJSON=b1;Rn.encode=P1;Rn.decode=C1;Rn.fromJSON=bv;kr.encode=$1;kr.decode=F1;kr.fromJSON=w1;Ei.encode=z1;Ei.decode=T1;_r.encode=V1;_r.decode=O1;function D1(n,e=new Map,t=ht.V5){const i=E1(n,e);return new We(i,Tl(n),e,t)}function C1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),A1(n),B1(n,e))}function F1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function O1(n){return new _r(n.offset(),n.length())}function T1(n){return new Ei(n.length(),n.nullCount())}function A1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,W1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function U1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function P1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ei.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function $1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function z1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function V1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const W1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?q1(e):Cy(e)?eS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?X1(new Fi(e)):Z1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class Q1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Ee({type:new Bt(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new G1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new H1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function X1(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function eS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Y1&&df(yield t.readAt(0,na+7&-8))?new Q1(new K1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function tS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function nS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const sS="application/vnd.apache.arrow.stream";class iS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function oS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class aS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new iS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return oS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=kb(await t.json());try{return Mb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Ib(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?rS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:sS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=nS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=I.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=I.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=I.useId(),w=I.useRef(null),_=I.useRef(null),C=f&&v;return I.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),I.useEffect(()=>{p&&!m&&x(!0)},[p,m]),I.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var E,F;return(F=(E=w.current)==null?void 0:E.querySelector("button"))==null?void 0:F.focus()});function U(E){var L;if(E.key==="Escape"){E.preventDefault(),x(!1);return}if(E.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];E.shiftKey&&document.activeElement===A?(E.preventDefault(),M.focus()):!E.shiftKey&&document.activeElement===M&&(E.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-x-auto border-b border-line bg-surface px-3 py-2 md:h-9 md:flex-nowrap md:py-0",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function lS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const cS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function uS(n,e){const t=n.split("__").at(-1);return t&&cS.has(t)?t:e}function dS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function fS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",E=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:E,selectedMetric:C,grain:$?uS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:fS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??dS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function hS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function pS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function mS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=pS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function yS(n){return{from:Vm(n.from),to:Vm(n.to)}}function gS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function vS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function xS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function bS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${bS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function wS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Bv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=wS(a,c,f,e.dialect);p&&t.push(p)}return t}function Bs(n,e={}){const t=Bv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...vS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const SS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:SS[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function _S(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function NS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function jS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function kS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function IS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=kS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function MS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Ev(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??MS(n),c=(i==null?void 0:i.selectedMetric)??Ev(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function DS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const CS=["home","explore","pivot"],FS=new Set(Pd),OS=new Set(["none","pctTotal","delta","deltaPct"]),TS=new Set(["off","previous","year","custom"]),AS="none",BS="previous",ES="UTC";function RS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const LS=new Set(["include","exclude","contains"]);function US(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!LS.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function PS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=US(i);a&&(e[t]=a)}return e}function $S(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function zS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==ES&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==AS&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify($S(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function VS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&CS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&FS.has(m)&&(i.grain=m);const g=t.get("tz");RS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&OS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&TS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=PS(bl(t.get("filters")));U&&(i.filters=U);const E=bl(t.get("jdims"));Wo(E)&&(i.joinedDims=[...new Set(E)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=I.createContext(null);function Qm(n){const e=zS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=VS(n,i),c=Ts(e,t,a.dashboardTab);return c?DS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function WS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=I.useMemo(()=>Rv(n,t),[n,t]),[p,m]=I.useReducer(IS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=I.useRef(i);I.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=I.useRef(a);v.current=a,I.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=I.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=I.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function HS(){Cs.active+=1,Uv()}function GS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return I.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const YS=80;function Bn(n,e){const[t,i]=I.useState({loading:!1}),a=I.useRef(0),c=e?JSON.stringify(e):null;return I.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{HS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>GS())},YS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}const QS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],KS=50,qm=200;function Zm(n,e){const[t,i]=I.useState(n);return I.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function $v({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=I.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=I.useState((g==null?void 0:g.mode)??"include"),b=I.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=I.useRef(null),_=I.useRef(null),C=I.useId(),[T,$]=I.useState(""),U=Zm(T,qm),E=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=I.useState(E),M=Zm(F,qm);I.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),I.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),I.useEffect(()=>{v==="contains"&&M!==E&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=I.useMemo(()=>xc(f),[f]),Q=I.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Bs(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=Bn(c,V?_S(n.ref,Q,KS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=I.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(E)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:QS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 truncate text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function JS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(g=>g.type!=="time"),[i,a]=I.useState(!1),[c,f]=I.useState(null),p=I.useRef(null);I.useEffect(()=>{if(!i)return;function g(x){x.key==="Escape"&&m()}function v(x){c||p.current&&!p.current.contains(x.target)&&m()}return document.addEventListener("keydown",g,!0),document.addEventListener("mousedown",v,!0),()=>{document.removeEventListener("keydown",g,!0),document.removeEventListener("mousedown",v,!0)}},[i,c]);function m(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?m():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 z-50 mt-1 max-h-64 w-48 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(g=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(g),className:"block w-full truncate px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:g.label},g.ref))}):null,i&&c?u.jsx($v,{dim:c,model:n,onClose:m}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function qS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class ZS extends I.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const XS=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function zv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=I.useRef(null),[p,m]=I.useState((n==null?void 0:n.from)??""),[g,v]=I.useState((n==null?void 0:n.to)??""),[x,b]=I.useState((a==null?void 0:a.from)??""),[w,_]=I.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",E=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${E?"opacity-50":""}`,children:XS.map(F=>u.jsx("button",{type:"button",disabled:E,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!E?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=I.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",Nb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx($v,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const e_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function t_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function n_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function r_({timezone:n,disabled:e,onChange:t}){const i=I.useId(),[a,c]=I.useState(!1),[f,p]=I.useState(""),m=I.useMemo(()=>{const b=new Set(e_);return n&&b.add(n),[...b]},[n]),g=I.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();t_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=n_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function s_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const i_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=I.useState(0),[w,_]=I.useState(""),C=I.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:E,visibleRows:F}=bb(C,x,p);I.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},E+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=s_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:i_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[E+1,"–",Math.min(E+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function o_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function a_(){var U,E;const[n,e]=I.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=I.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=o_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((E=f==null?void 0:f.timeDimension)==null?void 0:E.ref),x=I.useMemo(()=>xc(i),[i]),b=I.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Bs(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?jS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Vv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Vv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Wv(n){document.documentElement.dataset.theme=n}function l_(){Wv(yf())}function c_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Vv,n),Wv(n),n}function Zo(){const[n,e]=I.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(c_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Hv({view:n,onChange:e}){const t=I.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Gv="dashboard_filters",Yv="dashboard_ranges",Qv="dashboard_filter_sources",Kv="dashboard_range_sources",Jv="dashboard_chart_filters",qv="dashboard_chart_ranges";function u_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function d_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function f_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function h_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=h_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function p_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function m_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function y_(n,e,t){return[e,...t].some(i=>gf(n,i))}const g_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return g_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Zv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function Xv(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function e0(n,e,t){const i=Fs(n);if(i){const a=Xv(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function v_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[e0(n,{from:e,to:e},i)]:Bv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function x_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Zv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([E,F])=>v_(E,F,i,f)),...Object.entries(p.ranges).map(([E,F])=>e0(E,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=Xv(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function b_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,E=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return E&&(w.set("from",E.from),w.set("to",E.to)),`/explore?${w}`}function w_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function S_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function t0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function s0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function __(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Gv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Yv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Qv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Kv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Jv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(qv)??"{}")}catch{x={}}const b=r0(e),w=s0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:t0(v,w),chartRanges:n0(x,w)}}function N_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Gv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Yv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Qv,JSON.stringify(i)),Object.keys(a).length&&t.set(Kv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Jv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(qv,JSON.stringify(n.chartRanges)),t.toString()}function i0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function j_(n){try{const e=JSON.parse(localStorage.getItem(i0(n))??"[]");if(!Array.isArray(e))return[];const t=r0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=s0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:t0(c.chartFilters,p),chartRanges:n0(c.chartRanges,p)}}]})}catch{return[]}}function k_(n,e){try{return localStorage.setItem(i0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function I_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r -`)}function M_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function D_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Ev(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const C_="600px";function F_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function O_(n,e,t=C_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:F_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const T_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function o0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,E=m!=="none",F=E?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),E?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${T_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const A_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],E_=[];function R_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=E_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=I.useRef(null),[U,E]=I.useState(!1);I.useEffect(()=>{if(!(U||!$.current))return O_($.current,()=>E(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=I.useMemo(()=>xc(T),[T]),M=I.useMemo(()=>[...p,...Bs(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=Bn(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=I.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=I.useMemo(()=>ae&&f&&F&&ie?[...p,...Bs(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=Bn(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=I.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:wb(he,c);case"delta":return Sb(he,H.get(te),N);case"deltaPct":return _b(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(o0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:A_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=I.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function a0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=I.useRef(null),m=I.useId(),g=I.useRef(null),v=I.useRef(null),[x,b]=I.useState(200),[w,_]=I.useState(null),[C,T]=I.useState(null),[$,U]=I.useState(null);I.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const E=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(E.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...E.map(H=>H.value)),L=Math.max(...E.map(H=>H.value))-A||1,Y=E.map((H,N)=>({...H,x:F+N/(E.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${E.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const L_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},U_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=I.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${L_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:U_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(a0,{values:p,labels:m,onHover:E=>{C(E),b==null||b(E)},onBrush:w,formatValue:E=>pt(E,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=I.useRef(null),x=I.useRef(null),b=I.useRef(!1),w=I.useRef(null),[_,C]=I.useState(820),[T,$]=I.useState(null),[U,E]=I.useState(null);I.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},E({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},E({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,E(null)}function W(){$(null),b.current=!1,w.current=null,E(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const P_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function $_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${P_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const z_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function V_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} +]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Be({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Be({nullCount:0,type:new Et(this.schema.fields),children:this.schema.fields.map(t=>Be({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Be({type:new Et(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Be({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Be({type:new Et(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Be({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Be({type:new Et(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cBe({type:a.type})),i=Be({type:new Et(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class b1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new b1;function w1(n,e=new Map){return new We(_1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function S1(n){return new kr(bv(n.data),n.id,n.isDelta)}function _1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Em(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Bi(t.count,N1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function j1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Em(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Bm(i):new Jo,e.set(t,f=Rm(n,Em(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Et(e||[]);case"struct_":return new Et(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var k1=By,I1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=M1(e,t),i}static decode(e){e=new I1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=D1(t,c),f}static encode(e){const t=new k1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Bi{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=P1;nt.decode=L1;nt.fromJSON=j1;We.encode=U1;We.decode=C1;We.fromJSON=w1;Rn.encode=$1;Rn.decode=F1;Rn.fromJSON=bv;kr.encode=z1;kr.decode=O1;kr.fromJSON=S1;Bi.encode=V1;Bi.decode=A1;_r.encode=W1;_r.decode=T1;function C1(n,e=new Map,t=ht.V5){const i=R1(n,e);return new We(i,Tl(n),e,t)}function F1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),B1(n,e))}function O1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function T1(n){return new _r(n.offset(),n.length())}function A1(n){return new Bi(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,H1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function P1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function $1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Bi.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function z1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function V1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function W1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const H1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?Z1(e):Cy(e)?tS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?eS(new Fi(e)):X1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class K1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Be({type:new Et(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new Y1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new G1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function eS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function tS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Q1&&df(yield t.readAt(0,na+7&-8))?new K1(new J1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function nS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function rS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const iS="application/vnd.apache.arrow.stream";class oS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function aS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class lS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new oS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return aS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Ib(await t.json());try{return Db(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Mb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?sS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:iS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=rS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var B,F;return(F=(B=w.current)==null?void 0:B.querySelector("button"))==null?void 0:F.focus()});function U(B){var L;if(B.key==="Escape"){B.preventDefault(),x(!1);return}if(B.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];B.shiftKey&&document.activeElement===A?(B.preventDefault(),M.focus()):!B.shiftKey&&document.activeElement===M&&(B.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"relative z-30 flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function cS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const uS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function dS(n,e){const t=n.split("__").at(-1);return t&&uS.has(t)?t:e}function fS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function hS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",B=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:B,selectedMetric:C,grain:$?dS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:hS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??fS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function pS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function mS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function yS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=mS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function gS(n){return{from:Vm(n.from),to:Vm(n.to)}}function vS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function xS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function bS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function wS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${wS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function SS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Ev(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=SS(a,c,f,e.dialect);p&&t.push(p)}return t}function Es(n,e={}){const t=Ev(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...xS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const _S={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:_S[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function NS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function jS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function kS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function IS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function MS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=IS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function DS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Bv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??DS(n),c=(i==null?void 0:i.selectedMetric)??Bv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function CS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const FS=["home","explore","pivot"],OS=new Set(Pd),TS=new Set(["none","pctTotal","delta","deltaPct"]),AS=new Set(["off","previous","year","custom"]),ES="none",BS="previous",RS="UTC";function LS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const US=new Set(["include","exclude","contains"]);function PS(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!US.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function $S(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=PS(i);a&&(e[t]=a)}return e}function zS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function VS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==RS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(zS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function WS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&FS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&OS.has(m)&&(i.grain=m);const g=t.get("tz");LS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&TS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&AS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=$S(bl(t.get("filters")));U&&(i.filters=U);const B=bl(t.get("jdims"));Wo(B)&&(i.joinedDims=[...new Set(B)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=k.createContext(null);function Qm(n){const e=VS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=WS(n,i),c=Ts(e,t,a.dashboardTab);return c?CS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function HS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Rv(n,t),[n,t]),[p,m]=k.useReducer(MS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function GS(){Cs.active+=1,Uv()}function YS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const QS=80;function En(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{GS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>YS())},QS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function $v(n,e=!0){k.useLayoutEffect(()=>{const t=n.current,i=t==null?void 0:t.parentElement;if(!e||!t||!i)return;function a(){if(!t||!i)return;const f=i.getBoundingClientRect(),p=8,m=Math.max(p,Math.min(f.left,window.innerWidth-t.offsetWidth-p));t.style.left=`${m-f.left}px`,t.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-f.bottom-p-4)}px`)}a();const c=new ResizeObserver(a);return c.observe(t),c.observe(i),i.parentElement&&c.observe(i.parentElement),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{c.disconnect(),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}})}const KS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],JS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function zv({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=k.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=k.useState((g==null?void 0:g.mode)??"include"),b=k.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=k.useRef(null);$v(w);const _=k.useRef(null),C=k.useId(),[T,$]=k.useState(""),U=Zm(T,qm),B=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=k.useState(B),M=Zm(F,qm);k.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),k.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),k.useEffect(()=>{v==="contains"&&M!==B&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=k.useMemo(()=>xc(f),[f]),Q=k.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Es(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=En(c,V?NS(n.ref,Q,JS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=k.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(B)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:KS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function qS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(v=>v.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null);$v(m,i&&!c),k.useEffect(()=>{if(!i)return;function v(b){b.key==="Escape"&&g()}function x(b){c||p.current&&!p.current.contains(b.target)&&g()}return document.addEventListener("keydown",v,!0),document.addEventListener("mousedown",x,!0),()=>{document.removeEventListener("keydown",v,!0),document.removeEventListener("mousedown",x,!0)}},[i,c]);function g(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?g():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 top-full z-50 mt-1 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(v=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(v),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:v.label},v.ref))}):null,i&&c?u.jsx(zv,{dim:c,model:n,onClose:g}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function ZS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class XS extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const e_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Vv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",B=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${B?"opacity-50":""}`,children:e_.map(F=>u.jsx("button",{type:"button",disabled:B,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!B?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",jb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(zv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const t_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function n_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function r_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function s_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(t_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();n_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=r_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function i_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const o_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:B,visibleRows:F}=wb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},B+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=i_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:o_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[B+1,"–",Math.min(B+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function a_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function l_(){var U,B;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=a_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((B=f==null?void 0:f.timeDimension)==null?void 0:B.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Es(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?kS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=En(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Wv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Wv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Hv(n){document.documentElement.dataset.theme=n}function c_(){Hv(yf())}function u_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Wv,n),Hv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(u_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Gv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Yv="dashboard_filters",Qv="dashboard_ranges",Kv="dashboard_filter_sources",Jv="dashboard_range_sources",qv="dashboard_chart_filters",Zv="dashboard_chart_ranges";function d_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function f_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function h_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function p_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=p_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function m_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function y_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function g_(n,e,t){return[e,...t].some(i=>gf(n,i))}const v_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return v_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Xv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function e0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function t0(n,e,t){const i=Fs(n);if(i){const a=e0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function x_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[t0(n,{from:e,to:e},i)]:Ev({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function b_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Xv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([B,F])=>x_(B,F,i,f)),...Object.entries(p.ranges).map(([B,F])=>t0(B,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=e0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function w_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,B=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return B&&(w.set("from",B.from),w.set("to",B.to)),`/explore?${w}`}function S_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function __(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function s0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function i0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function N_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Yv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Qv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Kv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Jv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Zv)??"{}")}catch{x={}}const b=s0(e),w=i0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:n0(v,w),chartRanges:r0(x,w)}}function j_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Yv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Qv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Kv,JSON.stringify(i)),Object.keys(a).length&&t.set(Jv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Zv,JSON.stringify(n.chartRanges)),t.toString()}function o0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function k_(n){try{const e=JSON.parse(localStorage.getItem(o0(n))??"[]");if(!Array.isArray(e))return[];const t=s0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=i0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:n0(c.chartFilters,p),chartRanges:r0(c.chartRanges,p)}}]})}catch{return[]}}function I_(n,e){try{return localStorage.setItem(o0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function M_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r +`)}function D_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function C_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Bv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const F_="600px";function O_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function T_(n,e,t=F_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:O_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const A_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function a0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,B=m!=="none",F=B?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),B?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${A_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],R_=[];function L_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=R_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=k.useRef(null),[U,B]=k.useState(!1);k.useEffect(()=>{if(!(U||!$.current))return T_($.current,()=>B(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Es(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=En(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=k.useMemo(()=>ae&&f&&F&&ie?[...p,...Es(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=En(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=k.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:Sb(he,c);case"delta":return _b(he,H.get(te),N);case"deltaPct":return Nb(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(a0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:E_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function l0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[$,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const B=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(B.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...B.map(H=>H.value)),L=Math.max(...B.map(H=>H.value))-A||1,Y=B.map((H,N)=>({...H,x:F+N/(B.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${B.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const U_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},P_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${U_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:P_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(l0,{values:p,labels:m,onHover:B=>{C(B),b==null||b(B)},onBrush:w,formatValue:B=>pt(B,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,$]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},B({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},B({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,B(null)}function W(){$(null),b.current=!1,w.current=null,B(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const $_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function z_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${$_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const V_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function W_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} ${c}`).join(` -`),i=V_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function W_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const H_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!H_.has(n.type)}function G_(n,e){return!!(n&&n===e)}function Y_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function Q_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:xS(n.to,e)}}function K_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=I.useState(null),p=t.models.find(fe=>fe.name===n.model),m=I.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);I.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=I.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=I.useMemo(()=>xc(t),[t]),E=I.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=I.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?yS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:mS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=I.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=Bn(i,!C&&$.length?L(vd($,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=Bn(i,!C&&$.length&&w?L(Gm($,w,n.grain,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=Bn(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=Bn(i,C?L(vd([C.ref],E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=Bn(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Y_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=G_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:Q_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Br=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,W_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Br,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx($_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>gS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(R_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function J_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=I.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=I.useState(null),T=I.useMemo(()=>pf(a),[a]),$=I.useMemo(()=>Bs(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),E=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?NS(w,v,$,E,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=Bn(t,A),z=[...v,...w],Q=I.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=I.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function q_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function l0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=I.useRef(null),[f,p]=I.useState(640),{tip:m,handlers:g}=Cr();I.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),E=Math.max(8,Math.min(48,U*.62)),F=q_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-E)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:E,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+E/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Es(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function c0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=I.useRef(null),[m,g]=I.useState(640),{tip:v,handlers:x}=Cr();I.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),E=Math.max(...C),F=$-T||1,A=E-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Es(U,E,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Es(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function Z_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function X_(n){return pf(n.models.flatMap(e=>e.dimensions))}function e2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function t2({chart:n,columns:e,rows:t}){const i=I_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function n2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=d_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function r2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=I.useState(!1),g=I.useMemo(()=>X_(t),[t]),v=I.useMemo(()=>x_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=Bn(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=p_(e),$=T[0]??e2(e),U=br(C,w),E=vf(n,e,a),F=Zv(e,g),A=f_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=y_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(c0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=S_(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=w_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(l0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:E.filters[C],onSelect:Y?he=>{c(m_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:b_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(t2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(n2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function s2({document:n,state:e,onLoad:t}){const[i,a]=I.useState(""),[c,f]=I.useState(()=>j_(n)),[p,m]=I.useState(!1);function g(v){f(v),m(!k_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function i2(){const[n,e]=I.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function o2({document:n,catalog:e,backend:t}){const[i,a]=I.useState(()=>__(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];I.useEffect(()=>{window.document.title=n.title},[n.title]),I.useEffect(()=>{const b=N_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const E={...U.chartRanges??{}},F={...E[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?E[C]=F:delete E[C],{...U,chartRanges:E}});return}a(U=>{const E={...U.ranges},F={...U.rangeSources};return _?(E[w]=_,F[w]=C):(delete E[w],delete F[w]),{...U,ranges:E,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(s2,{document:n,state:i,onLoad:a}),u.jsx(i2,{}),u.jsx(Zo,{}),u.jsx(Z_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:M_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(r2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function a2(){const[n,e]=I.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function l2({backend:n,onAuthenticated:e}){const[t,i]=I.useState(""),[a,c]=I.useState(null),[f,p]=I.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function c2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(E=>E.name===n.model),m=I.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=I.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=hS(x==null?void 0:x.supportedGranularities,n.grain),_=I.useMemo(()=>{const E=new Map;for(const F of t.models)for(const A of F.dimensions)E.set(A.ref,{dim:A,model:F});return E},[t]),C=Object.entries(n.filters).flatMap(([E,F])=>{const A=_.get(E);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:E})},E)]:[]}),T=u.jsx(lS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(E=>{const F=E.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,E.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:E.label??E.id},E.id)})}):u.jsx(Hv,{view:n.view,onChange:E=>e({type:"setView",view:E})}),u.jsx(zv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(E,F)=>e({type:"setDateRange",range:E,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(E,F)=>e({type:"setComparison",comparison:E,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:E=>e({type:"setGrain",grain:E})}),u.jsx(r_,{timezone:n.timezone,disabled:!b,onChange:E=>e({type:"setTimezone",timezone:E})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(a2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(JS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(qS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(a_,{}),children:u.jsxs(ZS,{children:[n.view==="home"?u.jsx(D_,{}):null,n.view==="explore"?u.jsx(K_,{}):null,n.view==="pivot"?u.jsx(J_,{}):null]},n.view)})}function u2(){const[n,e]=I.useState(!1),t=I.useMemo(()=>new aS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=I.useState(null),[c,f]=I.useState(null),[p,m]=I.useState(0),g=u_(window.location.pathname,window.location.search);return I.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(l2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(o2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(WS,{catalog:i.catalog,backend:t,children:u.jsx(c2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function d2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=I.useRef(null),[m,g]=I.useState(640),{tip:v,handlers:x}=Cr();if(I.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),E=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/E)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Es(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Es($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const f2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${f2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function h2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=I.useId(),p=I.useRef(null),[m,g]=I.useState(!1),[v,x]=I.useState(""),[b,w]=I.useState(0),_=I.useMemo(()=>h2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};I.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function E(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:E,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function p2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const m2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function u0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function y2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:u0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return u0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=I.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=I.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=I.useState(null),b=I.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:m2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:y2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const E=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:E}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function g2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function v2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const d0=Math.PI*2;function x2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*d0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function b2(n,e,t,i,a,c){const f=Math.min(c-a,d0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function w2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=I.useRef(null),[f,p]=I.useState(360),{tip:m,handlers:g}=Cr();I.useEffect(()=>fs(c.current,220,p),[]);const v=x2(n),x=v.reduce((U,E)=>U+E.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:b2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function S2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=I.useRef(null),[p,m]=I.useState(640),{tip:g,handlers:v}=Cr();I.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,E=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*E+E/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*E+.5,width:Math.max(1,U-1),height:Math.max(1,E-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function _2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function N2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=I.useRef(null),[f,p]=I.useState(640),{tip:m,handlers:g}=Cr();I.useEffect(()=>fs(c.current,160,p),[]);const v=_2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(E=>E.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=E=>Fn.top+(1-E/x)*w,C=b/v.length,T=Es(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((E,F)=>{const A=_(E);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(E)})]},F)}),v.map((E,F)=>{const A=Fn.left+C*F,M=_(E.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":E.x0,"data-x1":E.x1,"data-count":E.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(E.x0)} – ${i(E.x1)}`,rows:[{label:"Count",value:E.count.toLocaleString()}]}))},F)}),v.map((E,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(E.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function j2(n){let e=2166136261;for(let t=0;t>>0}function k2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function I2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=k2(j2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function M2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=I.useRef(null),[c,f]=I.useState(640),{tip:p,handlers:m}=Cr();I.useEffect(()=>fs(a.current,240,f),[]);const g=I.useMemo(()=>I2(n,e,{width:c,height:t}),[n,e,c,t]),v=I.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=I.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function D2(n,e,t){return Math.min(Math.max(n,e),t)}function C2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=I.useRef(null),[p,m]=I.useState(640),[g,v]=I.useState(null);I.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,E=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${E(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${E(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Es(0,C,4).map((z,Q)=>{const V=E(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function F2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function O2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function T2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function A2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=I.useRef(null),[c,f]=I.useState(640),{tip:p,handlers:m}=Cr();I.useEffect(()=>fs(a.current,200,f),[]);const g=A2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),E=Es(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[E.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function E2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function R2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,E2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const L2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],U2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],P2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),$2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),z2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),V2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function W2(){const[n,e]=I.useState("orders.revenue"),[t,i]=I.useState({}),[a,c]=I.useState(null),[f,p]=I.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=I.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=I.useState("month"),[b,w]=I.useState("explore"),[_,C]=I.useState("previous"),[T,$]=I.useState("orders.revenue"),[U,E]=I.useState(["orders.revenue","orders.count"]),[F,A]=I.useState("apple"),[M,L]=I.useState(!0),[Y,z]=I.useState("explore"),[Q,V]=I.useState("2025-06-15"),[X,ne]=I.useState({from:"2025-06-01",to:"2025-06-21"}),ae=I.useMemo(()=>R2(P2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=I.useState({key:"revenue",dir:"desc"}),re=I.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:L2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(o0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(zv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Hv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(a0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(l0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(v2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(w2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(C2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(d2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(N2,{values:z2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(c0,{points:$2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(S2,{cells:V2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(M2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(F2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(O2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(T2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:E,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:U2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(g2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue +`),i=W_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function H_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const G_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!G_.has(n.type)}function Y_(n,e){return!!(n&&n===e)}function Q_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function K_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:bS(n.to,e)}}function J_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(fe=>fe.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=k.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),B=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?gS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:yS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=En(i,!C&&$.length?L(vd($,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=En(i,!C&&$.length&&w?L(Gm($,w,n.grain,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=En(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=En(i,C?L(vd([C.ref],B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=En(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Q_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Y_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:K_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Er=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,H_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Er,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(z_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>vS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(L_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function q_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),$=k.useMemo(()=>Es(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),B=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?jS(w,v,$,B,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=En(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function Z_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function c0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),B=Math.max(8,Math.min(48,U*.62)),F=Z_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-B)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:B,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+B/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Bs(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function u0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),B=Math.max(...C),F=$-T||1,A=B-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Bs(U,B,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Bs(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function X_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function e2(n){return pf(n.models.flatMap(e=>e.dimensions))}function t2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function n2({chart:n,columns:e,rows:t}){const i=M_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function r2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=f_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function s2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>e2(t),[t]),v=k.useMemo(()=>b_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=En(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=m_(e),$=T[0]??t2(e),U=br(C,w),B=vf(n,e,a),F=Xv(e,g),A=h_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=g_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(u0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=__(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=S_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(c0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:B.filters[C],onSelect:Y?he=>{c(y_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:w_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(n2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(r2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function i2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>k_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!I_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function o2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function a2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>N_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=j_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const B={...U.chartRanges??{}},F={...B[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?B[C]=F:delete B[C],{...U,chartRanges:B}});return}a(U=>{const B={...U.ranges},F={...U.rangeSources};return _?(B[w]=_,F[w]=C):(delete B[w],delete F[w]),{...U,ranges:B,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(i2,{document:n,state:i,onLoad:a}),u.jsx(o2,{}),u.jsx(Zo,{}),u.jsx(X_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:D_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(s2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function l2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function c2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function u2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(B=>B.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=pS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const B=new Map;for(const F of t.models)for(const A of F.dimensions)B.set(A.ref,{dim:A,model:F});return B},[t]),C=Object.entries(n.filters).flatMap(([B,F])=>{const A=_.get(B);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:B})},B)]:[]}),T=u.jsx(cS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(B=>{const F=B.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,B.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:B.label??B.id},B.id)})}):u.jsx(Gv,{view:n.view,onChange:B=>e({type:"setView",view:B})}),u.jsx(Vv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(B,F)=>e({type:"setDateRange",range:B,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(B,F)=>e({type:"setComparison",comparison:B,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:B=>e({type:"setGrain",grain:B})}),u.jsx(s_,{timezone:n.timezone,disabled:!b,onChange:B=>e({type:"setTimezone",timezone:B})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(l2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(qS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(ZS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(l_,{}),children:u.jsxs(XS,{children:[n.view==="home"?u.jsx(C_,{}):null,n.view==="explore"?u.jsx(J_,{}):null,n.view==="pivot"?u.jsx(q_,{}):null]},n.view)})}function d2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new lS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=d_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(c2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(a2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(HS,{catalog:i.catalog,backend:t,children:u.jsx(u2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function f2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),B=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/B)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Bs(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Bs($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const h2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${h2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function p2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>p2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};k.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function B(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:B,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function m2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const y2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function d0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function g2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:d0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return d0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:y2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:g2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const B=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:B}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function v2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function x2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const f0=Math.PI*2;function b2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*f0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function w2(n,e,t,i,a,c){const f=Math.min(c-a,f0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function S2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=b2(n),x=v.reduce((U,B)=>U+B.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:w2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function _2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,B=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*B+B/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*B+.5,width:Math.max(1,U-1),height:Math.max(1,B-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function N2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function j2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=N2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(B=>B.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=B=>Fn.top+(1-B/x)*w,C=b/v.length,T=Bs(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((B,F)=>{const A=_(B);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(B)})]},F)}),v.map((B,F)=>{const A=Fn.left+C*F,M=_(B.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":B.x0,"data-x1":B.x1,"data-count":B.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(B.x0)} – ${i(B.x1)}`,rows:[{label:"Count",value:B.count.toLocaleString()}]}))},F)}),v.map((B,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(B.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function k2(n){let e=2166136261;for(let t=0;t>>0}function I2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function M2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=I2(k2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function D2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>M2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function C2(n,e,t){return Math.min(Math.max(n,e),t)}function F2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,B=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${B(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${B(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Bs(0,C,4).map((z,Q)=>{const V=B(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function O2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function T2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function A2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),B=Bs(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[B.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function R2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function L2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,R2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const U2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],P2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],$2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),z2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),V2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),W2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function H2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,$]=k.useState("orders.revenue"),[U,B]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,L]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,V]=k.useState("2025-06-15"),[X,ne]=k.useState({from:"2025-06-01",to:"2025-06-21"}),ae=k.useMemo(()=>L2($2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:U2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(a0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Vv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Gv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(l0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(c0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(x2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(S2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(F2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(f2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(j2,{values:V2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(u0,{points:z2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(_2,{cells:W2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(D2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(O2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(T2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(A2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:B,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:P2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(v2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue FROM orders WHERE orders.status = 'completed' GROUP BY orders.region -ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(p2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],H2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const G2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Y2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],Q2=[31,42,38,55,60,74],K2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),J2=`select region, sum(revenue) as revenue +ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(m2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],G2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Y2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Q2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],K2=[31,42,38,55,60,74],J2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),q2=`select region, sum(revenue) as revenue from orders where created_at >= date '2025-01-01' group by all -order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function q2(){const[n,e]=I.useState("geist"),[t,i]=I.useState("geistmono"),[a,c]=I.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;I.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:H2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:Q2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:K2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:J2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:G2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Y2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}l_();const f0=document.getElementById("root");if(!f0)throw new Error("Missing #root element");gb.createRoot(f0).render(u.jsx(I.StrictMode,{children:window.location.pathname==="/components"?u.jsx(W2,{}):window.location.pathname==="/typography"?u.jsx(q2,{}):u.jsx(u2,{})})); +order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function Z2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:G2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:K2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:J2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:q2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Y2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Q2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}c_();const h0=document.getElementById("root");if(!h0)throw new Error("Missing #root element");vb.createRoot(h0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(H2,{}):window.location.pathname==="/typography"?u.jsx(Z2,{}):u.jsx(d2,{})})); diff --git a/sidemantic-rs/ui/index.html b/sidemantic-rs/ui/index.html index 53d08f6cd..55587f6f8 100644 --- a/sidemantic-rs/ui/index.html +++ b/sidemantic-rs/ui/index.html @@ -4,8 +4,8 @@ Sidemantic - - + +
diff --git a/sidemantic/ui/static/assets/index-BCalwD9m.css b/sidemantic/ui/static/assets/index-BCalwD9m.css new file mode 100644 index 000000000..d502892bd --- /dev/null +++ b/sidemantic/ui/static/assets/index-BCalwD9m.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic/ui/static/assets/index-DnTdRyzm.css b/sidemantic/ui/static/assets/index-DnTdRyzm.css deleted file mode 100644 index 416f0789b..000000000 --- a/sidemantic/ui/static/assets/index-DnTdRyzm.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-48{width:12rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:h-9{height:2.25rem}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:py-0{padding-top:0;padding-bottom:0}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic/ui/static/assets/index-pE1zWf5r.js b/sidemantic/ui/static/assets/index-gv_X5qC6.js similarity index 74% rename from sidemantic/ui/static/assets/index-pE1zWf5r.js rename to sidemantic/ui/static/assets/index-gv_X5qC6.js index 47cdc3335..706c5d746 100644 --- a/sidemantic/ui/static/assets/index-pE1zWf5r.js +++ b/sidemantic/ui/static/assets/index-gv_X5qC6.js @@ -1,4 +1,4 @@ -var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>lb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Be={};/** +var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>cb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Ee={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var im;function cb(){if(im)return Be;im=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.iterator;function b(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,C={};function T(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}T.prototype.isReactComponent={},T.prototype.setState=function(N,W){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,W,"setState")},T.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function $(){}$.prototype=T.prototype;function U(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}var E=U.prototype=new $;E.constructor=U,_(E,T.prototype),E.isPureReactComponent=!0;var F=Array.isArray,A=Object.prototype.hasOwnProperty,M={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function Y(N,W,J){var oe,te={},he=null,Ie=null;if(W!=null)for(oe in W.ref!==void 0&&(Ie=W.ref),W.key!==void 0&&(he=""+W.key),W)A.call(W,oe)&&!L.hasOwnProperty(oe)&&(te[oe]=W[oe]);var Fe=arguments.length-2;if(Fe===1)te.children=J;else if(1e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var am;function ub(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function db(){return lm||(lm=1,id.exports=ub()),id.exports}var u=db(),I=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** + */var am;function db(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function fb(){return lm||(lm=1,id.exports=db()),id.exports}var u=fb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var cm;function fb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,E(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(E(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),E(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function hb(){return um||(um=1,ld.exports=fb()),ld.exports}/** + */var cm;function hb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,B(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(B(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),B(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function pb(){return um||(um=1,ld.exports=hb()),ld.exports}/** * @license React * react-dom.production.min.js * @@ -30,26 +30,26 @@ var ab=Object.defineProperty;var lb=(n,e,t)=>e in n?ab(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var dm;function pb(){if(dm)return zt;dm=1;var n=Vd(),e=hb();function t(r){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+r,o=1;o"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function B(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2S||d[y]!==h[S]){var j=` -`+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&E(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Br=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Br?Pn?Pn.push(r):Pn=[r]:Br=r}function Nf(){if(Br){var r=Br,s=Pn;if(Pn=Br=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(_0(r)/N0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function M0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return nx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function sx(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ix(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function px(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function kx(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(B,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(B,ve),k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(B,ve),rt&&xs(B,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(B,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(B,ve),k=h(es,k,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(B,ve),rt&&xs(B,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(B,ze.value,ee),ze!==null&&(k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(B,De),pe}for(ve=l(B,ve);!ze.done;De++,ze=R.next())ze=se(ve,B,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),k=h(ze,k,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ob){return s(B,ob)}),rt&&xs(B,De),pe}function ut(B,k,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=k;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(B,ge.sibling),k=d(ge,R.props.children),k.return=B,B=k;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Eh(pe)===ge.type){o(B,ge.sibling),k=d(ge,R.props),k.ref=yo(B,ge,R),k.return=B,B=k;break e}o(B,ge);break}else s(B,ge);ge=ge.sibling}R.type===L?(k=Is(R.props.children,B.mode,ee,R.key),k.return=B,B=k):(ee=il(R.type,R.key,R.props,null,B.mode,ee),ee.ref=yo(B,k,R),ee.return=B,B=ee)}return y(B);case M:e:{for(ge=R.key;k!==null;){if(k.key===ge)if(k.tag===4&&k.stateNode.containerInfo===R.containerInfo&&k.stateNode.implementation===R.implementation){o(B,k.sibling),k=d(k,R.children||[]),k.return=B,B=k;break e}else{o(B,k);break}else s(B,k);k=k.sibling}k=ed(R,B.mode,ee),k.return=B,B=k}return y(B);case ye:return ge=R._init,ut(B,k,ge(R._payload),ee)}if(Un(R))return ue(B,k,R,ee);if(G(R))return de(B,k,R,ee);Ba(B,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,k!==null&&k.tag===6?(o(B,k.sibling),k=d(k,R),k.return=B,B=k):(o(B,k),k=Xu(R,B.mode,ee),k.return=B,B=k),y(B)):o(B,k)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ea=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ea.current;et(Ea),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Cx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Fx(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Ox={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Cx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Dx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&B(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Er=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Er?Pn?Pn.push(r):Pn=[r]:Er=r}function Nf(){if(Er){var r=Er,s=Pn;if(Pn=Er=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(N0(r)/j0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function D0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return rx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ix(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ox(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function mx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Ix(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(E,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(E,ve),I=h(es,I,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(E,ze.value,ee),ze!==null&&(I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(E,De),pe}for(ve=l(E,ve);!ze.done;De++,ze=R.next())ze=se(ve,E,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ab){return s(E,ab)}),rt&&xs(E,De),pe}function ut(E,I,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(E,ge.sibling),I=d(ge,R.props.children),I.return=E,E=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Bh(pe)===ge.type){o(E,ge.sibling),I=d(ge,R.props),I.ref=yo(E,ge,R),I.return=E,E=I;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}R.type===L?(I=Is(R.props.children,E.mode,ee,R.key),I.return=E,E=I):(ee=il(R.type,R.key,R.props,null,E.mode,ee),ee.ref=yo(E,I,R),ee.return=E,E=ee)}return y(E);case M:e:{for(ge=R.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===R.containerInfo&&I.stateNode.implementation===R.implementation){o(E,I.sibling),I=d(I,R.children||[]),I.return=E,E=I;break e}else{o(E,I);break}else s(E,I);I=I.sibling}I=ed(R,E.mode,ee),I.return=E,E=I}return y(E);case ye:return ge=R._init,ut(E,I,ge(R._payload),ee)}if(Un(R))return ue(E,I,R,ee);if(G(R))return de(E,I,R,ee);Ea(E,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,I!==null&&I.tag===6?(o(E,I.sibling),I=d(I,R),I.return=E,E=I):(o(E,I),I=Xu(R,E.mode,ee),I.return=E,E=I),y(E)):o(E,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ba=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ba.current;et(Ba),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Fx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ox(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Tx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Fx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Cx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Px(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,$x=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function zx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,B=s.stateNode,k=B.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);B.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[Nx],delete s[jx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Bp(r){return r.tag===5||r.tag===3||r.tag===4}function Ep(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bp(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new $x),s.forEach(function(l){var d=qx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Wx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function Jx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function qx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Lx(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=Xx(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ea,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Zx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Zx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Xx(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function eb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new eb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function tb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=pb(),ad.exports}var hm;function yb(){if(hm)return hl;hm=1;var n=mb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var gb=yb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function vb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function xb(n,e={}){return _y(n,{...e,compact:!0})}function bb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return vb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return xb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function wb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function Sb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function _b(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function Nb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function jb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of jb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function kb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Ib(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Mb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Db=new TextDecoder("utf-8"),Md=n=>Db.decode(n),Cb=new TextEncoder,Wd=n=>Cb.encode(n),Fb=n=>typeof n=="number",Ob=n=>typeof n=="boolean",At=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Go=n=>En(n)&&At(n.then),mc=n=>En(n)&&At(n[Symbol.iterator]),Hd=n=>En(n)&&At(n[Symbol.asyncIterator]),Dd=n=>En(n)&&En(n.schema),Dy=n=>En(n)&&"done"in n&&"value"in n,Cy=n=>En(n)&&At(n.stat)&&Fb(n.fd),Fy=n=>En(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>En(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>En(n)&&At(n.read)&&At(n.pipe)&&Ob(n.readable)&&!Oy(n),Tb=n=>En(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ab(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Eb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Rb=n=>Ay(Uint8Array,n);function Lb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Ub(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Eb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Vb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class By{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new By(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Wb=void 0;function Yo(n){if(n===null)return"null";if(n===Wb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Hb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Hb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Qb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Gb=BigInt(4294967296)*BigInt(4294967296),Yb=Gb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Bt extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Bt[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Bt.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Kb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Kb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Jb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Jb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function qb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Zb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=qb(t)},ew=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Zb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},tw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),nw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},rw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},iw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},ow=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},lw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),fw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?uw(e,t):t instanceof Je?cw(e,t):Array.isArray(t)?lw(e,t):dw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},hw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},pw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},mw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},yw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},gw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new vw(this[On],this[_i])}}class vw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const bw=(n,e)=>864e5*n[e],ww=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},Sw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<bw(n,e),Eg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],_w=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],Nw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},jw=({values:n},e)=>n[e],kw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Iw=(n,e)=>n.type.unit===bn.DAY?Bg(n,e):Eg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Mw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Cw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Fw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Ow=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Tw=(n,e)=>new Jd(n,e),Aw=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Ew=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Rw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Lw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(ww);xe.prototype.visitBool=je(Sw);xe.prototype.visitInt=je(jw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(kw);xe.prototype.visitFloat16=je(_w);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(Nw);xe.prototype.visitDate=je(Iw);xe.prototype.visitDateDay=je(Bg);xe.prototype.visitDateMillisecond=je(Eg);xe.prototype.visitTimestamp=je(Mw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Dw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Cw);xe.prototype.visitList=je(Fw);xe.prototype.visitStruct=je(Tw);xe.prototype.visitUnion=je(Aw);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Ew);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Rw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Lw);xe.prototype.visitMap=je(Ow);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new Pw)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Uw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Uw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class Pw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Bi(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Lb(n,t):!1:n instanceof Map?zw(n):Array.isArray(n)?$w(n):n instanceof Je?Vw(n):Ww(n,!0)}function $w(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Hw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Gw(n,t):!1}}function Hw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Bd(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Bd(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Ed(n,e,a)+Ed(n,i,t)+Qw(n,a>>3,i-a>>3)}function Qw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Kw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Kw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Ed(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const Jw=new Vo;function Ee(n){return Jw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function Xw(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return Xw(n,t)}const i=Qt.getVisitFn(n),a=Bi(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new e1(f)})}class e1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return qw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var t1=Ey,n1=Ii;class rf{static decode(e){e=new n1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new r1(i,t)}static encode(e){const t=new t1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class i1 extends s1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new o1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof i1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class o1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class l1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Bd(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?c1(i[t]):me.isBool(e)?Bd(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function c1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Et(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Et(n,e)}function Mr(n,e){return n===e||Et(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Et(n,e)&&n.precision===e.precision}function u1(n,e){return n===e||Et(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function d1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function f1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Et(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Et(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function p1(n,e){return n===e||Et(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function m1(n,e){return n===e||Et(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=u1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=d1;Se.prototype.visitStruct=f1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=h1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=p1;Se.prototype.visitMap=m1;const cs=new Se;function y1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return g1(n,e.map(t=>t.data.concat()))}function g1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Ee({type:new Bt(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function v1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Ee({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Bt)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!y1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+h.stack}return{value:r,source:s,stack:d,digest:null}}function Du(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Cu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Bx=typeof WeakMap=="function"?WeakMap:Map;function pp(r,s,o){o=fr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Xa||(Xa=!0,Hu=l),Cu(r,s)},o}function mp(r,s,o){o=fr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Cu(r,s)}}var h=r.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Cu(r,s),typeof l!="function"&&(Kr===null?Kr=new Set([this]):Kr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function yp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Bx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Jx.bind(null,r,s,o),s.then(r,r))}function gp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function vp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=fr(-1,1),s.tag=2,Yr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Rx=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Lh(s,null,o,l):Xs(s,r.child,o,l)}function xp(r,s,o,l,d){o=o.render;var h=s.ref;return ti(s,d),l=wu(r,s,o,l,h,d),o=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&o&&su(s),s.flags|=1,Ft(r,s,l,d),s.child)}function bp(r,s,o,l,d){if(r===null){var h=o.type;return typeof h=="function"&&!Zu(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=h,wp(r,s,h,l,d)):(r=il(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(h=r.child,(r.lanes&d)===0){var y=h.memoizedProps;if(o=o.compare,o=o!==null?o:lo,o(y,l)&&r.ref===s.ref)return hr(r,s,d)}return s.flags|=1,r=Xr(h,l),r.ref=s.ref,r.return=s,s.child=r}function wp(r,s,o,l,d){if(r!==null){var h=r.memoizedProps;if(lo(h,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=h,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,hr(r,s,d)}return Fu(r,s,o,l,d)}function Sp(r,s,o){var l=s.pendingProps,d=l.children,h=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(ii,Zt),Zt|=o;else{if((o&1073741824)===0)return r=h!==null?h.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(ii,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:o,qe(ii,Zt),Zt|=l}else h!==null?(l=h.baseLanes|o,s.memoizedState=null):l=o,qe(ii,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function _p(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Fu(r,s,o,l,d){var h=Lt(o)?gs:kt.current;return h=Ks(s,h),ti(s,d),o=wu(r,s,o,l,h,d),l=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&l&&su(s),s.flags|=1,Ft(r,s,o,d),s.child)}function Np(r,s,o,l,d){if(Lt(o)){var h=!0;Ca(s)}else h=!1;if(ti(s,d),s.stateNode===null)Qa(r,s),fp(s,o,l),Mu(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,P=o.contextType;typeof P=="object"&&P!==null?P=ln(P):(P=Lt(o)?gs:kt.current,P=Ks(s,P));var q=o.getDerivedStateFromProps,Z=typeof q=="function"||typeof y.getSnapshotBeforeUpdate=="function";Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==P)&&hp(s,y,l,P),Gr=!1;var K=s.memoizedState;y.state=K,Ua(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||Gr?(typeof q=="function"&&(Iu(s,o,q,l),j=s.memoizedState),(S=Gr||dp(s,o,S,l,K,j,P))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=P,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Ph(r,s),S=s.memoizedProps,P=s.type===s.elementType?S:jn(s.type,S),y.props=P,Z=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=ln(j):(j=Lt(o)?gs:kt.current,j=Ks(s,j));var se=o.getDerivedStateFromProps;(q=typeof se=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Z||K!==j)&&hp(s,y,l,j),Gr=!1,K=s.memoizedState,y.state=K,Ua(s,l,y,d);var ue=s.memoizedState;S!==Z||K!==ue||Rt.current||Gr?(typeof se=="function"&&(Iu(s,o,se,l),ue=s.memoizedState),(P=Gr||dp(s,o,P,l,K,ue,j)||!1)?(q||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=P):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Ou(r,s,o,l,h,d)}function Ou(r,s,o,l,d,h){_p(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Dh(s,o,!1),hr(r,s,h);l=s.stateNode,Rx.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=Xs(s,r.child,null,h),s.child=Xs(s,null,S,h)):Ft(r,s,S,h),s.memoizedState=l.state,d&&Dh(s,o,!0),s.child}function jp(r){var s=r.stateNode;s.pendingContext?Ih(r,s.pendingContext,s.pendingContext!==s.context):s.context&&Ih(r,s.context,!1),mu(r,s.containerInfo)}function kp(r,s,o,l,d){return Zs(),lu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Tu={dehydrated:null,treeContext:null,retryLane:0};function Au(r){return{baseLanes:r,cachePool:null,transitions:null}}function Ip(r,s,o){var l=s.pendingProps,d=it.current,h=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(h=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return au(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,h?(l=s.mode,h=s.child,y={mode:"hidden",children:y},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=y):h=ol(y,l,0,null),r=Is(r,l,o,null),h.return=s,r.return=s,h.sibling=r,s.child=h,s.child.memoizedState=Au(o),s.memoizedState=Tu,r):Eu(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Lx(r,s,y,l,S,d,o);if(h){h=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Xr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?h=Xr(S,h):(h=Is(h,y,o,null),h.flags|=2),h.return=s,l.return=s,l.sibling=h,s.child=l,l=h,h=s.child,y=r.child.memoizedState,y=y===null?Au(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},h.memoizedState=y,h.childLanes=r.childLanes&~o,s.memoizedState=Tu,l}return h=r.child,r=h.sibling,l=Xr(h,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Eu(r,s){return s=ol({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Ya(r,s,o,l){return l!==null&&lu(l),Xs(s,r.child,null,o),r=Eu(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Lx(r,s,o,l,d,h,y){if(o)return s.flags&256?(s.flags&=-257,l=Du(Error(t(422))),Ya(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(h=l.fallback,d=s.mode,l=ol({mode:"visible",children:l.children},d,0,null),h=Is(h,d,y,null),h.flags|=2,l.return=s,h.return=s,l.sibling=h,s.child=l,(s.mode&1)!==0&&Xs(s,r.child,null,y),s.child.memoizedState=Au(y),s.memoizedState=Tu,h);if((s.mode&1)===0)return Ya(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,h=Error(t(419)),l=Du(h,l,void 0),Ya(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,dr(r,d),Mn(l,r,d,-1))}return qu(),l=Du(Error(t(421))),Ya(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=qx.bind(null,r),d._reactRetry=s,null):(r=h.treeContext,qt=zr(d.nextSibling),Jt=s,rt=!0,Nn=null,r!==null&&(on[an++]=cr,on[an++]=ur,on[an++]=vs,cr=r.id,ur=r.overflow,vs=s),s=Eu(s,l.children),s.flags|=4096,s)}function Mp(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),fu(r.return,s,o)}function Bu(r,s,o,l,d){var h=r.memoizedState;h===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(h.isBackwards=s,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=o,h.tailMode=d)}function Dp(r,s,o){var l=s.pendingProps,d=l.revealOrder,h=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Mp(r,o,s);else if(r.tag===19)Mp(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Pa(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Bu(s,!1,d,o,h);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Pa(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Bu(s,!0,o,null,h);break;case"together":Bu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Qa(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function hr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),_s|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Xr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Xr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function Ux(r,s,o){switch(s.tag){case 3:jp(s),Zs();break;case 5:Vh(s);break;case 1:Lt(s.type)&&Ca(s);break;case 4:mu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ba,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?Ip(r,s,o):(qe(it,it.current&1),r=hr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Dp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,Sp(r,s,o)}return hr(r,s,o)}var Cp,Ru,Fp,Op;Cp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ru=function(){},Fp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,ws(Vn.current);var h=null;switch(o){case"input":d=or(r,d),l=or(r,l),h=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),h=[];break;case"textarea":d=Ui(r,d),l=Ui(r,l),h=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Ia)}fe(o,l);var y;o=null;for(P in d)if(!l.hasOwnProperty(P)&&d.hasOwnProperty(P)&&d[P]!=null)if(P==="style"){var S=d[P];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else P!=="dangerouslySetInnerHTML"&&P!=="children"&&P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&P!=="autoFocus"&&(a.hasOwnProperty(P)?h||(h=[]):(h=h||[]).push(P,null));for(P in l){var j=l[P];if(S=d!=null?d[P]:void 0,l.hasOwnProperty(P)&&j!==S&&(j!=null||S!=null))if(P==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(h||(h=[]),h.push(P,o)),o=j;else P==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(h=h||[]).push(P,j)):P==="children"?typeof j!="string"&&typeof j!="number"||(h=h||[]).push(P,""+j):P!=="suppressContentEditableWarning"&&P!=="suppressHydrationWarning"&&(a.hasOwnProperty(P)?(j!=null&&P==="onScroll"&&Xe("scroll",r),h||S===j||(h=[])):(h=h||[]).push(P,j))}o&&(h=h||[]).push("style",o);var P=h;(s.updateQueue=P)&&(s.flags|=4)}},Op=function(r,s,o,l){o!==l&&(s.flags|=4)};function No(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function Mt(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function Px(r,s,o){var l=s.pendingProps;switch(iu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mt(s),null;case 1:return Lt(s.type)&&Da(),Mt(s),null;case 3:return l=s.stateNode,ni(),et(Rt),et(kt),vu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Aa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Nn!==null&&(Qu(Nn),Nn=null))),Ru(r,s),Mt(s),null;case 5:yu(s);var d=ws(xo.current);if(o=s.type,r!==null&&s.stateNode!=null)Fp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return Mt(s),null}if(r=ws(Vn.current),Aa(s)){l=s.stateNode,o=s.type;var h=s.memoizedProps;switch(l[zn]=s,l[po]=h,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function $x(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,zx=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Vx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,I=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[jx],delete s[kx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ep(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ep(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new zx),s.forEach(function(l){var d=Zx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Hx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function Zx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ux(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=eb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ba,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Xx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Xx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function eb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function tb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new tb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function nb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=mb(),ad.exports}var hm;function gb(){if(hm)return hl;hm=1;var n=yb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var vb=gb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function xb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function bb(n,e={}){return _y(n,{...e,compact:!0})}function wb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return xb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return bb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function Sb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function _b(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function Nb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function jb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function kb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of kb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Ib(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Mb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Db(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Cb=new TextDecoder("utf-8"),Md=n=>Cb.decode(n),Fb=new TextEncoder,Wd=n=>Fb.encode(n),Ob=n=>typeof n=="number",Tb=n=>typeof n=="boolean",At=n=>typeof n=="function",Bn=n=>n!=null&&Object(n)===n,Go=n=>Bn(n)&&At(n.then),mc=n=>Bn(n)&&At(n[Symbol.iterator]),Hd=n=>Bn(n)&&At(n[Symbol.asyncIterator]),Dd=n=>Bn(n)&&Bn(n.schema),Dy=n=>Bn(n)&&"done"in n&&"value"in n,Cy=n=>Bn(n)&&At(n.stat)&&Ob(n.fd),Fy=n=>Bn(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>Bn(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>Bn(n)&&At(n.read)&&At(n.pipe)&&Tb(n.readable)&&!Oy(n),Ab=n=>Bn(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Rb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Lb=n=>Ay(Uint8Array,n);function Ub(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Pb(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Rb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Wb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Hb=void 0;function Yo(n){if(n===null)return"null";if(n===Hb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Gb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Gb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Kb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Yb=BigInt(4294967296)*BigInt(4294967296),Qb=Yb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Et extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Et[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Et.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Jb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Jb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function qb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Zb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Xb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=Zb(t)},tw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Xb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},nw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),rw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},ow=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},aw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),hw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?dw(e,t):t instanceof Je?uw(e,t):Array.isArray(t)?cw(e,t):fw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},pw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},mw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},yw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},gw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},vw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xw(this[On],this[_i])}}class xw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const ww=(n,e)=>864e5*n[e],Sw=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},_w=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<ww(n,e),Bg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],Nw=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],jw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},kw=({values:n},e)=>n[e],Iw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Mw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Bg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Fw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Ow=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Tw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Aw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Rw=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Lw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Uw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(Sw);xe.prototype.visitBool=je(_w);xe.prototype.visitInt=je(kw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(Iw);xe.prototype.visitFloat16=je(Nw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(jw);xe.prototype.visitDate=je(Mw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Bg);xe.prototype.visitTimestamp=je(Dw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Cw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Fw);xe.prototype.visitList=je(Ow);xe.prototype.visitStruct=je(Aw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Rw);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Lw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Uw);xe.prototype.visitMap=je(Tw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new $w)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Pw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Pw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class $w{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Ei(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Ub(n,t):!1:n instanceof Map?Vw(n):Array.isArray(n)?zw(n):n instanceof Je?Ww(n):Hw(n,!0)}function zw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Gw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Yw(n,t):!1}}function Gw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ed(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Ed(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Kw(n,a>>3,i-a>>3)}function Kw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Jw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Jw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const qw=new Vo;function Be(n){return qw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function e1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return e1(n,t)}const i=Qt.getVisitFn(n),a=Ei(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new t1(f)})}class t1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Zw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var n1=By,r1=Ii;class rf{static decode(e){e=new r1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new s1(i,t)}static encode(e){const t=new n1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class o1 extends i1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new a1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof o1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class a1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class c1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ed(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?u1(i[t]):me.isBool(e)?Ed(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function u1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function d1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function f1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function m1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function y1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=d1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=f1;Se.prototype.visitStruct=h1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=p1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=m1;Se.prototype.visitMap=y1;const cs=new Se;function g1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return v1(n,e.map(t=>t.data.concat()))}function v1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Be({type:new Et(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function x1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Be({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Et)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!g1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Ee({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ee({nullCount:0,type:new Bt(this.schema.fields),children:this.schema.fields.map(t=>Ee({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Ee({type:new Bt(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Ee({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Ee({type:new Bt(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Ee({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Ee({type:new Bt(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cEe({type:a.type})),i=Ee({type:new Bt(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class x1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new x1;function b1(n,e=new Map){return new We(S1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function w1(n){return new kr(bv(n.data),n.id,n.isDelta)}function S1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Bm(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Ei(t.count,_1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function N1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Bm(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Em(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Em(i):new Jo,e.set(t,f=Rm(n,Bm(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Em(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Bt(e||[]);case"struct_":return new Bt(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var j1=Ey,k1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=I1(e,t),i}static decode(e){e=new k1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=M1(t,c),f}static encode(e){const t=new j1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ei{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function I1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=U1;nt.decode=R1;nt.fromJSON=N1;We.encode=L1;We.decode=D1;We.fromJSON=b1;Rn.encode=P1;Rn.decode=C1;Rn.fromJSON=bv;kr.encode=$1;kr.decode=F1;kr.fromJSON=w1;Ei.encode=z1;Ei.decode=T1;_r.encode=V1;_r.decode=O1;function D1(n,e=new Map,t=ht.V5){const i=E1(n,e);return new We(i,Tl(n),e,t)}function C1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),A1(n),B1(n,e))}function F1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function O1(n){return new _r(n.offset(),n.length())}function T1(n){return new Ei(n.length(),n.nullCount())}function A1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,W1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function U1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function P1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ei.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function $1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function z1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function V1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const W1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?q1(e):Cy(e)?eS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?X1(new Fi(e)):Z1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class Q1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Ee({type:new Bt(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new G1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new H1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function X1(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function eS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Y1&&df(yield t.readAt(0,na+7&-8))?new Q1(new K1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function tS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function nS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const sS="application/vnd.apache.arrow.stream";class iS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function oS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class aS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new iS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return oS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=kb(await t.json());try{return Mb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Ib(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?rS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:sS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=nS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=I.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=I.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=I.useId(),w=I.useRef(null),_=I.useRef(null),C=f&&v;return I.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),I.useEffect(()=>{p&&!m&&x(!0)},[p,m]),I.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var E,F;return(F=(E=w.current)==null?void 0:E.querySelector("button"))==null?void 0:F.focus()});function U(E){var L;if(E.key==="Escape"){E.preventDefault(),x(!1);return}if(E.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];E.shiftKey&&document.activeElement===A?(E.preventDefault(),M.focus()):!E.shiftKey&&document.activeElement===M&&(E.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-x-auto border-b border-line bg-surface px-3 py-2 md:h-9 md:flex-nowrap md:py-0",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function lS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const cS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function uS(n,e){const t=n.split("__").at(-1);return t&&cS.has(t)?t:e}function dS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function fS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",E=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:E,selectedMetric:C,grain:$?uS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:fS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??dS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function hS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function pS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function mS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=pS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function yS(n){return{from:Vm(n.from),to:Vm(n.to)}}function gS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function vS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function xS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function bS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${bS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function wS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Bv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=wS(a,c,f,e.dialect);p&&t.push(p)}return t}function Bs(n,e={}){const t=Bv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...vS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const SS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:SS[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function _S(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function NS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function jS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function kS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function IS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=kS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function MS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Ev(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??MS(n),c=(i==null?void 0:i.selectedMetric)??Ev(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function DS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const CS=["home","explore","pivot"],FS=new Set(Pd),OS=new Set(["none","pctTotal","delta","deltaPct"]),TS=new Set(["off","previous","year","custom"]),AS="none",BS="previous",ES="UTC";function RS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const LS=new Set(["include","exclude","contains"]);function US(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!LS.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function PS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=US(i);a&&(e[t]=a)}return e}function $S(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function zS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==ES&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==AS&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify($S(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function VS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&CS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&FS.has(m)&&(i.grain=m);const g=t.get("tz");RS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&OS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&TS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=PS(bl(t.get("filters")));U&&(i.filters=U);const E=bl(t.get("jdims"));Wo(E)&&(i.joinedDims=[...new Set(E)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=I.createContext(null);function Qm(n){const e=zS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=VS(n,i),c=Ts(e,t,a.dashboardTab);return c?DS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function WS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=I.useMemo(()=>Rv(n,t),[n,t]),[p,m]=I.useReducer(IS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=I.useRef(i);I.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=I.useRef(a);v.current=a,I.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=I.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=I.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function HS(){Cs.active+=1,Uv()}function GS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return I.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const YS=80;function Bn(n,e){const[t,i]=I.useState({loading:!1}),a=I.useRef(0),c=e?JSON.stringify(e):null;return I.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{HS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>GS())},YS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}const QS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],KS=50,qm=200;function Zm(n,e){const[t,i]=I.useState(n);return I.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function $v({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=I.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=I.useState((g==null?void 0:g.mode)??"include"),b=I.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=I.useRef(null),_=I.useRef(null),C=I.useId(),[T,$]=I.useState(""),U=Zm(T,qm),E=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=I.useState(E),M=Zm(F,qm);I.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),I.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),I.useEffect(()=>{v==="contains"&&M!==E&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=I.useMemo(()=>xc(f),[f]),Q=I.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Bs(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=Bn(c,V?_S(n.ref,Q,KS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=I.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(E)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:QS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 truncate text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function JS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(g=>g.type!=="time"),[i,a]=I.useState(!1),[c,f]=I.useState(null),p=I.useRef(null);I.useEffect(()=>{if(!i)return;function g(x){x.key==="Escape"&&m()}function v(x){c||p.current&&!p.current.contains(x.target)&&m()}return document.addEventListener("keydown",g,!0),document.addEventListener("mousedown",v,!0),()=>{document.removeEventListener("keydown",g,!0),document.removeEventListener("mousedown",v,!0)}},[i,c]);function m(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?m():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 z-50 mt-1 max-h-64 w-48 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(g=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(g),className:"block w-full truncate px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:g.label},g.ref))}):null,i&&c?u.jsx($v,{dim:c,model:n,onClose:m}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function qS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class ZS extends I.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const XS=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function zv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=I.useRef(null),[p,m]=I.useState((n==null?void 0:n.from)??""),[g,v]=I.useState((n==null?void 0:n.to)??""),[x,b]=I.useState((a==null?void 0:a.from)??""),[w,_]=I.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",E=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${E?"opacity-50":""}`,children:XS.map(F=>u.jsx("button",{type:"button",disabled:E,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!E?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=I.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",Nb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx($v,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const e_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function t_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function n_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function r_({timezone:n,disabled:e,onChange:t}){const i=I.useId(),[a,c]=I.useState(!1),[f,p]=I.useState(""),m=I.useMemo(()=>{const b=new Set(e_);return n&&b.add(n),[...b]},[n]),g=I.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();t_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=n_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function s_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const i_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=I.useState(0),[w,_]=I.useState(""),C=I.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:E,visibleRows:F}=bb(C,x,p);I.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},E+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=s_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:i_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[E+1,"–",Math.min(E+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function o_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function a_(){var U,E;const[n,e]=I.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=I.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=o_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((E=f==null?void 0:f.timeDimension)==null?void 0:E.ref),x=I.useMemo(()=>xc(i),[i]),b=I.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Bs(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?jS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Vv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Vv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Wv(n){document.documentElement.dataset.theme=n}function l_(){Wv(yf())}function c_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Vv,n),Wv(n),n}function Zo(){const[n,e]=I.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(c_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Hv({view:n,onChange:e}){const t=I.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Gv="dashboard_filters",Yv="dashboard_ranges",Qv="dashboard_filter_sources",Kv="dashboard_range_sources",Jv="dashboard_chart_filters",qv="dashboard_chart_ranges";function u_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function d_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function f_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function h_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=h_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function p_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function m_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function y_(n,e,t){return[e,...t].some(i=>gf(n,i))}const g_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return g_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Zv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function Xv(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function e0(n,e,t){const i=Fs(n);if(i){const a=Xv(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function v_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[e0(n,{from:e,to:e},i)]:Bv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function x_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Zv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([E,F])=>v_(E,F,i,f)),...Object.entries(p.ranges).map(([E,F])=>e0(E,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=Xv(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function b_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,E=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return E&&(w.set("from",E.from),w.set("to",E.to)),`/explore?${w}`}function w_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function S_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function t0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function s0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function __(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Gv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Yv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Qv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Kv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Jv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(qv)??"{}")}catch{x={}}const b=r0(e),w=s0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:t0(v,w),chartRanges:n0(x,w)}}function N_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Gv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Yv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Qv,JSON.stringify(i)),Object.keys(a).length&&t.set(Kv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Jv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(qv,JSON.stringify(n.chartRanges)),t.toString()}function i0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function j_(n){try{const e=JSON.parse(localStorage.getItem(i0(n))??"[]");if(!Array.isArray(e))return[];const t=r0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=s0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:t0(c.chartFilters,p),chartRanges:n0(c.chartRanges,p)}}]})}catch{return[]}}function k_(n,e){try{return localStorage.setItem(i0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function I_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r -`)}function M_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function D_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Ev(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const C_="600px";function F_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function O_(n,e,t=C_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:F_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const T_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function o0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,E=m!=="none",F=E?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),E?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${T_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const A_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],E_=[];function R_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=E_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=I.useRef(null),[U,E]=I.useState(!1);I.useEffect(()=>{if(!(U||!$.current))return O_($.current,()=>E(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=I.useMemo(()=>xc(T),[T]),M=I.useMemo(()=>[...p,...Bs(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=Bn(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=I.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=I.useMemo(()=>ae&&f&&F&&ie?[...p,...Bs(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=Bn(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=I.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:wb(he,c);case"delta":return Sb(he,H.get(te),N);case"deltaPct":return _b(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(o0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:A_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=I.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function a0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=I.useRef(null),m=I.useId(),g=I.useRef(null),v=I.useRef(null),[x,b]=I.useState(200),[w,_]=I.useState(null),[C,T]=I.useState(null),[$,U]=I.useState(null);I.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const E=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(E.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...E.map(H=>H.value)),L=Math.max(...E.map(H=>H.value))-A||1,Y=E.map((H,N)=>({...H,x:F+N/(E.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${E.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const L_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},U_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=I.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${L_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:U_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(a0,{values:p,labels:m,onHover:E=>{C(E),b==null||b(E)},onBrush:w,formatValue:E=>pt(E,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=I.useRef(null),x=I.useRef(null),b=I.useRef(!1),w=I.useRef(null),[_,C]=I.useState(820),[T,$]=I.useState(null),[U,E]=I.useState(null);I.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},E({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},E({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,E(null)}function W(){$(null),b.current=!1,w.current=null,E(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const P_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function $_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${P_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const z_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function V_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} +]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Be({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Be({nullCount:0,type:new Et(this.schema.fields),children:this.schema.fields.map(t=>Be({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Be({type:new Et(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Be({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Be({type:new Et(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Be({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Be({type:new Et(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cBe({type:a.type})),i=Be({type:new Et(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class b1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new b1;function w1(n,e=new Map){return new We(_1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function S1(n){return new kr(bv(n.data),n.id,n.isDelta)}function _1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Em(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Bi(t.count,N1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function j1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Em(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Bm(i):new Jo,e.set(t,f=Rm(n,Em(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Et(e||[]);case"struct_":return new Et(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var k1=By,I1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=M1(e,t),i}static decode(e){e=new I1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=D1(t,c),f}static encode(e){const t=new k1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Bi{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=P1;nt.decode=L1;nt.fromJSON=j1;We.encode=U1;We.decode=C1;We.fromJSON=w1;Rn.encode=$1;Rn.decode=F1;Rn.fromJSON=bv;kr.encode=z1;kr.decode=O1;kr.fromJSON=S1;Bi.encode=V1;Bi.decode=A1;_r.encode=W1;_r.decode=T1;function C1(n,e=new Map,t=ht.V5){const i=R1(n,e);return new We(i,Tl(n),e,t)}function F1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),B1(n,e))}function O1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function T1(n){return new _r(n.offset(),n.length())}function A1(n){return new Bi(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,H1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function P1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function $1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Bi.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function z1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function V1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function W1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const H1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?Z1(e):Cy(e)?tS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?eS(new Fi(e)):X1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class K1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Be({type:new Et(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new Y1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new G1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function eS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function tS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Q1&&df(yield t.readAt(0,na+7&-8))?new K1(new J1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function nS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function rS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const iS="application/vnd.apache.arrow.stream";class oS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function aS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class lS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new oS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return aS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Ib(await t.json());try{return Db(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Mb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?sS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:iS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=rS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var B,F;return(F=(B=w.current)==null?void 0:B.querySelector("button"))==null?void 0:F.focus()});function U(B){var L;if(B.key==="Escape"){B.preventDefault(),x(!1);return}if(B.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];B.shiftKey&&document.activeElement===A?(B.preventDefault(),M.focus()):!B.shiftKey&&document.activeElement===M&&(B.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"relative z-30 flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function cS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const uS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function dS(n,e){const t=n.split("__").at(-1);return t&&uS.has(t)?t:e}function fS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function hS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",B=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:B,selectedMetric:C,grain:$?dS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:hS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??fS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function pS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function mS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function yS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=mS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function gS(n){return{from:Vm(n.from),to:Vm(n.to)}}function vS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function xS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function bS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function wS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${wS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function SS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Ev(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=SS(a,c,f,e.dialect);p&&t.push(p)}return t}function Es(n,e={}){const t=Ev(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...xS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const _S={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:_S[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function NS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function jS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function kS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function IS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function MS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=IS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function DS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Bv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??DS(n),c=(i==null?void 0:i.selectedMetric)??Bv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function CS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const FS=["home","explore","pivot"],OS=new Set(Pd),TS=new Set(["none","pctTotal","delta","deltaPct"]),AS=new Set(["off","previous","year","custom"]),ES="none",BS="previous",RS="UTC";function LS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const US=new Set(["include","exclude","contains"]);function PS(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!US.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function $S(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=PS(i);a&&(e[t]=a)}return e}function zS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function VS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==RS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(zS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function WS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&FS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&OS.has(m)&&(i.grain=m);const g=t.get("tz");LS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&TS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&AS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=$S(bl(t.get("filters")));U&&(i.filters=U);const B=bl(t.get("jdims"));Wo(B)&&(i.joinedDims=[...new Set(B)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=k.createContext(null);function Qm(n){const e=VS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=WS(n,i),c=Ts(e,t,a.dashboardTab);return c?CS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function HS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Rv(n,t),[n,t]),[p,m]=k.useReducer(MS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function GS(){Cs.active+=1,Uv()}function YS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const QS=80;function En(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{GS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>YS())},QS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function $v(n,e=!0){k.useLayoutEffect(()=>{const t=n.current,i=t==null?void 0:t.parentElement;if(!e||!t||!i)return;function a(){if(!t||!i)return;const f=i.getBoundingClientRect(),p=8,m=Math.max(p,Math.min(f.left,window.innerWidth-t.offsetWidth-p));t.style.left=`${m-f.left}px`,t.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-f.bottom-p-4)}px`)}a();const c=new ResizeObserver(a);return c.observe(t),c.observe(i),i.parentElement&&c.observe(i.parentElement),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{c.disconnect(),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}})}const KS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],JS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function zv({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=k.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=k.useState((g==null?void 0:g.mode)??"include"),b=k.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=k.useRef(null);$v(w);const _=k.useRef(null),C=k.useId(),[T,$]=k.useState(""),U=Zm(T,qm),B=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=k.useState(B),M=Zm(F,qm);k.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),k.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),k.useEffect(()=>{v==="contains"&&M!==B&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=k.useMemo(()=>xc(f),[f]),Q=k.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Es(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=En(c,V?NS(n.ref,Q,JS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=k.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(B)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:KS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function qS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(v=>v.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null);$v(m,i&&!c),k.useEffect(()=>{if(!i)return;function v(b){b.key==="Escape"&&g()}function x(b){c||p.current&&!p.current.contains(b.target)&&g()}return document.addEventListener("keydown",v,!0),document.addEventListener("mousedown",x,!0),()=>{document.removeEventListener("keydown",v,!0),document.removeEventListener("mousedown",x,!0)}},[i,c]);function g(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?g():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 top-full z-50 mt-1 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(v=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(v),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:v.label},v.ref))}):null,i&&c?u.jsx(zv,{dim:c,model:n,onClose:g}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function ZS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class XS extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const e_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Vv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",B=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${B?"opacity-50":""}`,children:e_.map(F=>u.jsx("button",{type:"button",disabled:B,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!B?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",jb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(zv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const t_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function n_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function r_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function s_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(t_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();n_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=r_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function i_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const o_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:B,visibleRows:F}=wb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},B+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=i_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:o_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[B+1,"–",Math.min(B+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function a_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function l_(){var U,B;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=a_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((B=f==null?void 0:f.timeDimension)==null?void 0:B.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Es(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?kS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=En(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Wv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Wv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Hv(n){document.documentElement.dataset.theme=n}function c_(){Hv(yf())}function u_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Wv,n),Hv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(u_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Gv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Yv="dashboard_filters",Qv="dashboard_ranges",Kv="dashboard_filter_sources",Jv="dashboard_range_sources",qv="dashboard_chart_filters",Zv="dashboard_chart_ranges";function d_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function f_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function h_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function p_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=p_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function m_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function y_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function g_(n,e,t){return[e,...t].some(i=>gf(n,i))}const v_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return v_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Xv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function e0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function t0(n,e,t){const i=Fs(n);if(i){const a=e0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function x_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[t0(n,{from:e,to:e},i)]:Ev({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function b_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Xv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([B,F])=>x_(B,F,i,f)),...Object.entries(p.ranges).map(([B,F])=>t0(B,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=e0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function w_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,B=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return B&&(w.set("from",B.from),w.set("to",B.to)),`/explore?${w}`}function S_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function __(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function s0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function i0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function N_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Yv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Qv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Kv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Jv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Zv)??"{}")}catch{x={}}const b=s0(e),w=i0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:n0(v,w),chartRanges:r0(x,w)}}function j_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Yv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Qv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Kv,JSON.stringify(i)),Object.keys(a).length&&t.set(Jv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Zv,JSON.stringify(n.chartRanges)),t.toString()}function o0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function k_(n){try{const e=JSON.parse(localStorage.getItem(o0(n))??"[]");if(!Array.isArray(e))return[];const t=s0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=i0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:n0(c.chartFilters,p),chartRanges:r0(c.chartRanges,p)}}]})}catch{return[]}}function I_(n,e){try{return localStorage.setItem(o0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function M_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r +`)}function D_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function C_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Bv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const F_="600px";function O_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function T_(n,e,t=F_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:O_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const A_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function a0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,B=m!=="none",F=B?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),B?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${A_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],R_=[];function L_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=R_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=k.useRef(null),[U,B]=k.useState(!1);k.useEffect(()=>{if(!(U||!$.current))return T_($.current,()=>B(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Es(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=En(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=k.useMemo(()=>ae&&f&&F&&ie?[...p,...Es(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=En(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=k.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:Sb(he,c);case"delta":return _b(he,H.get(te),N);case"deltaPct":return Nb(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(a0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:E_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function l0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[$,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const B=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(B.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...B.map(H=>H.value)),L=Math.max(...B.map(H=>H.value))-A||1,Y=B.map((H,N)=>({...H,x:F+N/(B.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${B.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const U_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},P_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${U_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:P_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(l0,{values:p,labels:m,onHover:B=>{C(B),b==null||b(B)},onBrush:w,formatValue:B=>pt(B,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,$]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},B({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},B({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,B(null)}function W(){$(null),b.current=!1,w.current=null,B(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const $_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function z_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${$_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const V_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function W_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} ${c}`).join(` -`),i=V_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function W_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const H_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!H_.has(n.type)}function G_(n,e){return!!(n&&n===e)}function Y_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function Q_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:xS(n.to,e)}}function K_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=I.useState(null),p=t.models.find(fe=>fe.name===n.model),m=I.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);I.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=I.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=I.useMemo(()=>xc(t),[t]),E=I.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=I.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?yS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:mS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=I.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=Bn(i,!C&&$.length?L(vd($,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=Bn(i,!C&&$.length&&w?L(Gm($,w,n.grain,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=Bn(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=Bn(i,C?L(vd([C.ref],E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=Bn(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Y_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=G_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:Q_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Br=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,W_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Br,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx($_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>gS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(R_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function J_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=I.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=I.useState(null),T=I.useMemo(()=>pf(a),[a]),$=I.useMemo(()=>Bs(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),E=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?NS(w,v,$,E,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=Bn(t,A),z=[...v,...w],Q=I.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=I.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function q_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function l0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=I.useRef(null),[f,p]=I.useState(640),{tip:m,handlers:g}=Cr();I.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),E=Math.max(8,Math.min(48,U*.62)),F=q_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-E)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:E,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+E/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Es(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function c0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=I.useRef(null),[m,g]=I.useState(640),{tip:v,handlers:x}=Cr();I.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),E=Math.max(...C),F=$-T||1,A=E-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Es(U,E,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Es(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function Z_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function X_(n){return pf(n.models.flatMap(e=>e.dimensions))}function e2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function t2({chart:n,columns:e,rows:t}){const i=I_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function n2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=d_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function r2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=I.useState(!1),g=I.useMemo(()=>X_(t),[t]),v=I.useMemo(()=>x_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=Bn(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=p_(e),$=T[0]??e2(e),U=br(C,w),E=vf(n,e,a),F=Zv(e,g),A=f_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=y_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(c0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=S_(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=w_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(l0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:E.filters[C],onSelect:Y?he=>{c(m_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:b_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(t2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(n2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function s2({document:n,state:e,onLoad:t}){const[i,a]=I.useState(""),[c,f]=I.useState(()=>j_(n)),[p,m]=I.useState(!1);function g(v){f(v),m(!k_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function i2(){const[n,e]=I.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function o2({document:n,catalog:e,backend:t}){const[i,a]=I.useState(()=>__(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];I.useEffect(()=>{window.document.title=n.title},[n.title]),I.useEffect(()=>{const b=N_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const E={...U.chartRanges??{}},F={...E[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?E[C]=F:delete E[C],{...U,chartRanges:E}});return}a(U=>{const E={...U.ranges},F={...U.rangeSources};return _?(E[w]=_,F[w]=C):(delete E[w],delete F[w]),{...U,ranges:E,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(s2,{document:n,state:i,onLoad:a}),u.jsx(i2,{}),u.jsx(Zo,{}),u.jsx(Z_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:M_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(r2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function a2(){const[n,e]=I.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function l2({backend:n,onAuthenticated:e}){const[t,i]=I.useState(""),[a,c]=I.useState(null),[f,p]=I.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function c2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(E=>E.name===n.model),m=I.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=I.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=hS(x==null?void 0:x.supportedGranularities,n.grain),_=I.useMemo(()=>{const E=new Map;for(const F of t.models)for(const A of F.dimensions)E.set(A.ref,{dim:A,model:F});return E},[t]),C=Object.entries(n.filters).flatMap(([E,F])=>{const A=_.get(E);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:E})},E)]:[]}),T=u.jsx(lS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(E=>{const F=E.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,E.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:E.label??E.id},E.id)})}):u.jsx(Hv,{view:n.view,onChange:E=>e({type:"setView",view:E})}),u.jsx(zv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(E,F)=>e({type:"setDateRange",range:E,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(E,F)=>e({type:"setComparison",comparison:E,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:E=>e({type:"setGrain",grain:E})}),u.jsx(r_,{timezone:n.timezone,disabled:!b,onChange:E=>e({type:"setTimezone",timezone:E})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(a2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(JS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(qS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(a_,{}),children:u.jsxs(ZS,{children:[n.view==="home"?u.jsx(D_,{}):null,n.view==="explore"?u.jsx(K_,{}):null,n.view==="pivot"?u.jsx(J_,{}):null]},n.view)})}function u2(){const[n,e]=I.useState(!1),t=I.useMemo(()=>new aS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=I.useState(null),[c,f]=I.useState(null),[p,m]=I.useState(0),g=u_(window.location.pathname,window.location.search);return I.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(l2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(o2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(WS,{catalog:i.catalog,backend:t,children:u.jsx(c2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function d2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=I.useRef(null),[m,g]=I.useState(640),{tip:v,handlers:x}=Cr();if(I.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),E=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/E)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Es(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Es($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const f2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${f2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function h2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=I.useId(),p=I.useRef(null),[m,g]=I.useState(!1),[v,x]=I.useState(""),[b,w]=I.useState(0),_=I.useMemo(()=>h2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};I.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function E(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:E,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function p2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const m2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function u0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function y2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:u0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return u0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=I.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=I.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=I.useState(null),b=I.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:m2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:y2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const E=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:E}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function g2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function v2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const d0=Math.PI*2;function x2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*d0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function b2(n,e,t,i,a,c){const f=Math.min(c-a,d0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function w2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=I.useRef(null),[f,p]=I.useState(360),{tip:m,handlers:g}=Cr();I.useEffect(()=>fs(c.current,220,p),[]);const v=x2(n),x=v.reduce((U,E)=>U+E.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:b2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function S2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=I.useRef(null),[p,m]=I.useState(640),{tip:g,handlers:v}=Cr();I.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,E=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*E+E/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*E+.5,width:Math.max(1,U-1),height:Math.max(1,E-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function _2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function N2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=I.useRef(null),[f,p]=I.useState(640),{tip:m,handlers:g}=Cr();I.useEffect(()=>fs(c.current,160,p),[]);const v=_2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(E=>E.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=E=>Fn.top+(1-E/x)*w,C=b/v.length,T=Es(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((E,F)=>{const A=_(E);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(E)})]},F)}),v.map((E,F)=>{const A=Fn.left+C*F,M=_(E.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":E.x0,"data-x1":E.x1,"data-count":E.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(E.x0)} – ${i(E.x1)}`,rows:[{label:"Count",value:E.count.toLocaleString()}]}))},F)}),v.map((E,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(E.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function j2(n){let e=2166136261;for(let t=0;t>>0}function k2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function I2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=k2(j2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function M2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=I.useRef(null),[c,f]=I.useState(640),{tip:p,handlers:m}=Cr();I.useEffect(()=>fs(a.current,240,f),[]);const g=I.useMemo(()=>I2(n,e,{width:c,height:t}),[n,e,c,t]),v=I.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=I.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function D2(n,e,t){return Math.min(Math.max(n,e),t)}function C2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=I.useRef(null),[p,m]=I.useState(640),[g,v]=I.useState(null);I.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,E=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${E(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${E(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Es(0,C,4).map((z,Q)=>{const V=E(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function F2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function O2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function T2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function A2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=I.useRef(null),[c,f]=I.useState(640),{tip:p,handlers:m}=Cr();I.useEffect(()=>fs(a.current,200,f),[]);const g=A2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),E=Es(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[E.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function E2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function R2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,E2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const L2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],U2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],P2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),$2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),z2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),V2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function W2(){const[n,e]=I.useState("orders.revenue"),[t,i]=I.useState({}),[a,c]=I.useState(null),[f,p]=I.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=I.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=I.useState("month"),[b,w]=I.useState("explore"),[_,C]=I.useState("previous"),[T,$]=I.useState("orders.revenue"),[U,E]=I.useState(["orders.revenue","orders.count"]),[F,A]=I.useState("apple"),[M,L]=I.useState(!0),[Y,z]=I.useState("explore"),[Q,V]=I.useState("2025-06-15"),[X,ne]=I.useState({from:"2025-06-01",to:"2025-06-21"}),ae=I.useMemo(()=>R2(P2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=I.useState({key:"revenue",dir:"desc"}),re=I.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:L2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(o0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(zv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Hv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(a0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(l0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(v2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(w2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(C2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(d2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(N2,{values:z2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(c0,{points:$2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(S2,{cells:V2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(M2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(F2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(O2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(T2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:E,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:U2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(g2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue +`),i=W_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function H_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const G_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!G_.has(n.type)}function Y_(n,e){return!!(n&&n===e)}function Q_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function K_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:bS(n.to,e)}}function J_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(fe=>fe.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=k.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),B=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?gS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:yS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=En(i,!C&&$.length?L(vd($,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=En(i,!C&&$.length&&w?L(Gm($,w,n.grain,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=En(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=En(i,C?L(vd([C.ref],B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=En(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Q_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Y_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:K_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Er=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,H_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Er,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(z_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>vS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(L_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function q_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),$=k.useMemo(()=>Es(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),B=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?jS(w,v,$,B,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=En(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function Z_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function c0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),B=Math.max(8,Math.min(48,U*.62)),F=Z_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-B)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:B,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+B/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Bs(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function u0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),B=Math.max(...C),F=$-T||1,A=B-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Bs(U,B,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Bs(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function X_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function e2(n){return pf(n.models.flatMap(e=>e.dimensions))}function t2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function n2({chart:n,columns:e,rows:t}){const i=M_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function r2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=f_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function s2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>e2(t),[t]),v=k.useMemo(()=>b_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=En(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=m_(e),$=T[0]??t2(e),U=br(C,w),B=vf(n,e,a),F=Xv(e,g),A=h_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=g_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(u0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=__(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=S_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(c0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:B.filters[C],onSelect:Y?he=>{c(y_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:w_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(n2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(r2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function i2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>k_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!I_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function o2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function a2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>N_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=j_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const B={...U.chartRanges??{}},F={...B[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?B[C]=F:delete B[C],{...U,chartRanges:B}});return}a(U=>{const B={...U.ranges},F={...U.rangeSources};return _?(B[w]=_,F[w]=C):(delete B[w],delete F[w]),{...U,ranges:B,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(i2,{document:n,state:i,onLoad:a}),u.jsx(o2,{}),u.jsx(Zo,{}),u.jsx(X_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:D_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(s2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function l2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function c2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function u2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(B=>B.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=pS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const B=new Map;for(const F of t.models)for(const A of F.dimensions)B.set(A.ref,{dim:A,model:F});return B},[t]),C=Object.entries(n.filters).flatMap(([B,F])=>{const A=_.get(B);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:B})},B)]:[]}),T=u.jsx(cS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(B=>{const F=B.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,B.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:B.label??B.id},B.id)})}):u.jsx(Gv,{view:n.view,onChange:B=>e({type:"setView",view:B})}),u.jsx(Vv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(B,F)=>e({type:"setDateRange",range:B,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(B,F)=>e({type:"setComparison",comparison:B,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:B=>e({type:"setGrain",grain:B})}),u.jsx(s_,{timezone:n.timezone,disabled:!b,onChange:B=>e({type:"setTimezone",timezone:B})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(l2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(qS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(ZS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(l_,{}),children:u.jsxs(XS,{children:[n.view==="home"?u.jsx(C_,{}):null,n.view==="explore"?u.jsx(J_,{}):null,n.view==="pivot"?u.jsx(q_,{}):null]},n.view)})}function d2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new lS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=d_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(c2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(a2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(HS,{catalog:i.catalog,backend:t,children:u.jsx(u2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function f2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),B=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/B)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Bs(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Bs($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const h2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${h2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function p2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>p2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};k.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function B(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:B,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function m2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const y2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function d0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function g2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:d0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return d0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:y2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:g2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const B=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:B}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function v2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function x2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const f0=Math.PI*2;function b2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*f0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function w2(n,e,t,i,a,c){const f=Math.min(c-a,f0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function S2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=b2(n),x=v.reduce((U,B)=>U+B.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:w2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function _2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,B=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*B+B/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*B+.5,width:Math.max(1,U-1),height:Math.max(1,B-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function N2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function j2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=N2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(B=>B.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=B=>Fn.top+(1-B/x)*w,C=b/v.length,T=Bs(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((B,F)=>{const A=_(B);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(B)})]},F)}),v.map((B,F)=>{const A=Fn.left+C*F,M=_(B.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":B.x0,"data-x1":B.x1,"data-count":B.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(B.x0)} – ${i(B.x1)}`,rows:[{label:"Count",value:B.count.toLocaleString()}]}))},F)}),v.map((B,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(B.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function k2(n){let e=2166136261;for(let t=0;t>>0}function I2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function M2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=I2(k2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function D2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>M2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function C2(n,e,t){return Math.min(Math.max(n,e),t)}function F2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,B=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${B(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${B(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Bs(0,C,4).map((z,Q)=>{const V=B(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function O2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function T2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function A2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),B=Bs(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[B.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function R2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function L2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,R2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const U2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],P2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],$2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),z2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),V2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),W2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function H2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,$]=k.useState("orders.revenue"),[U,B]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,L]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,V]=k.useState("2025-06-15"),[X,ne]=k.useState({from:"2025-06-01",to:"2025-06-21"}),ae=k.useMemo(()=>L2($2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:U2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(a0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Vv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Gv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(l0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(c0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(x2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(S2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(F2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(f2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(j2,{values:V2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(u0,{points:z2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(_2,{cells:W2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(D2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(O2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(T2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(A2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:B,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:P2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(v2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue FROM orders WHERE orders.status = 'completed' GROUP BY orders.region -ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(p2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],H2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const G2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Y2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],Q2=[31,42,38,55,60,74],K2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),J2=`select region, sum(revenue) as revenue +ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(m2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],G2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Y2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Q2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],K2=[31,42,38,55,60,74],J2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),q2=`select region, sum(revenue) as revenue from orders where created_at >= date '2025-01-01' group by all -order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function q2(){const[n,e]=I.useState("geist"),[t,i]=I.useState("geistmono"),[a,c]=I.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;I.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:H2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:Q2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:K2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:J2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:G2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Y2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}l_();const f0=document.getElementById("root");if(!f0)throw new Error("Missing #root element");gb.createRoot(f0).render(u.jsx(I.StrictMode,{children:window.location.pathname==="/components"?u.jsx(W2,{}):window.location.pathname==="/typography"?u.jsx(q2,{}):u.jsx(u2,{})})); +order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function Z2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:G2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:K2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:J2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:q2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Y2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Q2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}c_();const h0=document.getElementById("root");if(!h0)throw new Error("Missing #root element");vb.createRoot(h0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(H2,{}):window.location.pathname==="/typography"?u.jsx(Z2,{}):u.jsx(d2,{})})); diff --git a/sidemantic/ui/static/index.html b/sidemantic/ui/static/index.html index 53d08f6cd..55587f6f8 100644 --- a/sidemantic/ui/static/index.html +++ b/sidemantic/ui/static/index.html @@ -4,8 +4,8 @@ Sidemantic - - + +
diff --git a/sidemantic/widget/static/widget.css b/sidemantic/widget/static/widget.css index 5ecb4d020..5e531d134 100644 --- a/sidemantic/widget/static/widget.css +++ b/sidemantic/widget/static/widget.css @@ -1,5 +1,5 @@ /* Generated from the canonical UI distribution and js/widget.css. */ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-48{width:12rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:h-9{height:2.25rem}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:py-0{padding-top:0;padding-bottom:0}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} /* AnyWidget host layout layered on top of the canonical UI distribution. */ /* Ported from the sidemantic-demo */ diff --git a/sidemantic/widget/static/widget.js b/sidemantic/widget/static/widget.js index af4ec27c7..493e6cfba 100644 --- a/sidemantic/widget/static/widget.js +++ b/sidemantic/widget/static/widget.js @@ -1,20 +1,20 @@ -var _w=Object.defineProperty;var fi=(t,e)=>{for(var n in e)_w(t,n,{get:e[n],enumerable:!0})};function Yp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(t){return this instanceof Z?(this.v=t,this):new Z(t)}function Tt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(w){return Promise.resolve(w).then(v,d)}}function a(v,w){r[v]&&(i[v]=function(I){return new Promise(function(Y,h){s.push([v,I,Y,h])>1||l(v,I)})},w&&(i[v]=w(i[v])))}function l(v,w){try{u(r[v](w))}catch(I){y(s[0][3],I)}}function u(v){v.value instanceof Z?Promise.resolve(v.value.v).then(c,d):y(s[0][2],v)}function c(v){l("next",v)}function d(v){l("throw",v)}function y(v,w){v(w),s.shift(),s.length&&l(s[0][0],s[0][1])}}function es(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:Z(t[i](o)),done:!1}:s?s(o):o}:s}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hp=="function"?Hp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Et,memcpy:()=>uo,rebaseValueOffsets:()=>il,toArrayBufferView:()=>J,toArrayBufferViewAsyncIterator:()=>on,toArrayBufferViewIterator:()=>En,toBigInt64Array:()=>rl,toBigUint64Array:()=>Tw,toFloat32Array:()=>Ow,toFloat32ArrayAsyncIterator:()=>Hw,toFloat32ArrayIterator:()=>Uw,toFloat64Array:()=>Ew,toFloat64ArrayAsyncIterator:()=>Yw,toFloat64ArrayIterator:()=>Rw,toInt16Array:()=>Bw,toInt16ArrayAsyncIterator:()=>zw,toInt16ArrayIterator:()=>Aw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>Vw,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Iw,toInt8ArrayAsyncIterator:()=>jw,toInt8ArrayIterator:()=>kw,toUint16Array:()=>Dw,toUint16ArrayAsyncIterator:()=>$w,toUint16ArrayIterator:()=>Mw,toUint32Array:()=>Nw,toUint32ArrayAsyncIterator:()=>Ww,toUint32ArrayIterator:()=>Cw,toUint8Array:()=>V,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>Fw,toUint8ClampedArrayAsyncIterator:()=>Kw,toUint8ClampedArrayIterator:()=>Pw});var ww=new TextDecoder("utf-8"),ao=t=>ww.decode(t),Sw=new TextEncoder,On=t=>Sw.encode(t);var bw=t=>typeof t=="number",Kp=t=>typeof t=="boolean",je=t=>typeof t=="function",ct=t=>t!=null&&Object(t)===t,Ot=t=>ct(t)&&je(t.then);var sn=t=>ct(t)&&je(t[Symbol.iterator]),$t=t=>ct(t)&&je(t[Symbol.asyncIterator]),Za=t=>ct(t)&&ct(t.schema);var Ja=t=>ct(t)&&"done"in t&&"value"in t;var qa=t=>ct(t)&&je(t.stat)&&bw(t.fd);var el=t=>ct(t)&&lo(t.body),tl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Qp=t=>ct(t)&&je(t.abort)&&je(t.getWriter)&&!tl(t),lo=t=>ct(t)&&je(t.cancel)&&je(t.getReader)&&!tl(t),Gp=t=>ct(t)&&je(t.end)&&je(t.write)&&Kp(t.writable)&&!tl(t),nl=t=>ct(t)&&je(t.read)&&je(t.pipe)&&Kp(t.readable)&&!tl(t),Xp=t=>ct(t)&&je(t.clear)&&je(t.bytes)&&je(t.position)&&je(t.setPosition)&&je(t.capacity)&&je(t.getBufferIdentifier)&&je(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function xw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+d.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lJ(Int8Array,t),Bw=t=>J(Int16Array,t),di=t=>J(Int32Array,t),rl=t=>J(BigInt64Array,t),V=t=>J(Uint8Array,t),Dw=t=>J(Uint16Array,t),Nw=t=>J(Uint32Array,t),Tw=t=>J(BigUint64Array,t),Ow=t=>J(Float32Array,t),Ew=t=>J(Float64Array,t),Fw=t=>J(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*En(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):sn(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield J(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var kw=t=>En(Int8Array,t),Aw=t=>En(Int16Array,t),Lw=t=>En(Int32Array,t),df=t=>En(Uint8Array,t),Mw=t=>En(Uint16Array,t),Cw=t=>En(Uint32Array,t),Uw=t=>En(Float32Array,t),Rw=t=>En(Float64Array,t),Pw=t=>En(Uint8ClampedArray,t);function on(t,e){return Tt(this,arguments,function*(){if(Ot(e))return yield Z(yield Z(yield*es(rn(on(t,yield Z(e))))));let r=function(o){return Tt(this,arguments,function*(){yield yield Z(yield Z(o))})},i=function(o){return Tt(this,arguments,function*(){yield Z(yield*es(rn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):sn(e)?i(e):$t(e)?e:r(e);return yield Z(yield*es(rn(cf((function(o){return Tt(this,arguments,function*(){let a=null;do a=yield Z(o.next(yield yield Z(J(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield Z(new t)})}var jw=t=>on(Int8Array,t),zw=t=>on(Int16Array,t),Vw=t=>on(Int32Array,t),hf=t=>on(Uint8Array,t),$w=t=>on(Uint16Array,t),Ww=t=>on(Uint32Array,t),Hw=t=>on(Float32Array,t),Yw=t=>on(Float64Array,t),Kw=t=>on(Uint8ClampedArray,t);function il(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Qw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Et(r,o)[0]:([i,r,a]=Et(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a0&&(i.push(V(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return O(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return O(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=V(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Zw(t){return Tt(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function d(){return o==="peek"?Et(u,a)[0]:([c,u,l]=Et(u,a),c)}if({cmd:o,size:a}=(yield yield Z(null))||{cmd:"read",size:0},t.isTTY)return yield yield Z(new Uint8Array(0)),yield Z(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield Z(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=V(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield Z(d()));while(a{for(let[h,f]of v)t.off(h,f);try{let h=t.destroy;h&&h.call(t,w),w=void 0}catch(h){w=h||w}finally{w!=null?Y(w):I()}})}})}var ae;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(ae||(ae={}));var de;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(de||(de={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var Ae;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Ae||(Ae={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var He;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(He||(He={}));var Fn=new Int32Array(2),ol=new Float32Array(Fn.buffer),al=new Float64Array(Fn.buffer),ts=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var co;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(co||(co={}));var Ft=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){ol[0]=n,this.writeInt32(e,Fn[0])}writeFloat64(e,n){al[0]=n,this.writeInt32(e,Fn[ts?0:1]),this.writeInt32(e+4,Fn[ts?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var bo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new kn).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var gt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):kr.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,kr.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var ee;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(ee||(ee={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var cn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(cn||(cn={}));var Uf={};fi(Uf,{clampRange:()=>Do,createElementComparator:()=>$r,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>fn});function fn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>fn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Io,bigNumToBigInt:()=>Jp,bigNumToNumber:()=>Sf,bigNumToString:()=>os,isArrowBigNumSymbol:()=>Zp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Zp=Symbol.for("isArrowBigNum");function dn(t,...e){return e.length===0?Object.setPrototypeOf(J(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}dn.prototype[Zp]=!0;dn.prototype.toJSON=function(){return`"${os(this)}"`};dn.prototype.valueOf=function(t){return Sf(this,t)};dn.prototype.toString=function(){return os(this)};dn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return os(this);case"default":return Jp(this)}return os(this)};function is(...t){return dn.apply(this,t)}function ss(...t){return dn.apply(this,t)}function xo(...t){return dn.apply(this,t)}Object.setPrototypeOf(is.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ss.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(xo.prototype,Object.create(Uint32Array.prototype));Object.assign(is.prototype,dn.prototype,{constructor:is,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ss.prototype,dn.prototype,{constructor:ss,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(xo.prototype,dn.prototype,{constructor:xo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jw=BigInt(4294967296)*BigInt(4294967296),qw=Jw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(E.prototype);var ft=class extends E{constructor(){super(p.Null)}toString(){return"Null"}};em=Symbol.toStringTag;ft[em]=(t=>t[Symbol.toStringTag]="Null")(ft.prototype);var Ve=class extends E{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};tm=Symbol.toStringTag;Ve[tm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Ve.prototype);var cl=class extends Ve{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},fl=class extends Ve{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Ln=class extends Ve{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},dl=class extends Ve{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},hl=class extends Ve{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},pl=class extends Ve{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ml=class extends Ve{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yl=class extends Ve{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(cl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(fl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Ln.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(dl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(hl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(yl.prototype,"ArrayType",{value:BigUint64Array});var Ht=class extends E{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};nm=Symbol.toStringTag;Ht[nm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Ht.prototype);var gl=class extends Ht{constructor(){super(ce.HALF)}},vl=class extends Ht{constructor(){super(ce.SINGLE)}},_l=class extends Ht{constructor(){super(ce.DOUBLE)}};Object.defineProperty(gl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vl.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float64Array});var Gn=class extends E{constructor(){super(p.Binary)}toString(){return"Binary"}};rm=Symbol.toStringTag;Gn[rm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Gn.prototype);var Xn=class extends E{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};im=Symbol.toStringTag;Xn[im]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Xn.prototype);var Zn=class extends E{constructor(){super(p.Utf8)}toString(){return"Utf8"}};sm=Symbol.toStringTag;Zn[sm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Zn.prototype);var Jn=class extends E{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};om=Symbol.toStringTag;Jn[om]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(Jn.prototype);var qn=class extends E{constructor(){super(p.Bool)}toString(){return"Bool"}};am=Symbol.toStringTag;qn[am]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(qn.prototype);var er=class extends E{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lm=Symbol.toStringTag;er[lm]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(er.prototype);var tr=class extends E{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Ae[this.unit]}>`}get ArrayType(){return this.unit===Ae.DAY?Int32Array:BigInt64Array}};um=Symbol.toStringTag;tr[um]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(tr.prototype);var nr=class extends E{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};cm=Symbol.toStringTag;nr[cm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(nr.prototype);var rr=class extends E{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};fm=Symbol.toStringTag;rr[fm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(rr.prototype);var ir=class extends E{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${He[this.unit]}>`}};dm=Symbol.toStringTag;ir[dm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(ir.prototype);var sr=class extends E{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};hm=Symbol.toStringTag;sr[hm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(sr.prototype);var hn=class extends E{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};pm=Symbol.toStringTag;hn[pm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(hn.prototype);var he=class extends E{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};mm=Symbol.toStringTag;he[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(he.prototype);var pn=class extends E{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};ym=Symbol.toStringTag;pn[ym]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(pn.prototype);var or=class extends E{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};gm=Symbol.toStringTag;or[gm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(or.prototype);var mn=class extends E{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};vm=Symbol.toStringTag;mn[vm]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(mn.prototype);var yn=class extends E{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(yn.prototype);var eS=(t=>()=>++t)(-1),At=class extends E{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?eS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};wm=Symbol.toStringTag;At[wm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(At.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var C=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return tS(this,e,n)}getVisitFnByTypeId(e,n=!0){return as(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function tS(t,e,n=!0){return typeof e=="number"?as(t,e,n):typeof e=="string"&&e in p?as(t,p[e],n):e&&e instanceof E?as(t,Sm(e),n):e?.type&&e.type instanceof E?as(t,Sm(e.type),n):as(t,p.NONE,n)}function as(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function Sm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case Ae.DAY:return p.DateDay;case Ae.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case He.DAY_TIME:return p.IntervalDayTime;case He.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case de.Dense:return p.DenseUnion;case de.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}C.prototype.visitInt8=null;C.prototype.visitInt16=null;C.prototype.visitInt32=null;C.prototype.visitInt64=null;C.prototype.visitUint8=null;C.prototype.visitUint16=null;C.prototype.visitUint32=null;C.prototype.visitUint64=null;C.prototype.visitFloat16=null;C.prototype.visitFloat32=null;C.prototype.visitFloat64=null;C.prototype.visitDateDay=null;C.prototype.visitDateMillisecond=null;C.prototype.visitTimestampSecond=null;C.prototype.visitTimestampMillisecond=null;C.prototype.visitTimestampMicrosecond=null;C.prototype.visitTimestampNanosecond=null;C.prototype.visitTimeSecond=null;C.prototype.visitTimeMillisecond=null;C.prototype.visitTimeMicrosecond=null;C.prototype.visitTimeNanosecond=null;C.prototype.visitDenseUnion=null;C.prototype.visitSparseUnion=null;C.prototype.visitIntervalDayTime=null;C.prototype.visitIntervalYearMonth=null;C.prototype.visitDuration=null;C.prototype.visitDurationSecond=null;C.prototype.visitDurationMillisecond=null;C.prototype.visitDurationMicrosecond=null;C.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Bo,uint16ToFloat64:()=>wl});var bm=new Float64Array(1),ls=new Uint32Array(bm.buffer);function wl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Bo(t){if(t!==t)return 32256;bm[0]=t;let e=(ls[1]&2147483648)>>16&65535,n=ls[1]&2146435072,r=0;return n>=1089470464?ls[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ls[1]&1048575)>>10):n<=1056964608?(r=1048576+(ls[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ls[1]&1048575)+512>>10),e|n|r&65535}var z=class extends C{};function H(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var nS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},xm=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Im=({values:t},e,n)=>{t[e]=Bo(n)},iS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Im(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},Sl=({values:t},e,n)=>{nS(t,e,n.valueOf())},bl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Bm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,r),Dm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,On(r)),Df=(t,e,n)=>{t.type.unit===Ae.DAY?Sl(t,e,n):bl(t,e,n)},xl=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Il=({values:t},e,n)=>{t[e]=BigInt(n)},Bl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return xl(t,e,n);case k.MILLISECOND:return Il(t,e,n);case k.MICROSECOND:return Bl(t,e,n);case k.NANOSECOND:return Dl(t,e,n)}},Nl=({values:t},e,n)=>{t[e]=n},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},El=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Nl(t,e,n);case k.MILLISECOND:return Tl(t,e,n);case k.MICROSECOND:return Ol(t,e,n);case k.NANOSECOND:return El(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},sS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},aS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),fS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?uS(e,n):n instanceof te?lS(e,n):Array.isArray(n)?aS(e,n):cS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},dS=(t,e,n)=>{t.type.mode===de.Dense?Nm(t,e,n):Tm(t,e,n)},Nm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},hS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ef=(t,e,n)=>{t.type.unit===He.DAY_TIME?Fl(t,e,n):kl(t,e,n)},Fl=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},kl=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Al=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Ml=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ff=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Al(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Ml(t,e,n);case k.NANOSECOND:return Cl(t,e,n)}},pS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[gn],this[us])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[gn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[gn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[gn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Me.visit(e[gn].children[r],e[us]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[gn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[gn].children[i],e[us],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var U=class extends C{};function $(t){return(e,n)=>e.getValid(n)?t(e,n):null}var mS=(t,e)=>864e5*t[e],yS=(t,e)=>null,Om=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},gS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<mS(t,e),Fm=({values:t},e)=>ne(t[e]),zr=({stride:t,values:e},n)=>e[t*n],vS=({stride:t,values:e},n)=>wl(e[t*n]),km=({values:t},e)=>t[e],_S=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Am=({values:t,valueOffsets:e},n)=>Om(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Om(t,e,n);return r!==null?ao(r):null},wS=({values:t},e)=>t[e],SS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:wl(e[n]),bS=(t,e)=>t.type.unit===Ae.DAY?Em(t,e):Fm(t,e),Mm=({values:t},e)=>1e3*ne(t[e]),Cm=({values:t},e)=>ne(t[e]),Um=({values:t},e)=>_f(t[e],BigInt(1e3)),Rm=({values:t},e)=>_f(t[e],BigInt(1e6)),xS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Mm(t,e);case k.MILLISECOND:return Cm(t,e);case k.MICROSECOND:return Um(t,e);case k.NANOSECOND:return Rm(t,e)}},Pm=({values:t},e)=>t[e],jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Pm(t,e);case k.MILLISECOND:return jm(t,e);case k.MICROSECOND:return zm(t,e);case k.NANOSECOND:return Vm(t,e)}},BS=({values:t,stride:e},n)=>Io.decimal(t.subarray(e*n,e*(n+1))),DS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new te([l])},NS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Mn(o.slice(i,s-i))},TS=(t,e)=>new jr(t,e),OS=(t,e)=>t.type.mode===de.Dense?$m(t,e):Wm(t,e),$m=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,t.valueOffsets[e])},Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,e)},ES=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},FS=(t,e)=>t.type.unit===He.DAY_TIME?Hm(t,e):Ym(t,e),Hm=({values:t},e)=>t.subarray(2*e,2*(e+1)),Ym=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Km=({values:t},e)=>t[e],Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],kS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Km(t,e);case k.MILLISECOND:return Qm(t,e);case k.MICROSECOND:return Gm(t,e);case k.NANOSECOND:return Xm(t,e)}},AS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new te([s])};U.prototype.visitNull=$(yS);U.prototype.visitBool=$(gS);U.prototype.visitInt=$(wS);U.prototype.visitInt8=$(zr);U.prototype.visitInt16=$(zr);U.prototype.visitInt32=$(zr);U.prototype.visitInt64=$(km);U.prototype.visitUint8=$(zr);U.prototype.visitUint16=$(zr);U.prototype.visitUint32=$(zr);U.prototype.visitUint64=$(km);U.prototype.visitFloat=$(SS);U.prototype.visitFloat16=$(vS);U.prototype.visitFloat32=$(zr);U.prototype.visitFloat64=$(zr);U.prototype.visitUtf8=$(Lm);U.prototype.visitLargeUtf8=$(Lm);U.prototype.visitBinary=$(Am);U.prototype.visitLargeBinary=$(Am);U.prototype.visitFixedSizeBinary=$(_S);U.prototype.visitDate=$(bS);U.prototype.visitDateDay=$(Em);U.prototype.visitDateMillisecond=$(Fm);U.prototype.visitTimestamp=$(xS);U.prototype.visitTimestampSecond=$(Mm);U.prototype.visitTimestampMillisecond=$(Cm);U.prototype.visitTimestampMicrosecond=$(Um);U.prototype.visitTimestampNanosecond=$(Rm);U.prototype.visitTime=$(IS);U.prototype.visitTimeSecond=$(Pm);U.prototype.visitTimeMillisecond=$(jm);U.prototype.visitTimeMicrosecond=$(zm);U.prototype.visitTimeNanosecond=$(Vm);U.prototype.visitDecimal=$(BS);U.prototype.visitList=$(DS);U.prototype.visitStruct=$(TS);U.prototype.visitUnion=$(OS);U.prototype.visitDenseUnion=$($m);U.prototype.visitSparseUnion=$(Wm);U.prototype.visitDictionary=$(ES);U.prototype.visitInterval=$(FS);U.prototype.visitIntervalDayTime=$(Hm);U.prototype.visitIntervalYearMonth=$(Ym);U.prototype.visitDuration=$(kS);U.prototype.visitDurationSecond=$(Km);U.prototype.visitDurationMillisecond=$(Qm);U.prototype.visitDurationMicrosecond=$(Gm);U.prototype.visitDurationNanosecond=$(Xm);U.prototype.visitFixedSizeList=$(AS);U.prototype.visitMap=$(NS);var Me=new U;var Vr=Symbol.for("keys"),fs=Symbol.for("vals"),cs=Symbol.for("kKeysAsStrings"),Lf=Symbol.for("_kKeysAsStrings"),Mn=class{constructor(e){return this[Vr]=new te([e.children[0]]).memoize(),this[fs]=e.children[1],new Proxy(this,new Cf)}get[cs](){return this[Lf]||(this[Lf]=Array.from(this[Vr].toArray(),String))}[Symbol.iterator](){return new Mf(this[Vr],this[fs])}get size(){return this[Vr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Vr],n=this[fs],r={};for(let i=-1,s=e.length;++i`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Mf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Me.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cs]}has(e,n){return e[cs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[cs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[cs].indexOf(n);if(r!==-1){let i=Me.visit(Reflect.get(e,fs),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[cs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,fs),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Mn.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Vr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[fs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Zm;function Do(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,Jm=t=>t!==t;function $r(t){if(typeof t!=="object"||t===null)return Jm(t)?Jm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?MS(t):Array.isArray(t)?LS(t):t instanceof te?CS(t):US(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return RS(t,n);case Map:return qm(t,n,n.keys());case Mn:case jr:case Object:case void 0:return qm(t,n,e||Object.keys(n))}return n instanceof te?PS(t,n):!1}}function RS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ey,getBool:()=>Pl,packBools:()=>gi,popcnt_array:()=>ty,popcnt_bit_range:()=>No,popcnt_uint32:()=>Rl,setBool:()=>jS,truncateBitmap:()=>yi});function Pl(t,e,n,r){return(n&1<>r}function jS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,Pl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return No(t,e,i)+No(t,r,n)+ty(t,i>>3,r-i>>3)}function ty(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Rl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Rl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Rl(s.getUint8(i)),i+=1;return r}function Rl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var zS=-1,ie=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return E.isSparseUnion(e)?this.children.some(n=>n.nullable):E.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(E.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=zS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-No(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(E.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===de.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[c];r=(d&u)!==0,s[c]=n?d|u:d&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[cn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[cn.TYPE])&&(o[cn.TYPE]=s.subarray(e,e+n)),(s=o[cn.OFFSET])&&(o[cn.OFFSET]=s.subarray(e,e+n+1))||(s=o[cn.DATA])&&(o[cn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};ie.prototype.children=Object.freeze([]);var Pf=class t extends C{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new ie(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=V(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=J(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(E.isSparseUnion(n))return new ie(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new ie(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.indices.ArrayType,e.data),{["dictionary"]:o=new te([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=V(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}},VS=new Pf;function Q(t){return VS.visit(t)}var To=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function jl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function zl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function Vl(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),d=Math.min(r-l,u);i.push(a.slice(c,d-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function WS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,Pl)){if(!i)return r;++r}return-1}function G(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return WS(t,n)}let r=Me.getVisitFn(t),i=$r(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new To(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof ie)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=sy[o.typeId],c=s[0];this.isValid=d=>Oo(c,d),this.get=d=>a(c,d),this.set=(d,y)=>l(c,d,y),this.indexOf=d=>u(c,d),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,oy[o.typeId]),this._offsets=zl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ny(this.data)}get nullCount(){return jl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return hs.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(Do(this,e,n,({data:r,_offsets:i},s,o)=>Vl(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return E.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(E.isDictionary(this.type)){let e=new Hl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Hl(this)}unmemoize(){if(E.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};iy=Symbol.toStringTag;te[iy]=(t=>{t.type=E.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Me.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);sy[n]={get:r,set:i,indexOf:s},oy[n]=Object.create(t,{isValid:{value:ds(Oo)},get:{value:ds(Me.getVisitFnByTypeId(n))},set:{value:$l(Xe.getVisitFnByTypeId(n))},indexOf:{value:Wl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(te.prototype);var Hl=class t extends te{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new te(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ay(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` +var _w=Object.defineProperty;var fi=(t,e)=>{for(var n in e)_w(t,n,{get:e[n],enumerable:!0})};function Yp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(t){return this instanceof Z?(this.v=t,this):new Z(t)}function Tt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(w){return Promise.resolve(w).then(v,d)}}function a(v,w){r[v]&&(i[v]=function(I){return new Promise(function(Y,h){s.push([v,I,Y,h])>1||l(v,I)})},w&&(i[v]=w(i[v])))}function l(v,w){try{u(r[v](w))}catch(I){y(s[0][3],I)}}function u(v){v.value instanceof Z?Promise.resolve(v.value.v).then(c,d):y(s[0][2],v)}function c(v){l("next",v)}function d(v){l("throw",v)}function y(v,w){v(w),s.shift(),s.length&&l(s[0][0],s[0][1])}}function es(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:Z(t[i](o)),done:!1}:s?s(o):o}:s}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hp=="function"?Hp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Et,memcpy:()=>uo,rebaseValueOffsets:()=>il,toArrayBufferView:()=>J,toArrayBufferViewAsyncIterator:()=>on,toArrayBufferViewIterator:()=>En,toBigInt64Array:()=>rl,toBigUint64Array:()=>Tw,toFloat32Array:()=>Ow,toFloat32ArrayAsyncIterator:()=>Hw,toFloat32ArrayIterator:()=>Uw,toFloat64Array:()=>Ew,toFloat64ArrayAsyncIterator:()=>Yw,toFloat64ArrayIterator:()=>Rw,toInt16Array:()=>Bw,toInt16ArrayAsyncIterator:()=>zw,toInt16ArrayIterator:()=>Aw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>Vw,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Iw,toInt8ArrayAsyncIterator:()=>jw,toInt8ArrayIterator:()=>kw,toUint16Array:()=>Dw,toUint16ArrayAsyncIterator:()=>$w,toUint16ArrayIterator:()=>Mw,toUint32Array:()=>Nw,toUint32ArrayAsyncIterator:()=>Ww,toUint32ArrayIterator:()=>Cw,toUint8Array:()=>V,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>Fw,toUint8ClampedArrayAsyncIterator:()=>Kw,toUint8ClampedArrayIterator:()=>Pw});var ww=new TextDecoder("utf-8"),ao=t=>ww.decode(t),Sw=new TextEncoder,On=t=>Sw.encode(t);var bw=t=>typeof t=="number",Kp=t=>typeof t=="boolean",je=t=>typeof t=="function",ct=t=>t!=null&&Object(t)===t,Ot=t=>ct(t)&&je(t.then);var sn=t=>ct(t)&&je(t[Symbol.iterator]),Wt=t=>ct(t)&&je(t[Symbol.asyncIterator]),Za=t=>ct(t)&&ct(t.schema);var Ja=t=>ct(t)&&"done"in t&&"value"in t;var qa=t=>ct(t)&&je(t.stat)&&bw(t.fd);var el=t=>ct(t)&&lo(t.body),tl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Qp=t=>ct(t)&&je(t.abort)&&je(t.getWriter)&&!tl(t),lo=t=>ct(t)&&je(t.cancel)&&je(t.getReader)&&!tl(t),Gp=t=>ct(t)&&je(t.end)&&je(t.write)&&Kp(t.writable)&&!tl(t),nl=t=>ct(t)&&je(t.read)&&je(t.pipe)&&Kp(t.readable)&&!tl(t),Xp=t=>ct(t)&&je(t.clear)&&je(t.bytes)&&je(t.position)&&je(t.setPosition)&&je(t.capacity)&&je(t.getBufferIdentifier)&&je(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function xw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+d.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lJ(Int8Array,t),Bw=t=>J(Int16Array,t),di=t=>J(Int32Array,t),rl=t=>J(BigInt64Array,t),V=t=>J(Uint8Array,t),Dw=t=>J(Uint16Array,t),Nw=t=>J(Uint32Array,t),Tw=t=>J(BigUint64Array,t),Ow=t=>J(Float32Array,t),Ew=t=>J(Float64Array,t),Fw=t=>J(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*En(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):sn(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield J(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var kw=t=>En(Int8Array,t),Aw=t=>En(Int16Array,t),Lw=t=>En(Int32Array,t),df=t=>En(Uint8Array,t),Mw=t=>En(Uint16Array,t),Cw=t=>En(Uint32Array,t),Uw=t=>En(Float32Array,t),Rw=t=>En(Float64Array,t),Pw=t=>En(Uint8ClampedArray,t);function on(t,e){return Tt(this,arguments,function*(){if(Ot(e))return yield Z(yield Z(yield*es(rn(on(t,yield Z(e))))));let r=function(o){return Tt(this,arguments,function*(){yield yield Z(yield Z(o))})},i=function(o){return Tt(this,arguments,function*(){yield Z(yield*es(rn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):sn(e)?i(e):Wt(e)?e:r(e);return yield Z(yield*es(rn(cf((function(o){return Tt(this,arguments,function*(){let a=null;do a=yield Z(o.next(yield yield Z(J(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield Z(new t)})}var jw=t=>on(Int8Array,t),zw=t=>on(Int16Array,t),Vw=t=>on(Int32Array,t),hf=t=>on(Uint8Array,t),$w=t=>on(Uint16Array,t),Ww=t=>on(Uint32Array,t),Hw=t=>on(Float32Array,t),Yw=t=>on(Float64Array,t),Kw=t=>on(Uint8ClampedArray,t);function il(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Qw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Et(r,o)[0]:([i,r,a]=Et(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a0&&(i.push(V(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return O(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return O(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=V(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Zw(t){return Tt(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function d(){return o==="peek"?Et(u,a)[0]:([c,u,l]=Et(u,a),c)}if({cmd:o,size:a}=(yield yield Z(null))||{cmd:"read",size:0},t.isTTY)return yield yield Z(new Uint8Array(0)),yield Z(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield Z(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=V(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield Z(d()));while(a{for(let[h,f]of v)t.off(h,f);try{let h=t.destroy;h&&h.call(t,w),w=void 0}catch(h){w=h||w}finally{w!=null?Y(w):I()}})}})}var ae;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(ae||(ae={}));var de;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(de||(de={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var Ae;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Ae||(Ae={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var He;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(He||(He={}));var Fn=new Int32Array(2),ol=new Float32Array(Fn.buffer),al=new Float64Array(Fn.buffer),ts=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var co;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(co||(co={}));var Ft=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){ol[0]=n,this.writeInt32(e,Fn[0])}writeFloat64(e,n){al[0]=n,this.writeInt32(e,Fn[ts?0:1]),this.writeInt32(e+4,Fn[ts?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var bo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new kn).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var gt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):kr.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,kr.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var ee;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(ee||(ee={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var cn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(cn||(cn={}));var Uf={};fi(Uf,{clampRange:()=>Do,createElementComparator:()=>$r,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>fn});function fn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>fn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Io,bigNumToBigInt:()=>Jp,bigNumToNumber:()=>Sf,bigNumToString:()=>os,isArrowBigNumSymbol:()=>Zp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Zp=Symbol.for("isArrowBigNum");function dn(t,...e){return e.length===0?Object.setPrototypeOf(J(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}dn.prototype[Zp]=!0;dn.prototype.toJSON=function(){return`"${os(this)}"`};dn.prototype.valueOf=function(t){return Sf(this,t)};dn.prototype.toString=function(){return os(this)};dn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return os(this);case"default":return Jp(this)}return os(this)};function is(...t){return dn.apply(this,t)}function ss(...t){return dn.apply(this,t)}function xo(...t){return dn.apply(this,t)}Object.setPrototypeOf(is.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ss.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(xo.prototype,Object.create(Uint32Array.prototype));Object.assign(is.prototype,dn.prototype,{constructor:is,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ss.prototype,dn.prototype,{constructor:ss,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(xo.prototype,dn.prototype,{constructor:xo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jw=BigInt(4294967296)*BigInt(4294967296),qw=Jw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(E.prototype);var ft=class extends E{constructor(){super(p.Null)}toString(){return"Null"}};em=Symbol.toStringTag;ft[em]=(t=>t[Symbol.toStringTag]="Null")(ft.prototype);var Ve=class extends E{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};tm=Symbol.toStringTag;Ve[tm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Ve.prototype);var cl=class extends Ve{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},fl=class extends Ve{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Ln=class extends Ve{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},dl=class extends Ve{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},hl=class extends Ve{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},pl=class extends Ve{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ml=class extends Ve{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yl=class extends Ve{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(cl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(fl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Ln.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(dl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(hl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(yl.prototype,"ArrayType",{value:BigUint64Array});var Yt=class extends E{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};nm=Symbol.toStringTag;Yt[nm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Yt.prototype);var gl=class extends Yt{constructor(){super(ce.HALF)}},vl=class extends Yt{constructor(){super(ce.SINGLE)}},_l=class extends Yt{constructor(){super(ce.DOUBLE)}};Object.defineProperty(gl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vl.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float64Array});var Gn=class extends E{constructor(){super(p.Binary)}toString(){return"Binary"}};rm=Symbol.toStringTag;Gn[rm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Gn.prototype);var Xn=class extends E{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};im=Symbol.toStringTag;Xn[im]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Xn.prototype);var Zn=class extends E{constructor(){super(p.Utf8)}toString(){return"Utf8"}};sm=Symbol.toStringTag;Zn[sm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Zn.prototype);var Jn=class extends E{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};om=Symbol.toStringTag;Jn[om]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(Jn.prototype);var qn=class extends E{constructor(){super(p.Bool)}toString(){return"Bool"}};am=Symbol.toStringTag;qn[am]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(qn.prototype);var er=class extends E{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lm=Symbol.toStringTag;er[lm]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(er.prototype);var tr=class extends E{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Ae[this.unit]}>`}get ArrayType(){return this.unit===Ae.DAY?Int32Array:BigInt64Array}};um=Symbol.toStringTag;tr[um]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(tr.prototype);var nr=class extends E{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};cm=Symbol.toStringTag;nr[cm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(nr.prototype);var rr=class extends E{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};fm=Symbol.toStringTag;rr[fm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(rr.prototype);var ir=class extends E{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${He[this.unit]}>`}};dm=Symbol.toStringTag;ir[dm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(ir.prototype);var sr=class extends E{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};hm=Symbol.toStringTag;sr[hm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(sr.prototype);var hn=class extends E{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};pm=Symbol.toStringTag;hn[pm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(hn.prototype);var pe=class extends E{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};mm=Symbol.toStringTag;pe[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(pe.prototype);var pn=class extends E{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};ym=Symbol.toStringTag;pn[ym]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(pn.prototype);var or=class extends E{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};gm=Symbol.toStringTag;or[gm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(or.prototype);var mn=class extends E{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};vm=Symbol.toStringTag;mn[vm]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(mn.prototype);var yn=class extends E{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(yn.prototype);var eS=(t=>()=>++t)(-1),At=class extends E{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?eS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};wm=Symbol.toStringTag;At[wm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(At.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var C=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return tS(this,e,n)}getVisitFnByTypeId(e,n=!0){return as(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function tS(t,e,n=!0){return typeof e=="number"?as(t,e,n):typeof e=="string"&&e in p?as(t,p[e],n):e&&e instanceof E?as(t,Sm(e),n):e?.type&&e.type instanceof E?as(t,Sm(e.type),n):as(t,p.NONE,n)}function as(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function Sm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case Ae.DAY:return p.DateDay;case Ae.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case He.DAY_TIME:return p.IntervalDayTime;case He.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case de.Dense:return p.DenseUnion;case de.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}C.prototype.visitInt8=null;C.prototype.visitInt16=null;C.prototype.visitInt32=null;C.prototype.visitInt64=null;C.prototype.visitUint8=null;C.prototype.visitUint16=null;C.prototype.visitUint32=null;C.prototype.visitUint64=null;C.prototype.visitFloat16=null;C.prototype.visitFloat32=null;C.prototype.visitFloat64=null;C.prototype.visitDateDay=null;C.prototype.visitDateMillisecond=null;C.prototype.visitTimestampSecond=null;C.prototype.visitTimestampMillisecond=null;C.prototype.visitTimestampMicrosecond=null;C.prototype.visitTimestampNanosecond=null;C.prototype.visitTimeSecond=null;C.prototype.visitTimeMillisecond=null;C.prototype.visitTimeMicrosecond=null;C.prototype.visitTimeNanosecond=null;C.prototype.visitDenseUnion=null;C.prototype.visitSparseUnion=null;C.prototype.visitIntervalDayTime=null;C.prototype.visitIntervalYearMonth=null;C.prototype.visitDuration=null;C.prototype.visitDurationSecond=null;C.prototype.visitDurationMillisecond=null;C.prototype.visitDurationMicrosecond=null;C.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Bo,uint16ToFloat64:()=>wl});var bm=new Float64Array(1),ls=new Uint32Array(bm.buffer);function wl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Bo(t){if(t!==t)return 32256;bm[0]=t;let e=(ls[1]&2147483648)>>16&65535,n=ls[1]&2146435072,r=0;return n>=1089470464?ls[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ls[1]&1048575)>>10):n<=1056964608?(r=1048576+(ls[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ls[1]&1048575)+512>>10),e|n|r&65535}var z=class extends C{};function H(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var nS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},xm=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Im=({values:t},e,n)=>{t[e]=Bo(n)},iS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Im(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},Sl=({values:t},e,n)=>{nS(t,e,n.valueOf())},bl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Bm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,r),Dm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,On(r)),Df=(t,e,n)=>{t.type.unit===Ae.DAY?Sl(t,e,n):bl(t,e,n)},xl=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Il=({values:t},e,n)=>{t[e]=BigInt(n)},Bl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return xl(t,e,n);case k.MILLISECOND:return Il(t,e,n);case k.MICROSECOND:return Bl(t,e,n);case k.NANOSECOND:return Dl(t,e,n)}},Nl=({values:t},e,n)=>{t[e]=n},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},El=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Nl(t,e,n);case k.MILLISECOND:return Tl(t,e,n);case k.MICROSECOND:return Ol(t,e,n);case k.NANOSECOND:return El(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},sS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},aS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),fS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?uS(e,n):n instanceof te?lS(e,n):Array.isArray(n)?aS(e,n):cS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},dS=(t,e,n)=>{t.type.mode===de.Dense?Nm(t,e,n):Tm(t,e,n)},Nm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},hS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ef=(t,e,n)=>{t.type.unit===He.DAY_TIME?Fl(t,e,n):kl(t,e,n)},Fl=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},kl=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Al=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Ml=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ff=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Al(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Ml(t,e,n);case k.NANOSECOND:return Cl(t,e,n)}},pS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[gn],this[us])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[gn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[gn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[gn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Me.visit(e[gn].children[r],e[us]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[gn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[gn].children[i],e[us],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var U=class extends C{};function $(t){return(e,n)=>e.getValid(n)?t(e,n):null}var mS=(t,e)=>864e5*t[e],yS=(t,e)=>null,Om=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},gS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<mS(t,e),Fm=({values:t},e)=>ne(t[e]),zr=({stride:t,values:e},n)=>e[t*n],vS=({stride:t,values:e},n)=>wl(e[t*n]),km=({values:t},e)=>t[e],_S=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Am=({values:t,valueOffsets:e},n)=>Om(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Om(t,e,n);return r!==null?ao(r):null},wS=({values:t},e)=>t[e],SS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:wl(e[n]),bS=(t,e)=>t.type.unit===Ae.DAY?Em(t,e):Fm(t,e),Mm=({values:t},e)=>1e3*ne(t[e]),Cm=({values:t},e)=>ne(t[e]),Um=({values:t},e)=>_f(t[e],BigInt(1e3)),Rm=({values:t},e)=>_f(t[e],BigInt(1e6)),xS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Mm(t,e);case k.MILLISECOND:return Cm(t,e);case k.MICROSECOND:return Um(t,e);case k.NANOSECOND:return Rm(t,e)}},Pm=({values:t},e)=>t[e],jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Pm(t,e);case k.MILLISECOND:return jm(t,e);case k.MICROSECOND:return zm(t,e);case k.NANOSECOND:return Vm(t,e)}},BS=({values:t,stride:e},n)=>Io.decimal(t.subarray(e*n,e*(n+1))),DS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new te([l])},NS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Mn(o.slice(i,s-i))},TS=(t,e)=>new jr(t,e),OS=(t,e)=>t.type.mode===de.Dense?$m(t,e):Wm(t,e),$m=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,t.valueOffsets[e])},Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,e)},ES=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},FS=(t,e)=>t.type.unit===He.DAY_TIME?Hm(t,e):Ym(t,e),Hm=({values:t},e)=>t.subarray(2*e,2*(e+1)),Ym=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Km=({values:t},e)=>t[e],Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],kS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Km(t,e);case k.MILLISECOND:return Qm(t,e);case k.MICROSECOND:return Gm(t,e);case k.NANOSECOND:return Xm(t,e)}},AS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new te([s])};U.prototype.visitNull=$(yS);U.prototype.visitBool=$(gS);U.prototype.visitInt=$(wS);U.prototype.visitInt8=$(zr);U.prototype.visitInt16=$(zr);U.prototype.visitInt32=$(zr);U.prototype.visitInt64=$(km);U.prototype.visitUint8=$(zr);U.prototype.visitUint16=$(zr);U.prototype.visitUint32=$(zr);U.prototype.visitUint64=$(km);U.prototype.visitFloat=$(SS);U.prototype.visitFloat16=$(vS);U.prototype.visitFloat32=$(zr);U.prototype.visitFloat64=$(zr);U.prototype.visitUtf8=$(Lm);U.prototype.visitLargeUtf8=$(Lm);U.prototype.visitBinary=$(Am);U.prototype.visitLargeBinary=$(Am);U.prototype.visitFixedSizeBinary=$(_S);U.prototype.visitDate=$(bS);U.prototype.visitDateDay=$(Em);U.prototype.visitDateMillisecond=$(Fm);U.prototype.visitTimestamp=$(xS);U.prototype.visitTimestampSecond=$(Mm);U.prototype.visitTimestampMillisecond=$(Cm);U.prototype.visitTimestampMicrosecond=$(Um);U.prototype.visitTimestampNanosecond=$(Rm);U.prototype.visitTime=$(IS);U.prototype.visitTimeSecond=$(Pm);U.prototype.visitTimeMillisecond=$(jm);U.prototype.visitTimeMicrosecond=$(zm);U.prototype.visitTimeNanosecond=$(Vm);U.prototype.visitDecimal=$(BS);U.prototype.visitList=$(DS);U.prototype.visitStruct=$(TS);U.prototype.visitUnion=$(OS);U.prototype.visitDenseUnion=$($m);U.prototype.visitSparseUnion=$(Wm);U.prototype.visitDictionary=$(ES);U.prototype.visitInterval=$(FS);U.prototype.visitIntervalDayTime=$(Hm);U.prototype.visitIntervalYearMonth=$(Ym);U.prototype.visitDuration=$(kS);U.prototype.visitDurationSecond=$(Km);U.prototype.visitDurationMillisecond=$(Qm);U.prototype.visitDurationMicrosecond=$(Gm);U.prototype.visitDurationNanosecond=$(Xm);U.prototype.visitFixedSizeList=$(AS);U.prototype.visitMap=$(NS);var Me=new U;var Vr=Symbol.for("keys"),fs=Symbol.for("vals"),cs=Symbol.for("kKeysAsStrings"),Lf=Symbol.for("_kKeysAsStrings"),Mn=class{constructor(e){return this[Vr]=new te([e.children[0]]).memoize(),this[fs]=e.children[1],new Proxy(this,new Cf)}get[cs](){return this[Lf]||(this[Lf]=Array.from(this[Vr].toArray(),String))}[Symbol.iterator](){return new Mf(this[Vr],this[fs])}get size(){return this[Vr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Vr],n=this[fs],r={};for(let i=-1,s=e.length;++i`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Mf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Me.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cs]}has(e,n){return e[cs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[cs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[cs].indexOf(n);if(r!==-1){let i=Me.visit(Reflect.get(e,fs),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[cs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,fs),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Mn.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Vr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[fs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Zm;function Do(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,Jm=t=>t!==t;function $r(t){if(typeof t!=="object"||t===null)return Jm(t)?Jm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?MS(t):Array.isArray(t)?LS(t):t instanceof te?CS(t):US(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return RS(t,n);case Map:return qm(t,n,n.keys());case Mn:case jr:case Object:case void 0:return qm(t,n,e||Object.keys(n))}return n instanceof te?PS(t,n):!1}}function RS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ey,getBool:()=>Pl,packBools:()=>gi,popcnt_array:()=>ty,popcnt_bit_range:()=>No,popcnt_uint32:()=>Rl,setBool:()=>jS,truncateBitmap:()=>yi});function Pl(t,e,n,r){return(n&1<>r}function jS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,Pl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return No(t,e,i)+No(t,r,n)+ty(t,i>>3,r-i>>3)}function ty(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Rl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Rl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Rl(s.getUint8(i)),i+=1;return r}function Rl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var zS=-1,ie=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return E.isSparseUnion(e)?this.children.some(n=>n.nullable):E.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(E.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=zS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-No(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(E.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===de.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[c];r=(d&u)!==0,s[c]=n?d|u:d&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[cn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[cn.TYPE])&&(o[cn.TYPE]=s.subarray(e,e+n)),(s=o[cn.OFFSET])&&(o[cn.OFFSET]=s.subarray(e,e+n+1))||(s=o[cn.DATA])&&(o[cn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};ie.prototype.children=Object.freeze([]);var Pf=class t extends C{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new ie(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=V(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=J(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(E.isSparseUnion(n))return new ie(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new ie(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.indices.ArrayType,e.data),{["dictionary"]:o=new te([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=V(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}},VS=new Pf;function Q(t){return VS.visit(t)}var To=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function jl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function zl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function Vl(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),d=Math.min(r-l,u);i.push(a.slice(c,d-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function WS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,Pl)){if(!i)return r;++r}return-1}function G(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return WS(t,n)}let r=Me.getVisitFn(t),i=$r(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new To(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof ie)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=sy[o.typeId],c=s[0];this.isValid=d=>Oo(c,d),this.get=d=>a(c,d),this.set=(d,y)=>l(c,d,y),this.indexOf=d=>u(c,d),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,oy[o.typeId]),this._offsets=zl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ny(this.data)}get nullCount(){return jl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return hs.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(Do(this,e,n,({data:r,_offsets:i},s,o)=>Vl(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return E.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(E.isDictionary(this.type)){let e=new Hl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Hl(this)}unmemoize(){if(E.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};iy=Symbol.toStringTag;te[iy]=(t=>{t.type=E.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Me.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);sy[n]={get:r,set:i,indexOf:s},oy[n]=Object.create(t,{isValid:{value:ds(Oo)},get:{value:ds(Me.getVisitFnByTypeId(n))},set:{value:$l(Xe.getVisitFnByTypeId(n))},indexOf:{value:Wl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(te.prototype);var Hl=class t extends te{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new te(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ay(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` switch (x) {${n.map(r=>` case ${HS(r)}:`).join("")} return false; }`),t.length!==n.length&&(e=`if (x !== x) return false; ${e}`),new Function("x",`${e} -return true;`)}function HS(t){return typeof t!="bigint"?fn(t):`${fn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function ly(t,e=0){return t.length>=e?t.subarray(0,e):uo(new t.constructor(e),t,0)}var vn=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=ly(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=ly(this.buffer,e)}},lr=class extends vn{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ps=class extends lr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ge=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ps,n&&n.length>0&&(this._isValid=ay(n))}toVector(){return new te([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:d}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=d?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),Q({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ge.prototype.length=1;ge.prototype.stride=1;ge.prototype.children=null;ge.prototype.finished=!1;ge.prototype.nullValues=null;ge.prototype._isValid=()=>!0;var Ce=class extends ge{constructor(e){super(e),this._values=new lr(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},vt=class extends ge{constructor(e){super(e),this._pendingLength=0,this._offsets=new ms(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Mn?n[Vr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Mt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new gt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var oe=class t{constructor(e=[],n,r,i=ae.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Yl(Yl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Yl(Yl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};oe.prototype.fields=null;oe.prototype.metadata=null;oe.prototype.dictionaries=null;var q=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};q.prototype.type=null;q.prototype.name=null;q.prototype.nullable=null;q.prototype.metadata=null;function Yl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var YS=hi,KS=Ft,ur=class{static decode(e){e=new KS(V(e));let n=Mt.getRootAsFooter(e),r=oe.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new YS,r=oe.encode(n,e.schema);Mt.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())cr.encode(n,o);let i=n.endVector();Mt.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())cr.encode(n,o);let s=n.endVector();return Mt.startFooter(n),Mt.addSchema(n,r),Mt.addVersion(n,ae.V5),Mt.addRecordBatches(n,i),Mt.addDictionaries(n,s),Mt.finishFooterBuffer(n,Mt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=ae.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(pe);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return O(this,void 0,void 0,function*(){return yield this.abort(e),pe})}return(e){return O(this,void 0,void 0,function*(){return yield this.close(),pe})}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(pe)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Cn=class extends Kl{write(e){if((e=V(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ao(this.toUint8Array(!0)):this.toUint8Array(!1).then(ao)}toUint8Array(e=!1){return e?Et(this._values)[0]:O(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=rn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Et(o,a)[0]})}},Un=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Yt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Cn?this.source=new fr(Ge.fromAsyncIterable(e)):nl(e)?this.source=new fr(Ge.fromNodeStream(e)):lo(e)?this.source=new fr(Ge.fromDOMStream(e)):el(e)?this.source=new fr(Ge.fromDOMStream(e.body)):sn(e)?this.source=new fr(Ge.fromIterable(e)):Ot(e)?this.source=new fr(Ge.fromAsyncIterable(e)):$t(e)&&(this.source=new fr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||pe)}return(e){return Object.create(this.source.return&&this.source.return(e)||pe)}},fr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return O(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return O(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return O(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||pe;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var Fo=class extends Un{constructor(e,n){super(),this.position=0,this.buffer=V(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eko,Int128:()=>Ao,Int64:()=>dr,Uint64:()=>De});function ys(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var gs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ko=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ys(this.buffer[3])} ${ys(this.buffer[2])} ${ys(this.buffer[1])} ${ys(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Ql=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return E.isTimestamp(e)?J(Uint8Array,dr.convertArray(r[n])):(E.isInt(e)||E.isTime(e))&&e.bitWidth===64||E.isDuration(e)?J(Uint8Array,dr.convertArray(r[n])):E.isDate(e)&&e.unit===Ae.MILLISECOND?J(Uint8Array,dr.convertArray(r[n])):E.isDecimal(e)?J(Uint8Array,Ao.convertArray(r[n])):E.isBinary(e)||E.isLargeBinary(e)||E.isFixedSizeBinary(e)?QS(r[n]):E.isBool(e)?gi(r[n]):E.isUtf8(e)||E.isLargeUtf8(e)?On(r[n].join("")):J(Uint8Array,J(e.ArrayType,r[n].map(i=>+i)))}};function QS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var vs=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var _s=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Gl=class extends ge{constructor(e){super(e),this._values=new ps}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Ce{};Si.prototype._setValue=Df;var Mo=class extends Si{};Mo.prototype._setValue=Sl;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Ce{};Uo.prototype._setValue=Of;var Xl=class extends ge{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new At(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Ro=class extends Ce{};Ro.prototype._setValue=Bf;var Zl=class extends ge{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new mn(this.type.listSize,new q(n,e.type,!0)),r}};var xi=class extends Ce{setValue(e,n){this._values.set(e,n)}},Jl=class extends xi{setValue(e,n){super.setValue(e,Bo(n))}},ql=class extends xi{},eu=class extends xi{};var Ii=class extends Ce{};Ii.prototype._setValue=Ef;var Po=class extends Ii{};Po.prototype._setValue=Fl;var jo=class extends Ii{};jo.prototype._setValue=kl;var hr=class extends Ce{};hr.prototype._setValue=Ff;var zo=class extends hr{};zo.prototype._setValue=Al;var Vo=class extends hr{};Vo.prototype._setValue=Ll;var $o=class extends hr{};$o.prototype._setValue=Ml;var Wo=class extends hr{};Wo.prototype._setValue=Cl;var Kt=class extends Ce{setValue(e,n){this._values.set(e,n)}},tu=class extends Kt{},nu=class extends Kt{},ru=class extends Kt{},iu=class extends Kt{},su=class extends Kt{},ou=class extends Kt{},au=class extends Kt{},lu=class extends Kt{};var uu=class extends vt{constructor(e){super(e),this._offsets=new ms(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new hn(new q(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new yn(new q(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var fu=class extends ge{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var du=class extends ge{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new he([...this.type.children,new q(n,e.type,!0)]),r}};var pr=class extends Ce{};pr.prototype._setValue=Nf;var Ho=class extends pr{};Ho.prototype._setValue=xl;var Yo=class extends pr{};Yo.prototype._setValue=Il;var Ko=class extends pr{};Ko.prototype._setValue=Bl;var Qo=class extends pr{};Qo.prototype._setValue=Dl;var mr=class extends Ce{};mr.prototype._setValue=Tf;var Go=class extends mr{};Go.prototype._setValue=Nl;var Xo=class extends mr{};Xo.prototype._setValue=Tl;var Zo=class extends mr{};Zo.prototype._setValue=Ol;var Jo=class extends mr{};Jo.prototype._setValue=El;var ws=class extends ge{constructor(e){super(e),this._typeIds=new lr(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new q(n,e.type)];return this.type=new pn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},hu=class extends ws{},pu=class extends ws{constructor(e){super(e),this._offsets=new lr(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var qo=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};qo.prototype._flushPending=vs.prototype._flushPending;var ea=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var Qf=class extends C{visitNull(){return fu}visitBool(){return Gl}visitInt(){return Kt}visitInt8(){return tu}visitInt16(){return nu}visitInt32(){return ru}visitInt64(){return iu}visitUint8(){return su}visitUint16(){return ou}visitUint32(){return au}visitUint64(){return lu}visitFloat(){return xi}visitFloat16(){return Jl}visitFloat32(){return ql}visitFloat64(){return eu}visitUtf8(){return qo}visitLargeUtf8(){return ea}visitBinary(){return vs}visitLargeBinary(){return _s}visitFixedSizeBinary(){return Ro}visitDate(){return Si}visitDateDay(){return Mo}visitDateMillisecond(){return Co}visitTimestamp(){return pr}visitTimestampSecond(){return Ho}visitTimestampMillisecond(){return Yo}visitTimestampMicrosecond(){return Ko}visitTimestampNanosecond(){return Qo}visitTime(){return mr}visitTimeSecond(){return Go}visitTimeMillisecond(){return Xo}visitTimeMicrosecond(){return Zo}visitTimeNanosecond(){return Jo}visitDecimal(){return Uo}visitList(){return uu}visitStruct(){return du}visitUnion(){return ws}visitDenseUnion(){return pu}visitSparseUnion(){return hu}visitDictionary(){return Xl}visitInterval(){return Ii}visitIntervalDayTime(){return Po}visitIntervalYearMonth(){return jo}visitDuration(){return hr}visitDurationSecond(){return zo}visitDurationMillisecond(){return Vo}visitDurationMicrosecond(){return $o}visitDurationNanosecond(){return Wo}visitFixedSizeList(){return Zl}visitMap(){return cu}},uy=new Qf;var j=class extends C{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function dt(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||dt(t,e)}function yr(t,e){return t===e||dt(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function mu(t,e){return t===e||dt(t,e)&&t.precision===e.precision}function GS(t,e){return t===e||dt(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ta(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function na(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function XS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function ZS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||dt(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Rn.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||dt(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Rn.visit(t.indices,e.indices)&&Rn.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ra(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function qS(t,e){return t===e||dt(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function eb(t,e){return t===e||dt(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}j.prototype.visitNull=Bi;j.prototype.visitBool=Bi;j.prototype.visitInt=yr;j.prototype.visitInt8=yr;j.prototype.visitInt16=yr;j.prototype.visitInt32=yr;j.prototype.visitInt64=yr;j.prototype.visitUint8=yr;j.prototype.visitUint16=yr;j.prototype.visitUint32=yr;j.prototype.visitUint64=yr;j.prototype.visitFloat=mu;j.prototype.visitFloat16=mu;j.prototype.visitFloat32=mu;j.prototype.visitFloat64=mu;j.prototype.visitUtf8=Bi;j.prototype.visitLargeUtf8=Bi;j.prototype.visitBinary=Bi;j.prototype.visitLargeBinary=Bi;j.prototype.visitFixedSizeBinary=GS;j.prototype.visitDate=Gf;j.prototype.visitDateDay=Gf;j.prototype.visitDateMillisecond=Gf;j.prototype.visitTimestamp=ta;j.prototype.visitTimestampSecond=ta;j.prototype.visitTimestampMillisecond=ta;j.prototype.visitTimestampMicrosecond=ta;j.prototype.visitTimestampNanosecond=ta;j.prototype.visitTime=na;j.prototype.visitTimeSecond=na;j.prototype.visitTimeMillisecond=na;j.prototype.visitTimeMicrosecond=na;j.prototype.visitTimeNanosecond=na;j.prototype.visitDecimal=Bi;j.prototype.visitList=XS;j.prototype.visitStruct=ZS;j.prototype.visitUnion=Xf;j.prototype.visitDenseUnion=Xf;j.prototype.visitSparseUnion=Xf;j.prototype.visitDictionary=JS;j.prototype.visitInterval=Zf;j.prototype.visitIntervalDayTime=Zf;j.prototype.visitIntervalYearMonth=Zf;j.prototype.visitDuration=ra;j.prototype.visitDurationSecond=ra;j.prototype.visitDurationMillisecond=ra;j.prototype.visitDurationMicrosecond=ra;j.prototype.visitDurationNanosecond=ra;j.prototype.visitFixedSizeList=qS;j.prototype.visitMap=eb;var Rn=new j;function Di(t,e){return Rn.compareSchemas(t,e)}function cy(t,e){return Rn.compareFields(t,e)}function fy(t,e){return Rn.visit(t,e)}function bi(t){let e=t.type,n=new(uy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function yu(t,e){return tb(t,e.map(n=>n.data.concat()))}function tb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((d,y)=>Math.max(d,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Q({type:new he(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(d=>new Oe(t,d))]}function nb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let d=t[a];t[a]=d.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Q({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var dy,_t=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new oe([]),this._offsets=[0],this;let i,s;e[0]instanceof oe&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Oe)return[l];if(l instanceof t)return l.batches;if(l instanceof ie){if(l.type instanceof he)return[new Oe(new oe(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new te([l[v]])),d=i??new oe(u.map((v,w)=>new q(String(v),c[w].type,c[w].nullable))),[,y]=yu(d,c);return y.length===0?[new Oe(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new oe([]),!(i instanceof oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?hs.visit(new te(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +return true;`)}function HS(t){return typeof t!="bigint"?fn(t):`${fn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function ly(t,e=0){return t.length>=e?t.subarray(0,e):uo(new t.constructor(e),t,0)}var vn=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=ly(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=ly(this.buffer,e)}},lr=class extends vn{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ps=class extends lr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ge=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ps,n&&n.length>0&&(this._isValid=ay(n))}toVector(){return new te([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:d}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=d?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),Q({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ge.prototype.length=1;ge.prototype.stride=1;ge.prototype.children=null;ge.prototype.finished=!1;ge.prototype.nullValues=null;ge.prototype._isValid=()=>!0;var Ce=class extends ge{constructor(e){super(e),this._values=new lr(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},vt=class extends ge{constructor(e){super(e),this._pendingLength=0,this._offsets=new ms(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Mn?n[Vr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Mt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new gt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var oe=class t{constructor(e=[],n,r,i=ae.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Yl(Yl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Yl(Yl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};oe.prototype.fields=null;oe.prototype.metadata=null;oe.prototype.dictionaries=null;var q=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};q.prototype.type=null;q.prototype.name=null;q.prototype.nullable=null;q.prototype.metadata=null;function Yl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var YS=hi,KS=Ft,ur=class{static decode(e){e=new KS(V(e));let n=Mt.getRootAsFooter(e),r=oe.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new YS,r=oe.encode(n,e.schema);Mt.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())cr.encode(n,o);let i=n.endVector();Mt.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())cr.encode(n,o);let s=n.endVector();return Mt.startFooter(n),Mt.addSchema(n,r),Mt.addVersion(n,ae.V5),Mt.addRecordBatches(n,i),Mt.addDictionaries(n,s),Mt.finishFooterBuffer(n,Mt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=ae.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(me);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return O(this,void 0,void 0,function*(){return yield this.abort(e),me})}return(e){return O(this,void 0,void 0,function*(){return yield this.close(),me})}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(me)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Cn=class extends Kl{write(e){if((e=V(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ao(this.toUint8Array(!0)):this.toUint8Array(!1).then(ao)}toUint8Array(e=!1){return e?Et(this._values)[0]:O(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=rn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Et(o,a)[0]})}},Un=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Kt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Cn?this.source=new fr(Ge.fromAsyncIterable(e)):nl(e)?this.source=new fr(Ge.fromNodeStream(e)):lo(e)?this.source=new fr(Ge.fromDOMStream(e)):el(e)?this.source=new fr(Ge.fromDOMStream(e.body)):sn(e)?this.source=new fr(Ge.fromIterable(e)):Ot(e)?this.source=new fr(Ge.fromAsyncIterable(e)):Wt(e)&&(this.source=new fr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||me)}return(e){return Object.create(this.source.return&&this.source.return(e)||me)}},fr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return O(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return O(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||me;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return O(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||me;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var Fo=class extends Un{constructor(e,n){super(),this.position=0,this.buffer=V(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eko,Int128:()=>Ao,Int64:()=>dr,Uint64:()=>De});function ys(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var gs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ko=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ys(this.buffer[3])} ${ys(this.buffer[2])} ${ys(this.buffer[1])} ${ys(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Ql=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return E.isTimestamp(e)?J(Uint8Array,dr.convertArray(r[n])):(E.isInt(e)||E.isTime(e))&&e.bitWidth===64||E.isDuration(e)?J(Uint8Array,dr.convertArray(r[n])):E.isDate(e)&&e.unit===Ae.MILLISECOND?J(Uint8Array,dr.convertArray(r[n])):E.isDecimal(e)?J(Uint8Array,Ao.convertArray(r[n])):E.isBinary(e)||E.isLargeBinary(e)||E.isFixedSizeBinary(e)?QS(r[n]):E.isBool(e)?gi(r[n]):E.isUtf8(e)||E.isLargeUtf8(e)?On(r[n].join("")):J(Uint8Array,J(e.ArrayType,r[n].map(i=>+i)))}};function QS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var vs=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var _s=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Gl=class extends ge{constructor(e){super(e),this._values=new ps}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Ce{};Si.prototype._setValue=Df;var Mo=class extends Si{};Mo.prototype._setValue=Sl;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Ce{};Uo.prototype._setValue=Of;var Xl=class extends ge{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new At(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Ro=class extends Ce{};Ro.prototype._setValue=Bf;var Zl=class extends ge{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new mn(this.type.listSize,new q(n,e.type,!0)),r}};var xi=class extends Ce{setValue(e,n){this._values.set(e,n)}},Jl=class extends xi{setValue(e,n){super.setValue(e,Bo(n))}},ql=class extends xi{},eu=class extends xi{};var Ii=class extends Ce{};Ii.prototype._setValue=Ef;var Po=class extends Ii{};Po.prototype._setValue=Fl;var jo=class extends Ii{};jo.prototype._setValue=kl;var hr=class extends Ce{};hr.prototype._setValue=Ff;var zo=class extends hr{};zo.prototype._setValue=Al;var Vo=class extends hr{};Vo.prototype._setValue=Ll;var $o=class extends hr{};$o.prototype._setValue=Ml;var Wo=class extends hr{};Wo.prototype._setValue=Cl;var Qt=class extends Ce{setValue(e,n){this._values.set(e,n)}},tu=class extends Qt{},nu=class extends Qt{},ru=class extends Qt{},iu=class extends Qt{},su=class extends Qt{},ou=class extends Qt{},au=class extends Qt{},lu=class extends Qt{};var uu=class extends vt{constructor(e){super(e),this._offsets=new ms(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new hn(new q(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new yn(new q(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var fu=class extends ge{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var du=class extends ge{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new pe([...this.type.children,new q(n,e.type,!0)]),r}};var pr=class extends Ce{};pr.prototype._setValue=Nf;var Ho=class extends pr{};Ho.prototype._setValue=xl;var Yo=class extends pr{};Yo.prototype._setValue=Il;var Ko=class extends pr{};Ko.prototype._setValue=Bl;var Qo=class extends pr{};Qo.prototype._setValue=Dl;var mr=class extends Ce{};mr.prototype._setValue=Tf;var Go=class extends mr{};Go.prototype._setValue=Nl;var Xo=class extends mr{};Xo.prototype._setValue=Tl;var Zo=class extends mr{};Zo.prototype._setValue=Ol;var Jo=class extends mr{};Jo.prototype._setValue=El;var ws=class extends ge{constructor(e){super(e),this._typeIds=new lr(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new q(n,e.type)];return this.type=new pn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},hu=class extends ws{},pu=class extends ws{constructor(e){super(e),this._offsets=new lr(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var qo=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};qo.prototype._flushPending=vs.prototype._flushPending;var ea=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var Qf=class extends C{visitNull(){return fu}visitBool(){return Gl}visitInt(){return Qt}visitInt8(){return tu}visitInt16(){return nu}visitInt32(){return ru}visitInt64(){return iu}visitUint8(){return su}visitUint16(){return ou}visitUint32(){return au}visitUint64(){return lu}visitFloat(){return xi}visitFloat16(){return Jl}visitFloat32(){return ql}visitFloat64(){return eu}visitUtf8(){return qo}visitLargeUtf8(){return ea}visitBinary(){return vs}visitLargeBinary(){return _s}visitFixedSizeBinary(){return Ro}visitDate(){return Si}visitDateDay(){return Mo}visitDateMillisecond(){return Co}visitTimestamp(){return pr}visitTimestampSecond(){return Ho}visitTimestampMillisecond(){return Yo}visitTimestampMicrosecond(){return Ko}visitTimestampNanosecond(){return Qo}visitTime(){return mr}visitTimeSecond(){return Go}visitTimeMillisecond(){return Xo}visitTimeMicrosecond(){return Zo}visitTimeNanosecond(){return Jo}visitDecimal(){return Uo}visitList(){return uu}visitStruct(){return du}visitUnion(){return ws}visitDenseUnion(){return pu}visitSparseUnion(){return hu}visitDictionary(){return Xl}visitInterval(){return Ii}visitIntervalDayTime(){return Po}visitIntervalYearMonth(){return jo}visitDuration(){return hr}visitDurationSecond(){return zo}visitDurationMillisecond(){return Vo}visitDurationMicrosecond(){return $o}visitDurationNanosecond(){return Wo}visitFixedSizeList(){return Zl}visitMap(){return cu}},uy=new Qf;var j=class extends C{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function dt(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||dt(t,e)}function yr(t,e){return t===e||dt(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function mu(t,e){return t===e||dt(t,e)&&t.precision===e.precision}function GS(t,e){return t===e||dt(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ta(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function na(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function XS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function ZS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||dt(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Rn.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||dt(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Rn.visit(t.indices,e.indices)&&Rn.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ra(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function qS(t,e){return t===e||dt(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function eb(t,e){return t===e||dt(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}j.prototype.visitNull=Bi;j.prototype.visitBool=Bi;j.prototype.visitInt=yr;j.prototype.visitInt8=yr;j.prototype.visitInt16=yr;j.prototype.visitInt32=yr;j.prototype.visitInt64=yr;j.prototype.visitUint8=yr;j.prototype.visitUint16=yr;j.prototype.visitUint32=yr;j.prototype.visitUint64=yr;j.prototype.visitFloat=mu;j.prototype.visitFloat16=mu;j.prototype.visitFloat32=mu;j.prototype.visitFloat64=mu;j.prototype.visitUtf8=Bi;j.prototype.visitLargeUtf8=Bi;j.prototype.visitBinary=Bi;j.prototype.visitLargeBinary=Bi;j.prototype.visitFixedSizeBinary=GS;j.prototype.visitDate=Gf;j.prototype.visitDateDay=Gf;j.prototype.visitDateMillisecond=Gf;j.prototype.visitTimestamp=ta;j.prototype.visitTimestampSecond=ta;j.prototype.visitTimestampMillisecond=ta;j.prototype.visitTimestampMicrosecond=ta;j.prototype.visitTimestampNanosecond=ta;j.prototype.visitTime=na;j.prototype.visitTimeSecond=na;j.prototype.visitTimeMillisecond=na;j.prototype.visitTimeMicrosecond=na;j.prototype.visitTimeNanosecond=na;j.prototype.visitDecimal=Bi;j.prototype.visitList=XS;j.prototype.visitStruct=ZS;j.prototype.visitUnion=Xf;j.prototype.visitDenseUnion=Xf;j.prototype.visitSparseUnion=Xf;j.prototype.visitDictionary=JS;j.prototype.visitInterval=Zf;j.prototype.visitIntervalDayTime=Zf;j.prototype.visitIntervalYearMonth=Zf;j.prototype.visitDuration=ra;j.prototype.visitDurationSecond=ra;j.prototype.visitDurationMillisecond=ra;j.prototype.visitDurationMicrosecond=ra;j.prototype.visitDurationNanosecond=ra;j.prototype.visitFixedSizeList=qS;j.prototype.visitMap=eb;var Rn=new j;function Di(t,e){return Rn.compareSchemas(t,e)}function cy(t,e){return Rn.compareFields(t,e)}function fy(t,e){return Rn.visit(t,e)}function bi(t){let e=t.type,n=new(uy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function yu(t,e){return tb(t,e.map(n=>n.data.concat()))}function tb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((d,y)=>Math.max(d,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Q({type:new pe(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(d=>new Oe(t,d))]}function nb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let d=t[a];t[a]=d.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Q({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var dy,_t=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new oe([]),this._offsets=[0],this;let i,s;e[0]instanceof oe&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Oe)return[l];if(l instanceof t)return l.batches;if(l instanceof ie){if(l.type instanceof pe)return[new Oe(new oe(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new te([l[v]])),d=i??new oe(u.map((v,w)=>new q(String(v),c[w].type,c[w].nullable))),[,y]=yu(d,c);return y.length===0?[new Oe(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new oe([]),!(i instanceof oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?hs.visit(new te(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){let n=this.schema,r=this.data.concat(e.flatMap(({data:i})=>i));return new t(n,r.map(i=>new Oe(n,i)))}slice(e,n){let r=this.schema;[e,n]=Do({length:this.numRows},e,n);let i=Vl(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Oe(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new te(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=yu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,d]=a,y=n.findIndex(v=>v.name===l.name);return~y?d[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...yu(s,o))}};dy=Symbol.toStringTag;_t[dy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ds(Oo),t.get=ds(Me.getVisitFn(p.Struct)),t.set=$l(Xe.getVisitFn(p.Struct)),t.indexOf=Wl(vi.getVisitFn(p.Struct)),"Table"))(_t.prototype);var py,Oe=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof oe))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new he(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=e,!(this.data instanceof ie))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=hy(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=q.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new oe(r),a=Q({type:new he(r),length:s,children:i,nullCount:0});[this.schema,this.data]=hy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=my(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Me.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return hs.visit(new te([this.data]))}toArray(){return[...this]}concat(...e){return new _t(this.schema,[this,...e])}slice(e,n){let[r]=new te([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,Q({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Q({type:new he(n.fields),length:this.numRows,children:r});return new t(n,i)}};py=Symbol.toStringTag;Oe[py]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Oe.prototype);function hy(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Q({type:new he(i),length:n,children:s})]}function my(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sQ({type:i.type})),r=Q({type:new he(e.fields),nullCount:0,children:n});super(e,r)}};var _n=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):ee.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,ee.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends C{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return ln.startInt(n),ln.addBitWidth(n,e.bitWidth),ln.addIsSigned(n,e.isSigned),ln.endInt(n)}visitFloat(e,n){return Ur.startFloatingPoint(n),Ur.addPrecision(n,e.precision),Ur.endFloatingPoint(n)}visitBinary(e,n){return mo.startBinary(n),mo.endBinary(n)}visitLargeBinary(e,n){return go.startLargeBinary(n),go.endLargeBinary(n)}visitBool(e,n){return yo.startBool(n),yo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitLargeUtf8(e,n){return vo.startLargeUtf8(n),vo.endLargeUtf8(n)}visitDecimal(e,n){return An.startDecimal(n),An.addScale(n,e.scale),An.addPrecision(n,e.precision),An.addBitWidth(n,e.bitWidth),An.endDecimal(n)}visitDate(e,n){return Ar.startDate(n),Ar.addUnit(n,e.unit),Ar.endDate(n)}visitTime(e,n){return Kn.startTime(n),Kn.addUnit(n,e.unit),Kn.addBitWidth(n,e.bitWidth),Kn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Qn.startTimestamp(n),Qn.addUnit(n,e.unit),r!==void 0&&Qn.addTimezone(n,r),Qn.endTimestamp(n)}visitInterval(e,n){return Rr.startInterval(n),Rr.addUnit(n,e.unit),Rr.endInterval(n)}visitDuration(e,n){return Lr.startDuration(n),Lr.addUnit(n,e.unit),Lr.endDuration(n)}visitList(e,n){return _o.startList(n),_o.endList(n)}visitStruct(e,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(e,n){un.startTypeIdsVector(n,e.typeIds.length);let r=un.createTypeIdsVector(n,e.typeIds);return un.startUnion(n),un.addMode(n,e.mode),un.addTypeIds(n,r),un.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return kn.startDictionaryEncoding(n),kn.addId(n,BigInt(e.id)),kn.addIsOrdered(n,e.isOrdered),r!==void 0&&kn.addIndexType(n,r),kn.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Mr.startFixedSizeBinary(n),Mr.addByteWidth(n,e.byteWidth),Mr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Cr.startFixedSizeList(n),Cr.addListSize(n,e.listSize),Cr.endFixedSizeList(n)}visitMap(e,n){return Pr.startMap(n),Pr.addKeysSorted(n,e.keysSorted),Pr.endMap(n)}},gu=new Jf;function _y(t,e=new Map){return new oe(ib(t,e),vu(t.metadata),e)}function qf(t){return new Ze(t.count,Sy(t.columns),by(t.columns))}function wy(t){return new St(qf(t.data),t.id,t.isDelta)}function ib(t,e){return(t.fields||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function yy(t,e){return(t.children||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function Sy(t){return(t||[]).reduce((e,n)=>[...e,new Qt(n.count,sb(n.VALIDITY)),...Sy(n.children)],[])}function by(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function xy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=vy(t,yy(t,e)),i=new q(t.name,o,t.nullable,vu(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?gy(r):new Ln,a=new At(e.get(n),r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))):(r=(r=s.indexType)?gy(r):new Ln,e.set(n,o=vy(t,yy(t,e))),a=new At(o,r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))),i||null}function vu(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function gy(t){return new Ve(t.isSigned,t.bitWidth)}function vy(t,e){let n=t.type.name;switch(n){case"NONE":return new ft;case"null":return new ft;case"binary":return new Gn;case"largebinary":return new Xn;case"utf8":return new Zn;case"largeutf8":return new Jn;case"bool":return new qn;case"list":return new hn((e||[])[0]);case"struct":return new he(e||[]);case"struct_":return new he(e||[])}switch(n){case"int":{let r=t.type;return new Ve(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Ht(ce[r.precision])}case"decimal":{let r=t.type;return new er(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new tr(Ae[r.unit])}case"time":{let r=t.type;return new nr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new rr(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new ir(He[r.unit])}case"duration":{let r=t.type;return new sr(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new pn(de[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new or(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new mn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new yn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ob=hi,ab=Ft,bt=class t{static fromJSON(e,n){let r=new t(0,ae.V5,n);return r._createHeader=lb(e,n),r}static decode(e){e=new ab(V(e));let n=_n.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=ub(n,s),o}static encode(e){let n=new ob,r=-1;return e.isSchema()?r=oe.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=St.encode(n,e.header())),_n.startMessage(n),_n.addVersion(n,ae.V5),_n.addHeader(n,r),_n.addHeaderType(n,e.headerType),_n.addBodyLength(n,BigInt(e.bodyLength)),_n.finishMessageBuffer(n,_n.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof oe)return new t(0,ae.V5,ee.Schema,e);if(e instanceof Ze)return new t(n,ae.V5,ee.RecordBatch,e);if(e instanceof St)return new t(n,ae.V5,ee.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===ee.Schema}isRecordBatch(){return this.headerType===ee.RecordBatch}isDictionaryBatch(){return this.headerType===ee.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},St=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},wt=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Qt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function lb(t,e){return(()=>{switch(e){case ee.Schema:return oe.fromJSON(t);case ee.RecordBatch:return Ze.fromJSON(t);case ee.DictionaryBatch:return St.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}function ub(t,e){return(()=>{switch(e){case ee.Schema:return oe.decode(t.header(new gt),new Map,t.version());case ee.RecordBatch:return Ze.decode(t.header(new kt),t.version());case ee.DictionaryBatch:return St.decode(t.header(new Yn),t.version())}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}q.encode=wb;q.decode=vb;q.fromJSON=xy;oe.encode=_b;oe.decode=cb;oe.fromJSON=_y;Ze.encode=Sb;Ze.decode=fb;Ze.fromJSON=qf;St.encode=bb;St.decode=db;St.fromJSON=wy;Qt.encode=xb;Qt.decode=pb;wt.encode=Ib;wt.decode=hb;function cb(t,e=new Map,n=ae.V5){let r=gb(t,e);return new oe(r,_u(t),e,n)}function fb(t,e=ae.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),mb(t),yb(t,e))}function db(t,e=ae.V5){return new St(Ze.decode(t.data(),e),t.id(),t.isDelta())}function hb(t){return new wt(t.offset(),t.length())}function pb(t){return new Qt(t.length(),t.nullCount())}function mb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rq.encode(t,s));gt.startFieldsVector(t,n.length);let r=gt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?gt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return ze.startKeyValue(t),ze.addKey(t,a),ze.addValue(t,l),ze.endKeyValue(t)})):-1;return gt.startSchema(t),gt.addFields(t,r),gt.addEndianness(t,Bb?kr.Little:kr.Big),i!==-1&>.addCustomMetadata(t,i),gt.endSchema(t)}function wb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;E.isDictionary(s)?(o=s.dictionary.typeId,i=gu.visit(s,t),r=gu.visit(s.dictionary,t)):r=gu.visit(s,t);let a=(s.children||[]).map(c=>q.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,d])=>{let y=t.createString(`${c}`),v=t.createString(`${d}`);return ze.startKeyValue(t),ze.addKey(t,y),ze.addValue(t,v),ze.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function Sb(t,e){let n=e.nodes||[],r=e.buffers||[];kt.startNodesVector(t,n.length);for(let o of n.slice().reverse())Qt.encode(t,o);let i=t.endVector();kt.startBuffersVector(t,r.length);for(let o of r.slice().reverse())wt.encode(t,o);let s=t.endVector();return kt.startRecordBatch(t),kt.addLength(t,BigInt(e.length)),kt.addNodes(t,i),kt.addBuffers(t,s),kt.endRecordBatch(t)}function bb(t,e){let n=Ze.encode(t,e.data);return Yn.startDictionaryBatch(t),Yn.addId(t,BigInt(e.id)),Yn.addIsDelta(t,e.isDelta),Yn.addData(t,n),Yn.endDictionaryBatch(t)}function xb(t,e){return rs.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Ib(t,e){return ns.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Bb=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${ee[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${ee[t]} Message is null or length 0.`,Ny=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Ty=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,Ss=class{constructor(e){this.source=e instanceof Un?e:new Un(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?pe:e.value===-1&&(e=this.readMetadataLength()).done?pe:(e=this.readMetadata(e.value)).done?pe:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=V(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=ee.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},wu=4,ed="ARROW1",bs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Za(e)?Nb(e):qa(e)?Eb(e):Ot(e)?O(this,void 0,void 0,function*(){return yield t.from(yield e)}):el(e)||lo(e)||nl(e)||$t(e)?Ob(new Yt(e)):Tb(new Un(e))}static readAll(e){return e instanceof t?e.isSync()?Ey(e):Fy(e):Za(e)||ArrayBuffer.isView(e)||sn(e)||Ja(e)?Ey(e):Fy(e)}},gr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Tt(this,arguments,function*(){yield Z(yield*es(rn(this[Symbol.iterator]())))})}},Ti=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return O(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=rn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends gr{constructor(e){super(e),this._impl=e}},bu=class extends Ti{constructor(e){super(e),this._impl=e}},xu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=Q({type:new he(this.schema.fields),length:e.length,children:r});return new Oe(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new te(u)):new te(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Is=class extends xu{constructor(e,n){super(n),this._reader=Za(e)?new sa(this._handle=e):new Ss(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):pe}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):pe}next(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Bs=class extends xu{constructor(e,n){super(n),this._reader=new ia(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):pe})}return(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):pe})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return pe;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Iu=class extends Is{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof Fo?e:new Fo(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return ur.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return O(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return O(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return ur.decode(i)})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Su(e)?new Oi(new Iu(t.read())):new gr(new Is(t)):new gr(new Is((function*(){})()))}function Ob(t){return O(this,void 0,void 0,function*(){let e=yield t.peek(xs+7&-8);return e&&e.byteLength>=4?Su(e)?new Oi(new Iu(yield t.read())):new Ti(new Bs(t)):new Ti(new Bs((function(){return Tt(this,arguments,function*(){})})()))})}function Eb(t){return O(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new Wr(t,e);return e>=Oy&&Su(yield n.readAt(0,xs+7&-8))?new bu(new id(n)):new Ti(new Bs(n))})}var we=class t extends C{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Oe?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof te)return this.visitMany(e.data),this;let{type:n}=e;if(!E.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(E.isUnion(n))this.nodes.push(new Qt(r,0));else{let{nullCount:i}=e;E.isNull(n)||wn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Qt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function wn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new wt(this._byteLength,e)),this._byteLength+=e,this}function Fb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(wn.call(this,i),n.mode===de.Sparse)return od.call(this,t);if(n.mode===de.Dense){if(t.offset<=0)return wn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,d=-1;++d{let d=n.typeIds[c],y=a[d],v=l[d];return u.slice(y,Math.min(r,v))}))}}return this}function kb(t){let e;return t.nullCount>=t.length?wn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?wn.call(this,yi(t.offset,t.length,e)):wn.call(this,gi(t.values))}function vr(t){return wn.call(this,t.values.subarray(0,t.length*t.stride))}function Bu(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return wn.call(this,il(-i,e+1,r)),wn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return wn.call(this,il(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}we.prototype.visitBool=kb;we.prototype.visitInt=vr;we.prototype.visitFloat=vr;we.prototype.visitUtf8=Bu;we.prototype.visitLargeUtf8=Bu;we.prototype.visitBinary=Bu;we.prototype.visitLargeBinary=Bu;we.prototype.visitFixedSizeBinary=vr;we.prototype.visitDate=vr;we.prototype.visitTimestamp=vr;we.prototype.visitTime=vr;we.prototype.visitDecimal=vr;we.prototype.visitList=ad;we.prototype.visitStruct=od;we.prototype.visitUnion=Fb;we.prototype.visitInterval=vr;we.prototype.visitDuration=vr;we.prototype.visitFixedSizeList=ad;we.prototype.visitMap=ad;var Ei=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Cn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ct(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ot(e)?e.then(n=>this.writeAll(n)):$t(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Cn?this._sink=e:(this._sink=new Cn,e&&Qp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Gp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof _t&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Oe&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Oe?e instanceof Ni||this._writeRecordBatch(e):e instanceof _t?this.writeAll(e.batches):sn(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=bt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===ee.RecordBatch?this._recordBatchBlocks.push(new cr(a,e.bodyLength,this._position)):e.headerType===ee.DictionaryBatch&&this._dictionaryBlocks.push(new cr(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=V(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(bt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=we.assemble(e),o=new Ze(e.numRows,r,i),a=bt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=we.assemble(new te([e])),l=new Ze(e.length,s,o),u=new St(l,n,r),c=bt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):$t(e)?ud(r,e):ld(r,e)}},aa=class t extends Ei{static writeAll(e){let n=new t;return Ot(e)?e.then(r=>n.writeAll(r)):$t(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=ur.encode(new ur(e,ae.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof _t&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return O(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=rn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function Ay(t,e){if($t(t))return Lb(t,e);if(sn(t))return Ab(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Ab(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return O(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return O(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Cy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Yp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:My;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:My}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},My=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Du(t,e){let n=new Cn,r=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Ct.from(n)).open(e)})}function o(a,l){return O(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Nu(t,e){let n=new this(t),r=new Yt(n),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function la(t){let e=Ct.from(t);return Ot(e)?e.then(n=>la(n)):e.isAsync()?e.readAll().then(n=>new _t(n)):new _t(e.readAll())}var Cb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:cy,compareTypes:fy});Ge.toDOMStream=Ay;ge.throughDOM=Cy;Ct.throughDOM=Du;Oi.throughDOM=Du;gr.throughDOM=Du;Ei.throughDOM=Nu;aa.throughDOM=Nu;oa.throughDOM=Nu;var Ub=Object.create,Rb=Object.getPrototypeOf,Vd=Object.defineProperty,Pb=Object.getOwnPropertyNames,jb=Object.prototype.hasOwnProperty;function zb(t){return this[t]}var Vb,$b,ye=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?Vb??=new WeakMap:$b??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Ub(Rb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of Pb(t))jb.call(o,a)||Vd(o,a,{get:zb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},so=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wb=t=>t;function Hb(t,e){this[t]=Wb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Hb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),bv={};Qh(bv,{Children:()=>Ev,Component:()=>Fv,Fragment:()=>kv,Profiler:()=>Av,PureComponent:()=>Lv,StrictMode:()=>Mv,Suspense:()=>Cv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Uv,act:()=>Rv,cloneElement:()=>Xb,createContext:()=>Zb,createElement:()=>Pv,createFactory:()=>Jb,createRef:()=>qb,forwardRef:()=>ex,isValidElement:()=>jv,lazy:()=>tx,memo:()=>nx,startTransition:()=>rx,unstable_act:()=>zv,useCallback:()=>ix,useContext:()=>sx,useDebugValue:()=>ox,useDeferredValue:()=>ax,useEffect:()=>lx,useId:()=>ux,useImperativeHandle:()=>cx,useInsertionEffect:()=>fx,useLayoutEffect:()=>dx,useMemo:()=>hx,useReducer:()=>px,useRef:()=>mx,useState:()=>yx,useSyncExternalStore:()=>gx,useTransition:()=>vx,version:()=>_x});function Yb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ds(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Uy(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function xv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{oo=Symbol.for("react.element"),Iv=Symbol.for("react.portal"),Py=Symbol.for("react.fragment"),jy=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),Dv=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),Vy=Symbol.for("react.suspense"),Tv=Symbol.for("react.memo"),Ov=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ds.prototype.isReactComponent={},Ds.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ds.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Uy.prototype=Ds.prototype,Ou=fd.prototype=new Uy,Ou.constructor=fd,Hd(Ou,Ds.prototype),Ou.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,cc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ia={transition:null},$y={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ia,ReactCurrentOwner:cc},Ev={map:Tu,forEach:function(t,e,n){Tu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Tu(t,function(){e++}),e},toArray:function(t){return Tu(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Fv=Ds,kv=Py,Av=zy,Lv=fd,Mv=jy,Cv=Vy,Uv=$y,Rv=Ry,Pv=xv,jv=$d,zv=Ry}),nn=so(function(t,e){wx(),e.exports=bv}),Sx=so(function(t){function e(T,M){var B=T.length;T.push(M);e:for(;0>>1,X=T[b];if(0>>1;bi(uf,B))cii(Xa,uf)?(T[b]=Xa,T[ci]=B,b=ci):(T[b]=uf,T[Tn]=B,b=Tn);else if(cii(Xa,B))T[b]=Xa,T[ci]=B,b=ci;else break e}}return M}function i(T,M){var B=T.sortIndex-M.sortIndex;return B!==0?B:T.id-M.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,d=null,y=3,v=!1,w=!1,I=!1,Y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(T){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=T)r(u),M.sortIndex=M.expirationTime,e(l,M);else break;M=n(u)}}function g(T){if(I=!1,m(T),!w)if(n(l)!==null)w=!0,Pe(_);else{var M=n(u);M!==null&&Fr(g,M.startTime-T)}}function _(T,M){w=!1,I&&(I=!1,h(S),S=-1),v=!0;var B=y;try{for(m(M),d=n(l);d!==null&&(!(d.expirationTime>M)||T&&!ue());){var b=d.callback;if(typeof b=="function"){d.callback=null,y=d.priorityLevel;var X=b(d.expirationTime<=M);M=t.unstable_now(),typeof X=="function"?d.callback=X:d===n(l)&&r(l),m(M)}else r(l);d=n(l)}if(d!==null)var Be=!0;else{var Tn=n(u);Tn!==null&&Fr(g,Tn.startTime-M),Be=!1}return Be}finally{d=null,y=B,v=!1}}var D=!1,N=null,S=-1,K=5,L=-1;function ue(){return!(t.unstable_now()-LT||125b?(T.sortIndex=B,e(u,T),n(l)===null&&T===n(u)&&(I?(h(S),S=-1):I=!0,Fr(g,B-b))):(T.sortIndex=X,e(l,T),w||v||(w=!0,Pe(_))),T},t.unstable_shouldYield=ue,t.unstable_wrapCallback=function(T){var M=y;return function(){var B=y;y=M;try{return T.apply(this,arguments)}finally{y=B}}}}),bx=so(function(t,e){var n=ye(Sx());e.exports=n}),Vv={};Qh(Vv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>G_,createPortal:()=>I1,createRoot:()=>B1,findDOMNode:()=>D1,flushSync:()=>N1,hydrate:()=>T1,hydrateRoot:()=>O1,render:()=>E1,unmountComponentAtNode:()=>F1,unstable_batchedUpdates:()=>X_,unstable_renderSubtreeIntoContainer:()=>k1,version:()=>A1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Ix(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ht(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=Ye.hasOwnProperty(e)?Ye[e]:null;(i!==null?i.type!==0:r||!(2i));return new t(n,r.map(i=>new Oe(n,i)))}slice(e,n){let r=this.schema;[e,n]=Do({length:this.numRows},e,n);let i=Vl(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Oe(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new te(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=yu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,d]=a,y=n.findIndex(v=>v.name===l.name);return~y?d[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...yu(s,o))}};dy=Symbol.toStringTag;_t[dy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ds(Oo),t.get=ds(Me.getVisitFn(p.Struct)),t.set=$l(Xe.getVisitFn(p.Struct)),t.indexOf=Wl(vi.getVisitFn(p.Struct)),"Table"))(_t.prototype);var py,Oe=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof oe))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new pe(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=e,!(this.data instanceof ie))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=hy(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=q.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new oe(r),a=Q({type:new pe(r),length:s,children:i,nullCount:0});[this.schema,this.data]=hy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=my(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Me.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return hs.visit(new te([this.data]))}toArray(){return[...this]}concat(...e){return new _t(this.schema,[this,...e])}slice(e,n){let[r]=new te([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,Q({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Q({type:new pe(n.fields),length:this.numRows,children:r});return new t(n,i)}};py=Symbol.toStringTag;Oe[py]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Oe.prototype);function hy(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Q({type:new pe(i),length:n,children:s})]}function my(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sQ({type:i.type})),r=Q({type:new pe(e.fields),nullCount:0,children:n});super(e,r)}};var _n=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):ee.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,ee.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends C{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return ln.startInt(n),ln.addBitWidth(n,e.bitWidth),ln.addIsSigned(n,e.isSigned),ln.endInt(n)}visitFloat(e,n){return Ur.startFloatingPoint(n),Ur.addPrecision(n,e.precision),Ur.endFloatingPoint(n)}visitBinary(e,n){return mo.startBinary(n),mo.endBinary(n)}visitLargeBinary(e,n){return go.startLargeBinary(n),go.endLargeBinary(n)}visitBool(e,n){return yo.startBool(n),yo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitLargeUtf8(e,n){return vo.startLargeUtf8(n),vo.endLargeUtf8(n)}visitDecimal(e,n){return An.startDecimal(n),An.addScale(n,e.scale),An.addPrecision(n,e.precision),An.addBitWidth(n,e.bitWidth),An.endDecimal(n)}visitDate(e,n){return Ar.startDate(n),Ar.addUnit(n,e.unit),Ar.endDate(n)}visitTime(e,n){return Kn.startTime(n),Kn.addUnit(n,e.unit),Kn.addBitWidth(n,e.bitWidth),Kn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Qn.startTimestamp(n),Qn.addUnit(n,e.unit),r!==void 0&&Qn.addTimezone(n,r),Qn.endTimestamp(n)}visitInterval(e,n){return Rr.startInterval(n),Rr.addUnit(n,e.unit),Rr.endInterval(n)}visitDuration(e,n){return Lr.startDuration(n),Lr.addUnit(n,e.unit),Lr.endDuration(n)}visitList(e,n){return _o.startList(n),_o.endList(n)}visitStruct(e,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(e,n){un.startTypeIdsVector(n,e.typeIds.length);let r=un.createTypeIdsVector(n,e.typeIds);return un.startUnion(n),un.addMode(n,e.mode),un.addTypeIds(n,r),un.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return kn.startDictionaryEncoding(n),kn.addId(n,BigInt(e.id)),kn.addIsOrdered(n,e.isOrdered),r!==void 0&&kn.addIndexType(n,r),kn.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Mr.startFixedSizeBinary(n),Mr.addByteWidth(n,e.byteWidth),Mr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Cr.startFixedSizeList(n),Cr.addListSize(n,e.listSize),Cr.endFixedSizeList(n)}visitMap(e,n){return Pr.startMap(n),Pr.addKeysSorted(n,e.keysSorted),Pr.endMap(n)}},gu=new Jf;function _y(t,e=new Map){return new oe(ib(t,e),vu(t.metadata),e)}function qf(t){return new Ze(t.count,Sy(t.columns),by(t.columns))}function wy(t){return new St(qf(t.data),t.id,t.isDelta)}function ib(t,e){return(t.fields||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function yy(t,e){return(t.children||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function Sy(t){return(t||[]).reduce((e,n)=>[...e,new Gt(n.count,sb(n.VALIDITY)),...Sy(n.children)],[])}function by(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function xy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=vy(t,yy(t,e)),i=new q(t.name,o,t.nullable,vu(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?gy(r):new Ln,a=new At(e.get(n),r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))):(r=(r=s.indexType)?gy(r):new Ln,e.set(n,o=vy(t,yy(t,e))),a=new At(o,r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))),i||null}function vu(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function gy(t){return new Ve(t.isSigned,t.bitWidth)}function vy(t,e){let n=t.type.name;switch(n){case"NONE":return new ft;case"null":return new ft;case"binary":return new Gn;case"largebinary":return new Xn;case"utf8":return new Zn;case"largeutf8":return new Jn;case"bool":return new qn;case"list":return new hn((e||[])[0]);case"struct":return new pe(e||[]);case"struct_":return new pe(e||[])}switch(n){case"int":{let r=t.type;return new Ve(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Yt(ce[r.precision])}case"decimal":{let r=t.type;return new er(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new tr(Ae[r.unit])}case"time":{let r=t.type;return new nr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new rr(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new ir(He[r.unit])}case"duration":{let r=t.type;return new sr(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new pn(de[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new or(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new mn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new yn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ob=hi,ab=Ft,bt=class t{static fromJSON(e,n){let r=new t(0,ae.V5,n);return r._createHeader=lb(e,n),r}static decode(e){e=new ab(V(e));let n=_n.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=ub(n,s),o}static encode(e){let n=new ob,r=-1;return e.isSchema()?r=oe.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=St.encode(n,e.header())),_n.startMessage(n),_n.addVersion(n,ae.V5),_n.addHeader(n,r),_n.addHeaderType(n,e.headerType),_n.addBodyLength(n,BigInt(e.bodyLength)),_n.finishMessageBuffer(n,_n.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof oe)return new t(0,ae.V5,ee.Schema,e);if(e instanceof Ze)return new t(n,ae.V5,ee.RecordBatch,e);if(e instanceof St)return new t(n,ae.V5,ee.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===ee.Schema}isRecordBatch(){return this.headerType===ee.RecordBatch}isDictionaryBatch(){return this.headerType===ee.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},St=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},wt=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Gt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function lb(t,e){return(()=>{switch(e){case ee.Schema:return oe.fromJSON(t);case ee.RecordBatch:return Ze.fromJSON(t);case ee.DictionaryBatch:return St.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}function ub(t,e){return(()=>{switch(e){case ee.Schema:return oe.decode(t.header(new gt),new Map,t.version());case ee.RecordBatch:return Ze.decode(t.header(new kt),t.version());case ee.DictionaryBatch:return St.decode(t.header(new Yn),t.version())}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}q.encode=wb;q.decode=vb;q.fromJSON=xy;oe.encode=_b;oe.decode=cb;oe.fromJSON=_y;Ze.encode=Sb;Ze.decode=fb;Ze.fromJSON=qf;St.encode=bb;St.decode=db;St.fromJSON=wy;Gt.encode=xb;Gt.decode=pb;wt.encode=Ib;wt.decode=hb;function cb(t,e=new Map,n=ae.V5){let r=gb(t,e);return new oe(r,_u(t),e,n)}function fb(t,e=ae.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),mb(t),yb(t,e))}function db(t,e=ae.V5){return new St(Ze.decode(t.data(),e),t.id(),t.isDelta())}function hb(t){return new wt(t.offset(),t.length())}function pb(t){return new Gt(t.length(),t.nullCount())}function mb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rq.encode(t,s));gt.startFieldsVector(t,n.length);let r=gt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?gt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return ze.startKeyValue(t),ze.addKey(t,a),ze.addValue(t,l),ze.endKeyValue(t)})):-1;return gt.startSchema(t),gt.addFields(t,r),gt.addEndianness(t,Bb?kr.Little:kr.Big),i!==-1&>.addCustomMetadata(t,i),gt.endSchema(t)}function wb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;E.isDictionary(s)?(o=s.dictionary.typeId,i=gu.visit(s,t),r=gu.visit(s.dictionary,t)):r=gu.visit(s,t);let a=(s.children||[]).map(c=>q.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,d])=>{let y=t.createString(`${c}`),v=t.createString(`${d}`);return ze.startKeyValue(t),ze.addKey(t,y),ze.addValue(t,v),ze.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function Sb(t,e){let n=e.nodes||[],r=e.buffers||[];kt.startNodesVector(t,n.length);for(let o of n.slice().reverse())Gt.encode(t,o);let i=t.endVector();kt.startBuffersVector(t,r.length);for(let o of r.slice().reverse())wt.encode(t,o);let s=t.endVector();return kt.startRecordBatch(t),kt.addLength(t,BigInt(e.length)),kt.addNodes(t,i),kt.addBuffers(t,s),kt.endRecordBatch(t)}function bb(t,e){let n=Ze.encode(t,e.data);return Yn.startDictionaryBatch(t),Yn.addId(t,BigInt(e.id)),Yn.addIsDelta(t,e.isDelta),Yn.addData(t,n),Yn.endDictionaryBatch(t)}function xb(t,e){return rs.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Ib(t,e){return ns.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Bb=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${ee[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${ee[t]} Message is null or length 0.`,Ny=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Ty=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,Ss=class{constructor(e){this.source=e instanceof Un?e:new Un(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?me:e.value===-1&&(e=this.readMetadataLength()).done?me:(e=this.readMetadata(e.value)).done?me:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=V(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=ee.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},wu=4,ed="ARROW1",bs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Za(e)?Nb(e):qa(e)?Eb(e):Ot(e)?O(this,void 0,void 0,function*(){return yield t.from(yield e)}):el(e)||lo(e)||nl(e)||Wt(e)?Ob(new Kt(e)):Tb(new Un(e))}static readAll(e){return e instanceof t?e.isSync()?Ey(e):Fy(e):Za(e)||ArrayBuffer.isView(e)||sn(e)||Ja(e)?Ey(e):Fy(e)}},gr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Tt(this,arguments,function*(){yield Z(yield*es(rn(this[Symbol.iterator]())))})}},Ti=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return O(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=rn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends gr{constructor(e){super(e),this._impl=e}},bu=class extends Ti{constructor(e){super(e),this._impl=e}},xu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=Q({type:new pe(this.schema.fields),length:e.length,children:r});return new Oe(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new te(u)):new te(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Is=class extends xu{constructor(e,n){super(n),this._reader=Za(e)?new sa(this._handle=e):new Ss(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):me}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):me}next(){if(this.closed)return me;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Bs=class extends xu{constructor(e,n){super(n),this._reader=new ia(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):me})}return(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):me})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return me;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Iu=class extends Is{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof Fo?e:new Fo(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return ur.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return O(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return O(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return ur.decode(i)})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Su(e)?new Oi(new Iu(t.read())):new gr(new Is(t)):new gr(new Is((function*(){})()))}function Ob(t){return O(this,void 0,void 0,function*(){let e=yield t.peek(xs+7&-8);return e&&e.byteLength>=4?Su(e)?new Oi(new Iu(yield t.read())):new Ti(new Bs(t)):new Ti(new Bs((function(){return Tt(this,arguments,function*(){})})()))})}function Eb(t){return O(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new Wr(t,e);return e>=Oy&&Su(yield n.readAt(0,xs+7&-8))?new bu(new id(n)):new Ti(new Bs(n))})}var we=class t extends C{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Oe?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof te)return this.visitMany(e.data),this;let{type:n}=e;if(!E.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(E.isUnion(n))this.nodes.push(new Gt(r,0));else{let{nullCount:i}=e;E.isNull(n)||wn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Gt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function wn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new wt(this._byteLength,e)),this._byteLength+=e,this}function Fb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(wn.call(this,i),n.mode===de.Sparse)return od.call(this,t);if(n.mode===de.Dense){if(t.offset<=0)return wn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,d=-1;++d{let d=n.typeIds[c],y=a[d],v=l[d];return u.slice(y,Math.min(r,v))}))}}return this}function kb(t){let e;return t.nullCount>=t.length?wn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?wn.call(this,yi(t.offset,t.length,e)):wn.call(this,gi(t.values))}function vr(t){return wn.call(this,t.values.subarray(0,t.length*t.stride))}function Bu(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return wn.call(this,il(-i,e+1,r)),wn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return wn.call(this,il(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}we.prototype.visitBool=kb;we.prototype.visitInt=vr;we.prototype.visitFloat=vr;we.prototype.visitUtf8=Bu;we.prototype.visitLargeUtf8=Bu;we.prototype.visitBinary=Bu;we.prototype.visitLargeBinary=Bu;we.prototype.visitFixedSizeBinary=vr;we.prototype.visitDate=vr;we.prototype.visitTimestamp=vr;we.prototype.visitTime=vr;we.prototype.visitDecimal=vr;we.prototype.visitList=ad;we.prototype.visitStruct=od;we.prototype.visitUnion=Fb;we.prototype.visitInterval=vr;we.prototype.visitDuration=vr;we.prototype.visitFixedSizeList=ad;we.prototype.visitMap=ad;var Ei=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Cn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ct(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ot(e)?e.then(n=>this.writeAll(n)):Wt(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Cn?this._sink=e:(this._sink=new Cn,e&&Qp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Gp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof _t&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Oe&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Oe?e instanceof Ni||this._writeRecordBatch(e):e instanceof _t?this.writeAll(e.batches):sn(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=bt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===ee.RecordBatch?this._recordBatchBlocks.push(new cr(a,e.bodyLength,this._position)):e.headerType===ee.DictionaryBatch&&this._dictionaryBlocks.push(new cr(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=V(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(bt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=we.assemble(e),o=new Ze(e.numRows,r,i),a=bt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=we.assemble(new te([e])),l=new Ze(e.length,s,o),u=new St(l,n,r),c=bt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):Wt(e)?ud(r,e):ld(r,e)}},aa=class t extends Ei{static writeAll(e){let n=new t;return Ot(e)?e.then(r=>n.writeAll(r)):Wt(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=ur.encode(new ur(e,ae.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof _t&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return O(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=rn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function Ay(t,e){if(Wt(t))return Lb(t,e);if(sn(t))return Ab(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Ab(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return O(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return O(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Cy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Yp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:My;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:My}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},My=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Du(t,e){let n=new Cn,r=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Ct.from(n)).open(e)})}function o(a,l){return O(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Nu(t,e){let n=new this(t),r=new Kt(n),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function la(t){let e=Ct.from(t);return Ot(e)?e.then(n=>la(n)):e.isAsync()?e.readAll().then(n=>new _t(n)):new _t(e.readAll())}var Cb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:cy,compareTypes:fy});Ge.toDOMStream=Ay;ge.throughDOM=Cy;Ct.throughDOM=Du;Oi.throughDOM=Du;gr.throughDOM=Du;Ei.throughDOM=Nu;aa.throughDOM=Nu;oa.throughDOM=Nu;var Ub=Object.create,Rb=Object.getPrototypeOf,Vd=Object.defineProperty,Pb=Object.getOwnPropertyNames,jb=Object.prototype.hasOwnProperty;function zb(t){return this[t]}var Vb,$b,he=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?Vb??=new WeakMap:$b??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Ub(Rb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of Pb(t))jb.call(o,a)||Vd(o,a,{get:zb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},so=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wb=t=>t;function Hb(t,e){this[t]=Wb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Hb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),bv={};Qh(bv,{Children:()=>Ev,Component:()=>Fv,Fragment:()=>kv,Profiler:()=>Av,PureComponent:()=>Lv,StrictMode:()=>Mv,Suspense:()=>Cv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Uv,act:()=>Rv,cloneElement:()=>Xb,createContext:()=>Zb,createElement:()=>Pv,createFactory:()=>Jb,createRef:()=>qb,forwardRef:()=>ex,isValidElement:()=>jv,lazy:()=>tx,memo:()=>nx,startTransition:()=>rx,unstable_act:()=>zv,useCallback:()=>ix,useContext:()=>sx,useDebugValue:()=>ox,useDeferredValue:()=>ax,useEffect:()=>lx,useId:()=>ux,useImperativeHandle:()=>cx,useInsertionEffect:()=>fx,useLayoutEffect:()=>dx,useMemo:()=>hx,useReducer:()=>px,useRef:()=>mx,useState:()=>yx,useSyncExternalStore:()=>gx,useTransition:()=>vx,version:()=>_x});function Yb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ds(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Uy(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function xv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{oo=Symbol.for("react.element"),Iv=Symbol.for("react.portal"),Py=Symbol.for("react.fragment"),jy=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),Dv=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),Vy=Symbol.for("react.suspense"),Tv=Symbol.for("react.memo"),Ov=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ds.prototype.isReactComponent={},Ds.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ds.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Uy.prototype=Ds.prototype,Ou=fd.prototype=new Uy,Ou.constructor=fd,Hd(Ou,Ds.prototype),Ou.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,cc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ia={transition:null},$y={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ia,ReactCurrentOwner:cc},Ev={map:Tu,forEach:function(t,e,n){Tu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Tu(t,function(){e++}),e},toArray:function(t){return Tu(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Fv=Ds,kv=Py,Av=zy,Lv=fd,Mv=jy,Cv=Vy,Uv=$y,Rv=Ry,Pv=xv,jv=$d,zv=Ry}),$t=so(function(t,e){wx(),e.exports=bv}),Sx=so(function(t){function e(T,M){var B=T.length;T.push(M);e:for(;0>>1,X=T[b];if(0>>1;bi(uf,B))cii(Xa,uf)?(T[b]=Xa,T[ci]=B,b=ci):(T[b]=uf,T[Tn]=B,b=Tn);else if(cii(Xa,B))T[b]=Xa,T[ci]=B,b=ci;else break e}}return M}function i(T,M){var B=T.sortIndex-M.sortIndex;return B!==0?B:T.id-M.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,d=null,y=3,v=!1,w=!1,I=!1,Y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(T){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=T)r(u),M.sortIndex=M.expirationTime,e(l,M);else break;M=n(u)}}function g(T){if(I=!1,m(T),!w)if(n(l)!==null)w=!0,Pe(_);else{var M=n(u);M!==null&&Fr(g,M.startTime-T)}}function _(T,M){w=!1,I&&(I=!1,h(S),S=-1),v=!0;var B=y;try{for(m(M),d=n(l);d!==null&&(!(d.expirationTime>M)||T&&!ue());){var b=d.callback;if(typeof b=="function"){d.callback=null,y=d.priorityLevel;var X=b(d.expirationTime<=M);M=t.unstable_now(),typeof X=="function"?d.callback=X:d===n(l)&&r(l),m(M)}else r(l);d=n(l)}if(d!==null)var Be=!0;else{var Tn=n(u);Tn!==null&&Fr(g,Tn.startTime-M),Be=!1}return Be}finally{d=null,y=B,v=!1}}var D=!1,N=null,S=-1,K=5,L=-1;function ue(){return!(t.unstable_now()-LT||125b?(T.sortIndex=B,e(u,T),n(l)===null&&T===n(u)&&(I?(h(S),S=-1):I=!0,Fr(g,B-b))):(T.sortIndex=X,e(l,T),w||v||(w=!0,Pe(_))),T},t.unstable_shouldYield=ue,t.unstable_wrapCallback=function(T){var M=y;return function(){var B=y;y=M;try{return T.apply(this,arguments)}finally{y=B}}}}),bx=so(function(t,e){var n=he(Sx());e.exports=n}),Vv={};Qh(Vv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>G_,createPortal:()=>I1,createRoot:()=>B1,findDOMNode:()=>D1,flushSync:()=>N1,hydrate:()=>T1,hydrateRoot:()=>O1,render:()=>E1,unmountComponentAtNode:()=>F1,unstable_batchedUpdates:()=>X_,unstable_renderSubtreeIntoContainer:()=>k1,version:()=>A1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Ix(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ht(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=Ye.hasOwnProperty(e)?Ye[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ed=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?va(t):""}function Dx(t){switch(t.tag){case 5:return va(t.type);case 16:return va("Lazy");case 13:return va("Suspense");case 19:return va("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Ic:return"Profiler";case Jc:return"StrictMode";case Bc:return"Suspense";case Dc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case qc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ef:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case Sr:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Nx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===Jc?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ai(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $v(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Tx(t){var e=$v(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Eu(t){t._valueTracker||(t._valueTracker=Tx(t))}function Wv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=$v(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function fc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return Se({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Wy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ai(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Hv(t,e);var n=ai(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,ai(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Hy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||fc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function $s(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(c_(t)/f_|0)|0}function _a(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function dc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=_a(a):(s&=o,s!==0&&(r=_a(s)))}else o=n&~i,o!==0?r=_a(o):s!==0&&(r=_a(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Qa(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-en(e),t[e]=n}function Ux(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tg(n)}}function h0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?h0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function p0(){for(var t=window,e=fc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Jx(t){var e=p0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&h0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=ng(n,s);var o=ng(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;nPs||(t.current=Lc[Ps],Lc[Ps]=null,Ps--)}function me(t,e){Ps++,Lc[Ps]=t.current,t.current=e}function Gs(t,e){var n=t.type.contextTypes;if(!n)return Tr;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(t){return t=t.childContextTypes,t!=null}function yc(){_e(yt),_e(tt)}function lg(t,e,n){if(tt.current!==Tr)throw Error(x(168));me(tt,e),me(yt,n)}function g0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Nx(t)||"Unknown",i));return Se({},n,r)}function gc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Tr,li=tt.current,me(tt,t),me(yt,yt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=g0(t,e,li),r.__reactInternalMemoizedMergedChildContext=t,_e(yt),_e(tt),me(tt,t)):_e(yt),me(yt,n)}function v0(t){br===null?br=[t]:br.push(t)}function e1(t){sf=!0,v0(t)}function ui(){if(!Rd&&br!==null){Rd=!0;var t=0,e=le;try{var n=br;for(le=1;t>=o,i-=o,Br=1<<32-en(e)+i|n<S?(K=N,N=null):K=N.sibling;var L=y(h,N,m[S],g);if(L===null){N===null&&(N=K);break}t&&N&&L.alternate===null&&e(h,N),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L,N=K}if(S===m.length)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;SS?(K=N,N=null):K=N.sibling;var ue=y(h,N,L.value,g);if(ue===null){N===null&&(N=K);break}t&&N&&ue.alternate===null&&e(h,N),f=s(ue,f,S),D===null?_=ue:D.sibling=ue,D=ue,N=K}if(L.done)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;!L.done;S++,L=m.next())L=d(h,L.value,g),L!==null&&(f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return xe&&Li(h,S),_}for(N=r(h,N);!L.done;S++,L=m.next())L=v(N,h,S,L.value,g),L!==null&&(t&&L.alternate!==null&&N.delete(L.key===null?S:L.key),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return t&&N.forEach(function(Te){return e(h,Te)}),xe&&Li(h,S),_}function Y(h,f,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Sa:e:{for(var _=m.key,D=f;D!==null;){if(D.key===_){if(_=m.type,_===ji){if(D.tag===7){n(h,D.sibling),f=i(D,m.props.children),f.return=h,h=f;break e}}else if(D.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Sr&&dg(_)===D.type){n(h,D.sibling),f=i(D,m.props),f.ref=da(h,D,m),f.return=h,h=f;break e}n(h,D);break}else e(h,D);D=D.sibling}m.type===ji?(f=Yi(m.props.children,h.mode,g,m.key),f.return=h,h=f):(g=tc(m.type,m.key,m.props,null,h.mode,g),g.ref=da(h,f,m),g.return=h,h=g)}return o(h);case Pi:e:{for(D=m.key;f!==null;){if(f.key===D)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(h,f.sibling),f=i(f,m.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else e(h,f);f=f.sibling}f=Nd(m,h.mode,g),f.return=h,h=f}return o(h);case Sr:return D=m._init,Y(h,f,D(m._payload),g)}if(Ls(m))return w(h,f,m,g);if(ua(m))return I(h,f,m,g);Cu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(h,f.sibling),f=i(f,m),f.return=h,h=f):(n(h,f),f=Dd(m,h.mode,g),f.return=h,h=f),o(h)):n(h,f)}return Y}function lp(){Cp=zs=Uc=null}function up(t){var e=Va.current;_e(Va),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ws(t,e){Uc=t,Cp=zs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Bt=!0),t.firstContext=null)}function Gt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},zs===null){if(Uc===null)throw Error(x(308));zs=t,Uc.dependencies={lanes:0,firstContext:t}}else zs=zs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function b0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Nr(t,r)}function Nr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ir(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ti(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Nr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Nr(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function pg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=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};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vc(t,e,n,r){var i=t.updateQueue;Qr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=t,I=a;switch(y=e,v=n,I.tag){case 1:if(w=I.payload,typeof w=="function"){d=w.call(v,d,y);break e}d=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=I.payload,y=typeof w=="function"?w.call(v,d,y):w,y==null)break e;d=Se({},d,y);break e;case 2:Qr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=d):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=d}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ac.transition;ac.transition={};try{t(!1),e()}finally{le=n,ac.transition=r}}function Ng(){return Jt().memoizedState}function n1(t,e,n){var r=Zr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},F0(t))k0(e,n);else if(n=b0(t,e,n,r),n!==null){var i=mt();In(n,t,r,i),A0(n,e,r)}}function r1(t,e,n){var r=Zr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(F0(t))k0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,tn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=b0(t,e,i,r),n!==null&&(i=mt(),In(n,t,r,i),A0(n,e,r))}}function F0(t){var e=t.alternate;return t===Ne||e!==null&&e===Ne}function k0(t,e){Ea=Rc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function A0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function bn(t,e){if(t&&t.defaultProps){e=Se({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:Se({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Tg(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ca(n,r)||!Ca(i,s):!0}function L0(t,e,n){var r=!1,i=Tr,s=e.contextType;return typeof s=="object"&&s!==null?s=Gt(s):(i=Dt(e)?li:tt.current,r=e.contextTypes,s=(r=r!=null)?Gs(t,i):Tr),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ha,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Og(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ha.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Gt(s):(s=Dt(e)?li:tt.current,i.context=Gs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ha.enqueueReplaceState(i,i.state,null),vc(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function Js(t,e){try{var n="",r=e;do n+=Dx(r),r=r.return;while(r);var i=n}catch(s){i=` +`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ed=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?va(t):""}function Dx(t){switch(t.tag){case 5:return va(t.type);case 16:return va("Lazy");case 13:return va("Suspense");case 19:return va("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Ic:return"Profiler";case Jc:return"StrictMode";case Bc:return"Suspense";case Dc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case qc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ef:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case Sr:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Nx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===Jc?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ai(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $v(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Tx(t){var e=$v(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Eu(t){t._valueTracker||(t._valueTracker=Tx(t))}function Wv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=$v(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function fc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return Se({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Wy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ai(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Hv(t,e);var n=ai(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,ai(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Hy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||fc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function $s(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(c_(t)/f_|0)|0}function _a(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function dc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=_a(a):(s&=o,s!==0&&(r=_a(s)))}else o=n&~i,o!==0?r=_a(o):s!==0&&(r=_a(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Qa(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-tn(e),t[e]=n}function Ux(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tg(n)}}function h0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?h0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function p0(){for(var t=window,e=fc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Jx(t){var e=p0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&h0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=ng(n,s);var o=ng(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;nPs||(t.current=Lc[Ps],Lc[Ps]=null,Ps--)}function ye(t,e){Ps++,Lc[Ps]=t.current,t.current=e}function Gs(t,e){var n=t.type.contextTypes;if(!n)return Tr;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(t){return t=t.childContextTypes,t!=null}function yc(){_e(yt),_e(tt)}function lg(t,e,n){if(tt.current!==Tr)throw Error(x(168));ye(tt,e),ye(yt,n)}function g0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Nx(t)||"Unknown",i));return Se({},n,r)}function gc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Tr,li=tt.current,ye(tt,t),ye(yt,yt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=g0(t,e,li),r.__reactInternalMemoizedMergedChildContext=t,_e(yt),_e(tt),ye(tt,t)):_e(yt),ye(yt,n)}function v0(t){br===null?br=[t]:br.push(t)}function e1(t){sf=!0,v0(t)}function ui(){if(!Rd&&br!==null){Rd=!0;var t=0,e=le;try{var n=br;for(le=1;t>=o,i-=o,Br=1<<32-tn(e)+i|n<S?(K=N,N=null):K=N.sibling;var L=y(h,N,m[S],g);if(L===null){N===null&&(N=K);break}t&&N&&L.alternate===null&&e(h,N),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L,N=K}if(S===m.length)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;SS?(K=N,N=null):K=N.sibling;var ue=y(h,N,L.value,g);if(ue===null){N===null&&(N=K);break}t&&N&&ue.alternate===null&&e(h,N),f=s(ue,f,S),D===null?_=ue:D.sibling=ue,D=ue,N=K}if(L.done)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;!L.done;S++,L=m.next())L=d(h,L.value,g),L!==null&&(f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return xe&&Li(h,S),_}for(N=r(h,N);!L.done;S++,L=m.next())L=v(N,h,S,L.value,g),L!==null&&(t&&L.alternate!==null&&N.delete(L.key===null?S:L.key),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return t&&N.forEach(function(Te){return e(h,Te)}),xe&&Li(h,S),_}function Y(h,f,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Sa:e:{for(var _=m.key,D=f;D!==null;){if(D.key===_){if(_=m.type,_===ji){if(D.tag===7){n(h,D.sibling),f=i(D,m.props.children),f.return=h,h=f;break e}}else if(D.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Sr&&dg(_)===D.type){n(h,D.sibling),f=i(D,m.props),f.ref=da(h,D,m),f.return=h,h=f;break e}n(h,D);break}else e(h,D);D=D.sibling}m.type===ji?(f=Yi(m.props.children,h.mode,g,m.key),f.return=h,h=f):(g=tc(m.type,m.key,m.props,null,h.mode,g),g.ref=da(h,f,m),g.return=h,h=g)}return o(h);case Pi:e:{for(D=m.key;f!==null;){if(f.key===D)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(h,f.sibling),f=i(f,m.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else e(h,f);f=f.sibling}f=Nd(m,h.mode,g),f.return=h,h=f}return o(h);case Sr:return D=m._init,Y(h,f,D(m._payload),g)}if(Ls(m))return w(h,f,m,g);if(ua(m))return I(h,f,m,g);Cu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(h,f.sibling),f=i(f,m),f.return=h,h=f):(n(h,f),f=Dd(m,h.mode,g),f.return=h,h=f),o(h)):n(h,f)}return Y}function lp(){Cp=zs=Uc=null}function up(t){var e=Va.current;_e(Va),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ws(t,e){Uc=t,Cp=zs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Bt=!0),t.firstContext=null)}function Xt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},zs===null){if(Uc===null)throw Error(x(308));zs=t,Uc.dependencies={lanes:0,firstContext:t}}else zs=zs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function b0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Nr(t,r)}function Nr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ir(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ti(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Nr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Nr(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function pg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=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};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vc(t,e,n,r){var i=t.updateQueue;Qr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=t,I=a;switch(y=e,v=n,I.tag){case 1:if(w=I.payload,typeof w=="function"){d=w.call(v,d,y);break e}d=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=I.payload,y=typeof w=="function"?w.call(v,d,y):w,y==null)break e;d=Se({},d,y);break e;case 2:Qr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=d):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=d}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ac.transition;ac.transition={};try{t(!1),e()}finally{le=n,ac.transition=r}}function Ng(){return qt().memoizedState}function n1(t,e,n){var r=Zr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},F0(t))k0(e,n);else if(n=b0(t,e,n,r),n!==null){var i=mt();In(n,t,r,i),A0(n,e,r)}}function r1(t,e,n){var r=Zr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(F0(t))k0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,nn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=b0(t,e,i,r),n!==null&&(i=mt(),In(n,t,r,i),A0(n,e,r))}}function F0(t){var e=t.alternate;return t===Ne||e!==null&&e===Ne}function k0(t,e){Ea=Rc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function A0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function bn(t,e){if(t&&t.defaultProps){e=Se({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:Se({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Tg(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ca(n,r)||!Ca(i,s):!0}function L0(t,e,n){var r=!1,i=Tr,s=e.contextType;return typeof s=="object"&&s!==null?s=Xt(s):(i=Dt(e)?li:tt.current,r=e.contextTypes,s=(r=r!=null)?Gs(t,i):Tr),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ha,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Og(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ha.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Xt(s):(s=Dt(e)?li:tt.current,i.context=Gs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ha.enqueueReplaceState(i,i.state,null),vc(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function Js(t,e){try{var n="",r=e;do n+=Dx(r),r=r.return;while(r);var i=n}catch(s){i=` Error generating stack: `+s.message+` -`+s.stack}return{value:t,source:e,stack:i,digest:null}}function xd(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function fh(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}function M0(t,e,n){n=Ir(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){jc||(jc=!0,Yh=r),fh(t,e)},n}function C0(t,e,n){n=Ir(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){fh(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){fh(t,e),typeof r!="function"&&(oi===null?oi=new Set([this]):oi.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Eg(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new z_;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=p1.bind(null,t,e,n),e.then(t,t))}function Fg(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function kg(t,e,n,r,i){return(t.mode&1)===0?(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ir(-1,1),e.tag=2,ti(n,e,1))),n.lanes|=1),t):(t.flags|=65536,t.lanes=i,t)}function pt(t,e,n,r){e.child=t===null?Wh(e,null,n,r):Gi(e,t.child,n,r)}function Ag(t,e,n,r,i){n=n.render;var s=e.ref;return Ws(e,i),r=yp(t,e,n,r,s,i),n=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Or(t,e,i)):(xe&&n&&sp(e),e.flags|=1,pt(t,e,r,i),e.child)}function Lg(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!Sp(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,U0(t,e,s,r,i)):(t=tc(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,(t.lanes&i)===0){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Ca,n(o,r)&&t.ref===e.ref)return Or(t,e,i)}return e.flags|=1,t=ni(s,r),t.ref=e.ref,t.return=e,e.child=t}function U0(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(Ca(s,r)&&t.ref===e.ref)if(Bt=!1,e.pendingProps=r=s,(t.lanes&i)!==0)(t.flags&131072)!==0&&(Bt=!0);else return e.lanes=t.lanes,Or(t,e,i)}return dh(t,e,n,r,i)}function R0(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if((e.mode&1)===0)e.memoizedState={baseLanes:0,cachePool:null,transitions:null},me($i,Rt),Rt|=n;else{if((n&1073741824)===0)return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,me($i,Rt),Rt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,me($i,Rt),Rt|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,me($i,Rt),Rt|=r;return pt(t,e,i,n),e.child}function P0(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function dh(t,e,n,r,i){var s=Dt(n)?li:tt.current;return s=Gs(e,s),Ws(e,i),n=yp(t,e,n,r,s,i),r=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Or(t,e,i)):(xe&&r&&sp(e),e.flags|=1,pt(t,e,n,i),e.child)}function Mg(t,e,n,r,i){if(Dt(n)){var s=!0;gc(e)}else s=!1;if(Ws(e,i),e.stateNode===null)ec(t,e),L0(e,n,r),ch(e,n,r,i),r=!0;else if(t===null){var{stateNode:o,memoizedProps:a}=e;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Gt(u):(u=Dt(n)?li:tt.current,u=Gs(e,u));var c=n.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Og(e,o,r,u),Qr=!1;var y=e.memoizedState;o.state=y,vc(e,r,o,i),l=e.memoizedState,a!==r||y!==l||yt.current||Qr?(typeof c=="function"&&(uh(e,n,c,r),l=e.memoizedState),(a=Qr||Tg(e,n,a,r,y,l,u))?(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"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,x0(t,e),a=e.memoizedProps,u=e.type===e.elementType?a:bn(e.type,a),o.props=u,d=e.pendingProps,y=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=Gt(l):(l=Dt(n)?li:tt.current,l=Gs(e,l));var v=n.getDerivedStateFromProps;(c=typeof v=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||y!==l)&&Og(e,o,r,l),Qr=!1,y=e.memoizedState,o.state=y,vc(e,r,o,i);var w=e.memoizedState;a!==d||y!==w||yt.current||Qr?(typeof v=="function"&&(uh(e,n,v,r),w=e.memoizedState),(u=Qr||Tg(e,n,u,r,y,w,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=w),o.props=r,o.state=w,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),r=!1)}return hh(t,e,n,r,s,i)}function hh(t,e,n,r,i,s){P0(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&ug(e,n,!1),Or(t,e,s);r=e.stateNode,V_.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Gi(e,t.child,null,s),e.child=Gi(e,null,a,s)):pt(t,e,a,s),e.memoizedState=r.state,i&&ug(e,n,!0),e.child}function j0(t){var e=t.stateNode;e.pendingContext?lg(t,e.pendingContext,e.pendingContext!==e.context):e.context&&lg(t,e.context,!1),dp(t,e.containerInfo)}function Cg(t,e,n,r,i){return Xs(),ap(i),e.flags|=256,pt(t,e,n,r),e.child}function ph(t){return{baseLanes:t,cachePool:null,transitions:null}}function z0(t,e,n){var r=e.pendingProps,i=be.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),me(be,i&1),t===null)return oh(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((e.mode&1)===0?e.lanes=1:t.data==="$!"?e.lanes=8:e.lanes=1073741824,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},(r&1)===0&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Gc(o,r,0,null),t=Yi(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=ph(n),e.memoizedState=Pc,t):vp(e,o));if(i=t.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return i1(t,e,o,r,a,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,a=i.sibling;var l={mode:"hidden",children:r.children};return(o&1)===0&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=ni(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=ni(a,s):(s=Yi(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?ph(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=Pc,r}return s=t.child,t=s.sibling,r=ni(s,{mode:"visible",children:r.children}),(e.mode&1)===0&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function vp(t,e){return e=Gc({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Uu(t,e,n,r){return r!==null&&ap(r),Gi(e,t.child,null,n),t=vp(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function i1(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=xd(Error(x(422))),Uu(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=Gc({mode:"visible",children:r.children},i,0,null),s=Yi(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,(e.mode&1)!==0&&Gi(e,t.child,null,o),e.child.memoizedState=ph(o),e.memoizedState=Pc,s);if((e.mode&1)===0)return Uu(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(x(419)),r=xd(s,r,void 0),Uu(t,e,o,r)}if(a=(o&t.childLanes)!==0,Bt||a){if(r=Qe,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=(i&(r.suspendedLanes|o))!==0?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Nr(t,i),In(r,t,i,-1))}return wp(),r=xd(Error(x(421))),Uu(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=m1.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,jt=ei(i.nextSibling),zt=e,xe=!0,Bn=null,t!==null&&(Pt[Xt++]=Br,Pt[Xt++]=Dr,Pt[Xt++]=Qi,Br=t.id,Dr=t.overflow,Qi=e),e=vp(e,r.children),e.flags|=4096,e)}function Ug(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),ah(t.return,e,n)}function Id(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function V0(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(pt(t,e,r.children,n),r=be.current,(r&2)!==0)r=r&1|2,e.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Ug(t,n,e);else if(t.tag===19)Ug(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(me(be,r),(e.mode&1)===0)e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&_c(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Id(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&_c(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Id(e,!0,n,null,s);break;case"together":Id(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ec(t,e){(e.mode&1)===0&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Or(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Zi|=e.lanes,(n&e.childLanes)===0)return null;if(t!==null&&e.child!==t.child)throw Error(x(153));if(e.child!==null){for(t=e.child,n=ni(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ni(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function s1(t,e,n){switch(e.tag){case 3:j0(e),Xs();break;case 5:I0(e);break;case 1:Dt(e.type)&&gc(e);break;case 4:dp(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;me(Va,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(me(be,be.current&1),e.flags|=128,null):(n&e.child.childLanes)!==0?z0(t,e,n):(me(be,be.current&1),t=Or(t,e,n),t!==null?t.sibling:null);me(be,be.current&1);break;case 19:if(r=(n&e.childLanes)!==0,(t.flags&128)!==0){if(r)return V0(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),me(be,be.current),r)break;return null;case 22:case 23:return e.lanes=0,R0(t,e,n)}return Or(t,e,n)}function ha(t,e){if(!xe)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function it(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function o1(t,e,n){var r=e.pendingProps;switch(op(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return it(e),null;case 1:return Dt(e.type)&&yc(),it(e),null;case 3:return r=e.stateNode,Zs(),_e(yt),_e(tt),pp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Mu(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&(e.flags&256)===0||(e.flags|=1024,Bn!==null&&(wh(Bn),Bn=null))),Hh(t,e),it(e),null;case 5:hp(e);var i=Ri(ro.current);if(n=e.type,t!==null&&e.stateNode!=null)W_(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(x(166));return it(e),null}if(t=Ri(Nn.current),Mu(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Dn]=e,r[to]=s,t=(e.mode&1)!==0,n){case"dialog":ve("cancel",r),ve("close",r);break;case"iframe":case"object":case"embed":ve("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Dn]=e,t[to]=r,$_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":ve("cancel",t),ve("close",t),i=r;break;case"iframe":case"object":case"embed":ve("load",t),i=r;break;case"video":case"audio":for(i=0;iio&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304)}else{if(!r)if(t=_c(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ha(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!xe)return it(e),null}else 2*Fe()-s.renderingStartTime>io&&n!==1073741824&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Fe(),e.sibling=null,n=be.current,me(be,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Rt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function a1(t,e){switch(op(e),e.tag){case 1:return Dt(e.type)&&yc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zs(),_e(yt),_e(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(_e(be),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Xs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return _e(be),null;case 4:return Zs(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function As(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Ee(t,e,r)}}function l1(t,e){if(Vh=Oc,t=p0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,y=null;t:for(;;){for(var v;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)y=d,d=v;for(;;){if(d===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=d.nextSibling)!==null)break;d=y,y=d.parentNode}d=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Oc=!1,F=e;F!==null;)if(e=F,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,F=t;else for(;F!==null;){e=F;try{var w=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var{memoizedProps:I,memoizedState:Y}=w,h=e.stateNode,f=h.getSnapshotBeforeUpdate(e.elementType===e.type?I:bn(e.type,I),Y);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Ee(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,F=t;break}F=e.return}return w=fv,fv=!1,w}function Ba(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Qc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function $0(t){var e=t.alternate;e!==null&&(t.alternate=null,$0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Dn],delete e[to],delete e[Ac],delete e[M_],delete e[C_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function W0(t){return t.tag===5||t.tag===3||t.tag===4}function Rg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||W0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Kr(t,e,n){for(n=n.child;n!==null;)H0(t,e,n),n=n.sibling}function H0(t,e,n){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(nf,n)}catch{}switch(n.tag){case 5:lt||As(n,e);case 6:var r=qe,i=xn;qe=null,Kr(t,e,n),qe=r,xn=i,qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ma(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=xn,qe=n.stateNode.containerInfo,xn=!0,Kr(t,e,n),qe=r,xn=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Kr(t,e,n);break;case 1:if(!lt&&(As(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ee(n,e,a)}Kr(t,e,n);break;case 21:Kr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Kr(t,e,n),lt=r):Kr(t,e,n);break;default:Kr(t,e,n)}}function Pg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Y_),e.forEach(function(r){var i=y1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Sn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*K_(r/1960))-r,10t?16:t,qr===null)var r=!1;else{if(t=qr,qr=null,zc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,F=t.current;F!==null;){var s=F,o=s.child;if((F.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lFe()-Rp?Hi(t,0):Up|=n),Nt(t,e)}function q0(t,e){e===0&&((t.mode&1)===0?e=1:(e=zu,zu<<=1,(zu&130023424)===0&&(zu=4194304)));var n=mt();t=Nr(t,e),t!==null&&(Qa(t,e,n),Nt(t,n))}function m1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),q0(t,n)}function y1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),q0(t,n)}function e_(t,e){return Op(t,e)}function g1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 qt(t,e,n,r){return new g1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function v1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qc)return 11;if(t===ef)return 14}return 2}function ni(t,e){var n=t.alternate;return n===null?(n=qt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case Jc:o=8,i|=8;break;case Ic:return t=qt(12,n,e,i|2),t.elementType=Ic,t.lanes=s,t;case Bc:return t=qt(13,n,e,i),t.elementType=Bc,t.lanes=s,t;case Dc:return t=qt(19,n,e,i),t.elementType=Dc,t.lanes=s,t;case Np:return Gc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case qc:o=11;break e;case ef:o=14;break e;case Sr:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=qt(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=qt(7,t,r,e),t.lanes=n,t}function Gc(t,e,n,r){return t=qt(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=qt(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=qt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new _1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=qt(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function w1(t,e,n){var r=3{if(Kg=ye(nn(),1),xt=ye(bx(),1),Ip=new Set,Ys={},jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=Object.prototype.hasOwnProperty,r_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},Ye={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ye[t]=new ht(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ye[e]=new ht(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ye[t]=new ht(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ye[t]=new ht(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ye[t]=new ht(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Ye[t]=new ht(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Ye[t]=new ht(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Ye[t]=new ht(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Ye[t]=new ht(t,5,!1,t.toLowerCase(),null,!1,!1)}),Ru=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!1,!1)}),Ye.xlinkHref=new ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!0,!0)}),zn=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sa=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),Jc=Symbol.for("react.strict_mode"),Ic=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),qc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Dc=Symbol.for("react.suspense_list"),ef=Symbol.for("react.memo"),Sr=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,Se=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Pu=Pu||document.createElement("div"),Pu.innerHTML=""+e.valueOf().toString()+"",e=Pu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Ms={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},Qg=["Webkit","ms","Moz","O"],Object.keys(Ms).forEach(function(t){Qg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ms[e]=Ms[t]})}),i_=Se({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}),jn)try{Ts={},Object.defineProperty(Ts,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Nh=!1}for(s_={onError:function(t){Da=!0,Nc=t}},Op=xt.unstable_scheduleCallback,Oh=xt.unstable_cancelCallback,o_=xt.unstable_shouldYield,a_=xt.unstable_requestPaint,Fe=xt.unstable_now,l_=xt.unstable_getCurrentPriorityLevel,tf=xt.unstable_ImmediatePriority,Ep=xt.unstable_UserBlockingPriority,ja=xt.unstable_NormalPriority,u_=xt.unstable_LowPriority,Fp=xt.unstable_IdlePriority,en=Math.clz32?Math.clz32:Lx,c_=Math.log,f_=Math.LN2,ba=[],qs=new Map,eo=new Map,xr=[],m_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=zn.ReactCurrentBatchConfig,Fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Ut(Fi),Os=Se({},Fi,{view:0,detail:0}),y_=Ut(Os),ma=Se({},Os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pa&&(pa&&t.type==="mousemove"?(kd=t.screenX-pa.screenX,Ad=t.screenY-pa.screenY):Ad=kd=0,pa=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Fh=Ut(ma),Xg=Se({},ma,{dataTransfer:0}),g_=Ut(Xg),Zg=Se({},Os,{relatedTarget:0}),ic=Ut(Zg),Jg=Se({},Fi,{animationName:0,elapsedTime:0,pseudoElement:0}),v_=Ut(Jg),qg=Se({},Fi,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),__=Ut(qg),ev=Se({},Fi,{data:0}),kh=Ut(ev),tv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},rv=Se({},Os,{key:function(t){if(t.key){var e=tv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Zu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Zu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),S_=Ut(rv),iv=Se({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Ut(iv),sv=Se({},Os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),b_=Ut(sv),ov=Se({},Fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Ut(ov),av=Se({},ma,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),I_=Ut(av),B_=[9,13,27,32],Fc=jn&&("CompositionEvent"in window),jn&&("documentMode"in document)&&(ya=document.documentMode),D_=jn&&("TextEvent"in window)&&!ya,Lp=jn&&(!Fc||ya&&8=ya),Lh=" ",N_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},jn&&(jn?(Vu="oninput"in document,Vu||(Md=document.createElement("div"),Md.setAttribute("oninput","return;"),Vu=typeof Md.oninput=="function"),Ld=Vu):Ld=!1,T_=Ld&&(!document.documentMode||9=document.documentMode,Ci={animationend:ku("Animation","AnimationEnd"),animationiteration:ku("Animation","AnimationIteration"),animationstart:ku("Animation","AnimationStart"),transitionend:ku("Transition","TransitionEnd")},sc={},Uh={},jn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Au("animationend"),Ph=Au("animationiteration"),jh=Au("animationstart"),zh=Au("transitionend"),Mp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Wu=0;Wu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Vv}),M1=so(function(t){var e=ye(Z_());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),J_={};Qh(J_,{Fragment:()=>rw,jsx:()=>iw,jsxs:()=>sw});function pv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)ew.call(e,r)&&!nw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:q_,type:t,key:s,ref:o,props:i,_owner:tw.current}}var mv,q_,yv,ew,tw,nw,rw,iw,sw,C1=Gh(()=>{mv=ye(nn(),1),q_=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),ew=Object.prototype.hasOwnProperty,tw=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nw={key:!0,ref:!0,__self:!0,__source:!0},rw=yv,iw=pv,sw=pv}),Er=so(function(t,e){C1(),e.exports=J_}),Zt=ye(nn(),1),U1=ye(M1(),1),R1=ye(Z_(),1),cL=ye(nn(),1);function Vc(t){return String(t||"").split(".").at(-1)}function jp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").trim().toLowerCase(),i=e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||!r&&!e.style&&!e.currency&&e.type==="ratio",s=r.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),o=r.match(/^(?:decimal|percent|usd)_(\d+)$/),a=s?(s[1]||"").length:o?Number(o[1]):void 0,l=e.maximumFractionDigits??(a===void 0?i||e.compact?1:2:Math.min(a,20)),u=a===void 0?void 0:Math.min(s?(s[1]||"").replaceAll("#","").length:a,l);if(i)return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:l,minimumFractionDigits:u,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let c=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:l,minimumFractionDigits:u,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function Ji(t){return String(t??"")}function ow(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function aw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var fL=ye(Er(),1);var P1=ye(nn(),1);function j1(t){return t.split(".").at(-1)||t}var $c="\0__null__";function Wc(t){return t===$c||t===""?"\u2014":t}function Pd(t,e={}){return jp(t,e)}function zp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${zp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Wc(e[0])}`:e.length<=2?`${n} ${e.map(Wc).join(", ")}`:`${n} ${e.length} values`}var at=ye(nn(),1);function V1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var $1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ku(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Qu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function W1(t,e){let n=t.split("__").at(-1);return n&&$1.has(n)?n:e}function H1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function Y1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function K1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Ku(i.query.dimensions),o=Ku(i.query.metrics),a=o.map(g=>t.graphMetrics.find(_=>_.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...V1(t,u.name)],d=o.map(g=>c.find(_=>_.ref===g)).filter(g=>!!g),y=s.map(g=>Qu(t,g)).filter((g,_,D)=>!!g&&D.findIndex(N=>N?.ref===g?.ref)===_),v=i.encoding?.y,I=(Array.isArray(v)?v:v?[v]:[]).find(g=>d.some(_=>_.ref===g))??d[0]?.ref??u.metrics[0]?.ref??"",Y=i.encoding?.x,h=(Y&&Qu(t,Y)?.type==="time"?Y:void 0)??s.find(g=>Qu(t,g)?.type==="time"),f=u.defaultGrain??"month",m=h?Qu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:d.length?d:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:I,grain:h?W1(h,f):f,filters:Ku(i.query.filters),segments:Ku(i.query.segments),usePreaggregations:Y1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??H1(e)}}var Q1=["second","minute","hour","day","week","month","quarter","year"];function G1(t){return t.toISOString().slice(0,10)}function X1(t){return t.slice(0,10)}function Z1(t){return new Date(`${X1(t)}T00:00:00Z`)}function J1(t,e){let n=Z1(t);return n.setUTCDate(n.getUTCDate()+e),G1(n)}function q1(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${J1(e.to,1)}' as date)`]}function eI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function tI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function nI(t){return tI(t.models.flatMap(e=>e.dimensions))}function gv(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return zp(t,n)}function rI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function lw(t,e,n){let r=zp(`%${rI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function iI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes($c),o=e.values.filter(l=>l!==$c),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${gv(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>gv(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function sI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||eI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(lw(r,i.pattern??"",e.dialect));continue}let o=iI(r,i,s,e.dialect);o&&n.push(o)}return n}function oI(t,e={}){let n=sI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...q1(e.timeRef,e.range)),n}function aI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var uw=ye(nn(),1),dL=new Set(Q1);var lI=uw.createContext(null);function uI(){let t=uw.useContext(lI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=ye(nn(),1),hL=ye(nn(),1),Hc={active:0,listeners:new Set};function cw(){for(let t of Hc.listeners)t()}function cI(){Hc.active+=1,cw()}function fI(){Hc.active=Math.max(0,Hc.active-1),cw()}var dI=80;function hI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{cI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>fI())},dI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var Le=ye(Er(),1),pI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],mI=50,vv=200;function _v(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function yI({dim:t,model:e,onClose:n}){let{state:r,dispatch:i,backend:s,catalog:o,dashboard:a}=uI(),l=at.useMemo(()=>K1(o,a,r.dashboardTab),[o,a,r.dashboardTab]),u=r.filters[t.ref],[c,d]=at.useState(u?.mode??"include"),y=at.useMemo(()=>new Set(u?.mode!=="contains"?u?.values??[]:[]),[u]),v=at.useRef(null),w=at.useRef(null),I=at.useId(),[Y,h]=at.useState(""),f=_v(Y,vv),m=u?.mode==="contains"?u.pattern??"":"",[g,_]=at.useState(m),D=_v(g,vv);at.useEffect(()=>{let b=document.activeElement;return w.current?.focus(),()=>b?.focus?.()},[]),at.useEffect(()=>{function b(Be){Be.key==="Escape"&&(Be.stopPropagation(),n())}function X(Be){v.current&&!v.current.contains(Be.target)&&n()}return document.addEventListener("keydown",b,!0),document.addEventListener("mousedown",X,!0),()=>{document.removeEventListener("keydown",b,!0),document.removeEventListener("mousedown",X,!0)}},[n]),at.useEffect(()=>{c==="contains"&&D!==m&&i({type:"setFilterPattern",dim:t.ref,pattern:D})},[D,c,t.ref,i]);let N=o.models.find(b=>b.name===r.model)??e,S=l?.timeDimension?.ref??N.timeDimension?.ref,K=at.useMemo(()=>nI(o),[o]),L=at.useMemo(()=>{let b=[...l?.filters??[],...oI(r.filters,{timeRef:S,range:r.dateRange,excludeDim:t.ref,types:K,dialect:o.dialect})];return f.trim()&&b.push(lw(t.ref,f.trim(),o.dialect)),b},[l,r.filters,S,r.dateRange,t.ref,f,K,o.dialect]),ue=c!=="contains",{result:Te,loading:Re,error:Ie}=hI(s,ue?aI(t.ref,L,mI,l?.segments,l?.usePreaggregations):null),ke=j1(t.ref),Pe=at.useMemo(()=>Te?Te.rows.map(b=>{let X=b[ke];return X==null?$c:String(X)}):[],[Te,ke]),Fr=!!Te&&Te.rows.length>0&&!Te.columns.includes(ke),T=ue&&(Re||Fr);function M(b){d(b),u&&i({type:"setFilterMode",dim:t.ref,mode:b}),b==="contains"&&_(m)}function B(b){if(b.key!=="Tab")return;let X=v.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!X||X.length===0)return;let Be=X[0],Tn=X[X.length-1];b.shiftKey&&document.activeElement===Be?(b.preventDefault(),Tn.focus()):!b.shiftKey&&document.activeElement===Tn&&(b.preventDefault(),Be.focus())}return Le.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":I,onKeyDown:B,className:"absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg",children:[Le.jsxs("div",{id:I,className:"mb-2 flex items-baseline justify-between gap-2",children:[Le.jsx("span",{className:"truncate font-semibold text-ink",children:t.label}),Le.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:n,className:"grid size-4 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Le.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:pI.map(({mode:b,label:X})=>Le.jsx("button",{type:"button","aria-pressed":c===b,onClick:()=>M(b),className:`px-1.5 py-1 text-center ${c===b?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:X},b))}),c==="contains"?Le.jsx("input",{ref:w,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:g,onChange:b=>_(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Le.jsxs(Le.Fragment,{children:[Le.jsx("input",{ref:w,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:Y,onChange:b=>h(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Le.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:Ie?Le.jsx("p",{className:"px-1 py-2 text-danger",children:Ie}):T?Le.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(b=>Le.jsx("div",{className:"skeleton h-4 w-full"},b))}):Pe.length===0?Le.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Pe.map(b=>{let X=y.has(b);return Le.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Le.jsx("input",{type:"checkbox",checked:X,onChange:()=>i({type:"toggleFilter",dim:t.ref,value:b,mode:c}),className:"size-3 accent-[var(--accent)]"}),Le.jsx("span",{className:"min-w-0 truncate text-ink",children:Wc(b)})]},b)})})]}),Le.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Le.jsx("button",{type:"button",onClick:()=>i({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Le.jsx("button",{type:"button",onClick:n,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}var Vn=ye(Er(),1);function wv(t){let[e,n]=P1.useState(!1);if(!("dim"in t))return Vn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("span",{className:"truncate",children:[Vn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?Vn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:r,model:i,filter:s,onRemove:o}=t;return Vn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":r.ref,"data-mode":s.mode,children:[Vn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("button",{type:"button","aria-label":`Edit filter ${r.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(a=>!a),className:"min-w-0 truncate text-left hover:text-ink",children:[Vn.jsx("span",{className:"text-faint",children:r.label})," ",z1(s)]}),Vn.jsx("button",{type:"button","aria-label":`Remove filter ${r.label}`,onClick:o,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?Vn.jsx(yI,{dim:r,model:i,onClose:()=>n(!1)}):null]})}var Je=ye(Er(),1),gI={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function vI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:d=6,expanded:y=!1,onExpandedChange:v,containerRef:w}){let I=new Set(i),Y=y?r:r.slice(0,d),h=Math.max(1,...Y.map(_=>Math.abs(_.metric))),f=y||r.length>d,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:w,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(_=>Je.jsx("button",{type:"button",title:_.title,"aria-pressed":l===_.key,"data-context":_.key,"data-active":l===_.key||void 0,onClick:()=>c(_.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:_.label},_.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(_=>Je.jsx("div",{className:"skeleton h-5 w-full"},_))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):Y.map(_=>{let D=_.metric<0?"negative":"positive",N=I.has(_.value),S=`${Math.round(Math.abs(_.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":_.value,"data-selected":N||void 0,"data-tone":D,onClick:()=>a?.(_.value),"aria-pressed":N,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${D==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:S}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Wc(_.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(_.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":_.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${gI[_.context?.tone??"neutral"]}`,children:_.context?.label??"\u2014"}):null]},`${t}:${_.value}`)})}),f&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var _I=ye(nn(),1),_r=ye(nn(),1),pL=ye(nn(),1),wI=ye(Er(),1);function SI({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?wI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=ye(Er(),1);function bI({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=_r.useRef(null),l=_r.useId(),u=_r.useRef(null),c=_r.useRef(null),[d,y]=_r.useState(200),[v,w]=_r.useState(null),[I,Y]=_r.useState(null),[h,f]=_r.useState(null);_r.useEffect(()=>{let B=a.current;if(!B||typeof ResizeObserver>"u")return;let b=new ResizeObserver(X=>{for(let Be of X)y(Math.max(40,Be.contentRect.width))});return b.observe(B),()=>b.disconnect()},[]);let m=t.map((B,b)=>({index:b,value:B})).filter(B=>Number.isFinite(B.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${d} ${n}`});let g=3,_=Math.min(...m.map(B=>B.value)),N=Math.max(...m.map(B=>B.value))-_||1,S=m.map((B,b)=>({...B,x:g+b/(m.length-1)*(d-g*2),y:g+(1-(B.value-_)/N)*(n-g*2)})),K=S.map(({x:B,y:b})=>`${B.toFixed(1)},${b.toFixed(1)}`).join(" L "),L=`M ${S[0].x.toFixed(1)},${n-g} L ${K} L ${S.at(-1).x.toFixed(1)},${n-g} Z`,ue=S.at(-1),Te=r||`Trend of ${m.length} points, latest ${i(ue.value)}`;function Re(B){let b=u.current?.getBoundingClientRect();return b?Math.max(g,Math.min(d-g,(B.clientX-b.left)/b.width*d)):g}function Ie(B){return Math.max(0,Math.min(S.length-1,Math.round((B-g)/(d-g*2)*(S.length-1))))}function ke(B){let b=Re(B),X=Ie(b),Be=S[X];w(X),f({content:`${e?.[Be.index]?`${e[Be.index]}: `:""}${i(Be.value)}`,x:B.clientX,y:B.clientY}),s?.({index:Be.index,label:e?.[Be.index],value:Be.value}),c.current!==null&&Y({a:c.current,b})}function Pe(B){if(!o||!e?.length)return;B.currentTarget.setPointerCapture(B.pointerId);let b=Re(B);c.current=b,Y({a:b,b})}function Fr(B){if(c.current===null||!o||!e?.length)return;B.currentTarget.hasPointerCapture(B.pointerId)&&B.currentTarget.releasePointerCapture(B.pointerId);let b=Re(B);if(Math.abs(b-c.current)>6){let X=S[Ie(Math.min(c.current,b))],Be=S[Ie(Math.max(c.current,b))];o({from:e[X.index],to:e[Be.index]})}c.current=null,Y(null)}function T(){w(null),f(null),s?.(null),c.current===null&&Y(null)}let M=v===null?null:S[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":Te,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${d} ${n}`,preserveAspectRatio:"none",onPointerMove:ke,onPointerDown:Pe,onPointerUp:Fr,onPointerCancel:T,onPointerLeave:T,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${K}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),I?st.jsx("rect",{x:Math.min(I.a,I.b),y:0,width:Math.abs(I.b-I.a),height:n,fill:"currentColor",opacity:.12}):null,M?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:M.x,x2:M.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:M.x,cy:M.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:ue.x,cy:ue.y,r:2.25,fill:"currentColor"})]}),st.jsx(SI,{tip:h})]})}var ot=ye(Er(),1),xI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},II={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function BI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:d,onSparkHover:y,onSparkBrush:v}){let[w,I]=_I.useState(null),Y=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),w?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:w.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):w?Pd(w.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${xI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:II[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",f=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(bI,{values:a,labels:l,onHover:m=>{I(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return d?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>d(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:Y}),f]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[Y,f]})}var mL=ye(Er(),1);var Xr=ye(Er(),1);function Vp({tone:t,title:e,message:n}){let r=t==="danger";return Xr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Xr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Xr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Xr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Xr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function DI({title:t="Loading",message:e="Loading metrics\u2026"}){return Xr.jsx(Vp,{tone:"loading",title:t,message:e})}function NI({title:t="No results",message:e}){return Xr.jsx(Vp,{tone:"muted",title:t,message:e})}function TI({title:t="Query failed",message:e}){return Xr.jsx(Vp,{tone:"danger",title:t,message:e})}var Sv=new WeakMap;function lf(t,e){let n=Sv.get(t);n||(t.replaceChildren(),n=U1.createRoot(t),Sv.set(t,n)),R1.flushSync(()=>n.render(e))}function OI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??Vc(e)}function fw(t,e){return typeof t=="function"?t(e):t}function EI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function FI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:EI(n)}}function dw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];lf(t,Zt.createElement(Zt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=Vc(s);return Zt.createElement(BI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:fw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function $p(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;lf(t,Zt.createElement(Zt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=FI({dimensions:[o],metrics:[n.metricRef],result:a}),u=OI(l),c=r===o;return Zt.createElement(vI,{key:o,dimension:o,title:s.label??Vc(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??Vc(n.metricRef),rows:u.map(d=>({value:Ji(d[zd(l,o)]),metric:Number(d[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:d=>jp(d,fw(n.valueFormat,{metric:n.metricRef,value:d})),onToggle:n.onSelect?d=>n.onSelect({dimension:o,value:d,row:u.find(y=>Ji(y[zd(l,o)])===d)}):void 0,onExpandedChange:n.expandable===!1?void 0:d=>{t.__sdmExpandedDim=d?o:void 0,$p(t,e,n)}})})))}function hw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return Zt.createElement(wv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(Zt.createElement(wv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));lf(t,i.length?Zt.createElement(Zt.Fragment,null,...i):r.emptyLabel?Zt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function pw(t,e){let n=e.kind==="error"?TI:e.kind==="loading"?DI:NI;lf(t,Zt.createElement(n,{message:e.message}))}function Wp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function mw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function yw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function gw(t,e){let n=mw(t),r=mw(e);if(!n||!r){let a=Wp(t),l=Wp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=yw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=yw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function kI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Dn]=e,t[to]=r,$_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":ve("cancel",t),ve("close",t),i=r;break;case"iframe":case"object":case"embed":ve("load",t),i=r;break;case"video":case"audio":for(i=0;iio&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304)}else{if(!r)if(t=_c(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ha(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!xe)return it(e),null}else 2*Fe()-s.renderingStartTime>io&&n!==1073741824&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Fe(),e.sibling=null,n=be.current,ye(be,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Rt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function a1(t,e){switch(op(e),e.tag){case 1:return Dt(e.type)&&yc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zs(),_e(yt),_e(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(_e(be),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Xs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return _e(be),null;case 4:return Zs(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function As(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Ee(t,e,r)}}function l1(t,e){if(Vh=Oc,t=p0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,y=null;t:for(;;){for(var v;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)y=d,d=v;for(;;){if(d===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=d.nextSibling)!==null)break;d=y,y=d.parentNode}d=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Oc=!1,F=e;F!==null;)if(e=F,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,F=t;else for(;F!==null;){e=F;try{var w=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var{memoizedProps:I,memoizedState:Y}=w,h=e.stateNode,f=h.getSnapshotBeforeUpdate(e.elementType===e.type?I:bn(e.type,I),Y);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Ee(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,F=t;break}F=e.return}return w=fv,fv=!1,w}function Ba(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Qc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function $0(t){var e=t.alternate;e!==null&&(t.alternate=null,$0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Dn],delete e[to],delete e[Ac],delete e[M_],delete e[C_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function W0(t){return t.tag===5||t.tag===3||t.tag===4}function Rg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||W0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Kr(t,e,n){for(n=n.child;n!==null;)H0(t,e,n),n=n.sibling}function H0(t,e,n){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(nf,n)}catch{}switch(n.tag){case 5:lt||As(n,e);case 6:var r=qe,i=xn;qe=null,Kr(t,e,n),qe=r,xn=i,qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ma(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=xn,qe=n.stateNode.containerInfo,xn=!0,Kr(t,e,n),qe=r,xn=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Kr(t,e,n);break;case 1:if(!lt&&(As(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ee(n,e,a)}Kr(t,e,n);break;case 21:Kr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Kr(t,e,n),lt=r):Kr(t,e,n);break;default:Kr(t,e,n)}}function Pg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Y_),e.forEach(function(r){var i=y1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Sn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*K_(r/1960))-r,10t?16:t,qr===null)var r=!1;else{if(t=qr,qr=null,zc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,F=t.current;F!==null;){var s=F,o=s.child;if((F.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lFe()-Rp?Hi(t,0):Up|=n),Nt(t,e)}function q0(t,e){e===0&&((t.mode&1)===0?e=1:(e=zu,zu<<=1,(zu&130023424)===0&&(zu=4194304)));var n=mt();t=Nr(t,e),t!==null&&(Qa(t,e,n),Nt(t,n))}function m1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),q0(t,n)}function y1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),q0(t,n)}function e_(t,e){return Op(t,e)}function g1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 en(t,e,n,r){return new g1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function v1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qc)return 11;if(t===ef)return 14}return 2}function ni(t,e){var n=t.alternate;return n===null?(n=en(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case Jc:o=8,i|=8;break;case Ic:return t=en(12,n,e,i|2),t.elementType=Ic,t.lanes=s,t;case Bc:return t=en(13,n,e,i),t.elementType=Bc,t.lanes=s,t;case Dc:return t=en(19,n,e,i),t.elementType=Dc,t.lanes=s,t;case Np:return Gc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case qc:o=11;break e;case ef:o=14;break e;case Sr:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=en(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=en(7,t,r,e),t.lanes=n,t}function Gc(t,e,n,r){return t=en(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=en(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=en(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new _1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=en(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function w1(t,e,n){var r=3{if(Kg=he($t(),1),xt=he(bx(),1),Ip=new Set,Ys={},jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=Object.prototype.hasOwnProperty,r_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},Ye={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ye[t]=new ht(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ye[e]=new ht(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ye[t]=new ht(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ye[t]=new ht(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ye[t]=new ht(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Ye[t]=new ht(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Ye[t]=new ht(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Ye[t]=new ht(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Ye[t]=new ht(t,5,!1,t.toLowerCase(),null,!1,!1)}),Ru=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!1,!1)}),Ye.xlinkHref=new ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!0,!0)}),zn=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sa=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),Jc=Symbol.for("react.strict_mode"),Ic=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),qc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Dc=Symbol.for("react.suspense_list"),ef=Symbol.for("react.memo"),Sr=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,Se=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Pu=Pu||document.createElement("div"),Pu.innerHTML=""+e.valueOf().toString()+"",e=Pu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Ms={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},Qg=["Webkit","ms","Moz","O"],Object.keys(Ms).forEach(function(t){Qg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ms[e]=Ms[t]})}),i_=Se({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}),jn)try{Ts={},Object.defineProperty(Ts,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Nh=!1}for(s_={onError:function(t){Da=!0,Nc=t}},Op=xt.unstable_scheduleCallback,Oh=xt.unstable_cancelCallback,o_=xt.unstable_shouldYield,a_=xt.unstable_requestPaint,Fe=xt.unstable_now,l_=xt.unstable_getCurrentPriorityLevel,tf=xt.unstable_ImmediatePriority,Ep=xt.unstable_UserBlockingPriority,ja=xt.unstable_NormalPriority,u_=xt.unstable_LowPriority,Fp=xt.unstable_IdlePriority,tn=Math.clz32?Math.clz32:Lx,c_=Math.log,f_=Math.LN2,ba=[],qs=new Map,eo=new Map,xr=[],m_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=zn.ReactCurrentBatchConfig,Fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Ut(Fi),Os=Se({},Fi,{view:0,detail:0}),y_=Ut(Os),ma=Se({},Os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pa&&(pa&&t.type==="mousemove"?(kd=t.screenX-pa.screenX,Ad=t.screenY-pa.screenY):Ad=kd=0,pa=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Fh=Ut(ma),Xg=Se({},ma,{dataTransfer:0}),g_=Ut(Xg),Zg=Se({},Os,{relatedTarget:0}),ic=Ut(Zg),Jg=Se({},Fi,{animationName:0,elapsedTime:0,pseudoElement:0}),v_=Ut(Jg),qg=Se({},Fi,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),__=Ut(qg),ev=Se({},Fi,{data:0}),kh=Ut(ev),tv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},rv=Se({},Os,{key:function(t){if(t.key){var e=tv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Zu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Zu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),S_=Ut(rv),iv=Se({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Ut(iv),sv=Se({},Os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),b_=Ut(sv),ov=Se({},Fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Ut(ov),av=Se({},ma,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),I_=Ut(av),B_=[9,13,27,32],Fc=jn&&("CompositionEvent"in window),jn&&("documentMode"in document)&&(ya=document.documentMode),D_=jn&&("TextEvent"in window)&&!ya,Lp=jn&&(!Fc||ya&&8=ya),Lh=" ",N_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},jn&&(jn?(Vu="oninput"in document,Vu||(Md=document.createElement("div"),Md.setAttribute("oninput","return;"),Vu=typeof Md.oninput=="function"),Ld=Vu):Ld=!1,T_=Ld&&(!document.documentMode||9=document.documentMode,Ci={animationend:ku("Animation","AnimationEnd"),animationiteration:ku("Animation","AnimationIteration"),animationstart:ku("Animation","AnimationStart"),transitionend:ku("Transition","TransitionEnd")},sc={},Uh={},jn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Au("animationend"),Ph=Au("animationiteration"),jh=Au("animationstart"),zh=Au("transitionend"),Mp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Wu=0;Wu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Vv}),M1=so(function(t){var e=he(Z_());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),J_={};Qh(J_,{Fragment:()=>rw,jsx:()=>iw,jsxs:()=>sw});function pv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)ew.call(e,r)&&!nw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:q_,type:t,key:s,ref:o,props:i,_owner:tw.current}}var mv,q_,yv,ew,tw,nw,rw,iw,sw,C1=Gh(()=>{mv=he($t(),1),q_=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),ew=Object.prototype.hasOwnProperty,tw=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nw={key:!0,ref:!0,__self:!0,__source:!0},rw=yv,iw=pv,sw=pv}),Er=so(function(t,e){C1(),e.exports=J_}),Jt=he($t(),1),U1=he(M1(),1),R1=he(Z_(),1),dL=he($t(),1);function Vc(t){return String(t||"").split(".").at(-1)}function jp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").trim().toLowerCase(),i=e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||!r&&!e.style&&!e.currency&&e.type==="ratio",s=r.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),o=r.match(/^(?:decimal|percent|usd)_(\d+)$/),a=s?(s[1]||"").length:o?Number(o[1]):void 0,l=e.maximumFractionDigits??(a===void 0?i||e.compact?1:2:Math.min(a,20)),u=a===void 0?void 0:Math.min(s?(s[1]||"").replaceAll("#","").length:a,l);if(i)return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:l,minimumFractionDigits:u,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let c=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:l,minimumFractionDigits:u,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function Ji(t){return String(t??"")}function ow(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function aw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var hL=he(Er(),1);var P1=he($t(),1);function j1(t){return t.split(".").at(-1)||t}var $c="\0__null__";function Wc(t){return t===$c||t===""?"\u2014":t}function Pd(t,e={}){return jp(t,e)}function zp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${zp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Wc(e[0])}`:e.length<=2?`${n} ${e.map(Wc).join(", ")}`:`${n} ${e.length} values`}var at=he($t(),1);function V1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var $1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ku(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Qu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function W1(t,e){let n=t.split("__").at(-1);return n&&$1.has(n)?n:e}function H1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function Y1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function K1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Ku(i.query.dimensions),o=Ku(i.query.metrics),a=o.map(g=>t.graphMetrics.find(_=>_.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...V1(t,u.name)],d=o.map(g=>c.find(_=>_.ref===g)).filter(g=>!!g),y=s.map(g=>Qu(t,g)).filter((g,_,D)=>!!g&&D.findIndex(N=>N?.ref===g?.ref)===_),v=i.encoding?.y,I=(Array.isArray(v)?v:v?[v]:[]).find(g=>d.some(_=>_.ref===g))??d[0]?.ref??u.metrics[0]?.ref??"",Y=i.encoding?.x,h=(Y&&Qu(t,Y)?.type==="time"?Y:void 0)??s.find(g=>Qu(t,g)?.type==="time"),f=u.defaultGrain??"month",m=h?Qu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:d.length?d:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:I,grain:h?W1(h,f):f,filters:Ku(i.query.filters),segments:Ku(i.query.segments),usePreaggregations:Y1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??H1(e)}}var Q1=["second","minute","hour","day","week","month","quarter","year"];function G1(t){return t.toISOString().slice(0,10)}function X1(t){return t.slice(0,10)}function Z1(t){return new Date(`${X1(t)}T00:00:00Z`)}function J1(t,e){let n=Z1(t);return n.setUTCDate(n.getUTCDate()+e),G1(n)}function q1(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${J1(e.to,1)}' as date)`]}function eI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function tI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function nI(t){return tI(t.models.flatMap(e=>e.dimensions))}function gv(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return zp(t,n)}function rI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function lw(t,e,n){let r=zp(`%${rI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function iI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes($c),o=e.values.filter(l=>l!==$c),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${gv(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>gv(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function sI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||eI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(lw(r,i.pattern??"",e.dialect));continue}let o=iI(r,i,s,e.dialect);o&&n.push(o)}return n}function oI(t,e={}){let n=sI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...q1(e.timeRef,e.range)),n}function aI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var uw=he($t(),1),pL=new Set(Q1);var lI=uw.createContext(null);function uI(){let t=uw.useContext(lI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=he($t(),1),mL=he($t(),1),Hc={active:0,listeners:new Set};function cw(){for(let t of Hc.listeners)t()}function cI(){Hc.active+=1,cw()}function fI(){Hc.active=Math.max(0,Hc.active-1),cw()}var dI=80;function hI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{cI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>fI())},dI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var pI=he($t(),1);function mI(t,e=!0){pI.useLayoutEffect(()=>{let n=t.current,r=n?.parentElement;if(!e||!n||!r)return;function i(){if(!n||!r)return;let o=r.getBoundingClientRect(),a=8,l=Math.max(a,Math.min(o.left,window.innerWidth-n.offsetWidth-a));n.style.left=`${l-o.left}px`,n.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-o.bottom-a-4)}px`)}i();let s=new ResizeObserver(i);return s.observe(n),s.observe(r),r.parentElement&&s.observe(r.parentElement),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{s.disconnect(),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}})}var Le=he(Er(),1),yI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],gI=50,vv=200;function _v(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function vI({dim:t,model:e,onClose:n}){let{state:r,dispatch:i,backend:s,catalog:o,dashboard:a}=uI(),l=at.useMemo(()=>K1(o,a,r.dashboardTab),[o,a,r.dashboardTab]),u=r.filters[t.ref],[c,d]=at.useState(u?.mode??"include"),y=at.useMemo(()=>new Set(u?.mode!=="contains"?u?.values??[]:[]),[u]),v=at.useRef(null);mI(v);let w=at.useRef(null),I=at.useId(),[Y,h]=at.useState(""),f=_v(Y,vv),m=u?.mode==="contains"?u.pattern??"":"",[g,_]=at.useState(m),D=_v(g,vv);at.useEffect(()=>{let b=document.activeElement;return w.current?.focus(),()=>b?.focus?.()},[]),at.useEffect(()=>{function b(Be){Be.key==="Escape"&&(Be.stopPropagation(),n())}function X(Be){v.current&&!v.current.contains(Be.target)&&n()}return document.addEventListener("keydown",b,!0),document.addEventListener("mousedown",X,!0),()=>{document.removeEventListener("keydown",b,!0),document.removeEventListener("mousedown",X,!0)}},[n]),at.useEffect(()=>{c==="contains"&&D!==m&&i({type:"setFilterPattern",dim:t.ref,pattern:D})},[D,c,t.ref,i]);let N=o.models.find(b=>b.name===r.model)??e,S=l?.timeDimension?.ref??N.timeDimension?.ref,K=at.useMemo(()=>nI(o),[o]),L=at.useMemo(()=>{let b=[...l?.filters??[],...oI(r.filters,{timeRef:S,range:r.dateRange,excludeDim:t.ref,types:K,dialect:o.dialect})];return f.trim()&&b.push(lw(t.ref,f.trim(),o.dialect)),b},[l,r.filters,S,r.dateRange,t.ref,f,K,o.dialect]),ue=c!=="contains",{result:Te,loading:Re,error:Ie}=hI(s,ue?aI(t.ref,L,gI,l?.segments,l?.usePreaggregations):null),ke=j1(t.ref),Pe=at.useMemo(()=>Te?Te.rows.map(b=>{let X=b[ke];return X==null?$c:String(X)}):[],[Te,ke]),Fr=!!Te&&Te.rows.length>0&&!Te.columns.includes(ke),T=ue&&(Re||Fr);function M(b){d(b),u&&i({type:"setFilterMode",dim:t.ref,mode:b}),b==="contains"&&_(m)}function B(b){if(b.key!=="Tab")return;let X=v.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!X||X.length===0)return;let Be=X[0],Tn=X[X.length-1];b.shiftKey&&document.activeElement===Be?(b.preventDefault(),Tn.focus()):!b.shiftKey&&document.activeElement===Tn&&(b.preventDefault(),Be.focus())}return Le.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":I,onKeyDown:B,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[Le.jsxs("div",{id:I,className:"mb-2 flex items-baseline justify-between gap-2",children:[Le.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:t.label}),Le.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:n,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Le.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:yI.map(({mode:b,label:X})=>Le.jsx("button",{type:"button","aria-pressed":c===b,onClick:()=>M(b),className:`px-1.5 py-1 text-center ${c===b?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:X},b))}),c==="contains"?Le.jsx("input",{ref:w,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:g,onChange:b=>_(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Le.jsxs(Le.Fragment,{children:[Le.jsx("input",{ref:w,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:Y,onChange:b=>h(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Le.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:Ie?Le.jsx("p",{className:"px-1 py-2 text-danger",children:Ie}):T?Le.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(b=>Le.jsx("div",{className:"skeleton h-4 w-full"},b))}):Pe.length===0?Le.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Pe.map(b=>{let X=y.has(b);return Le.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Le.jsx("input",{type:"checkbox",checked:X,onChange:()=>i({type:"toggleFilter",dim:t.ref,value:b,mode:c}),className:"size-3 shrink-0 accent-[var(--accent)]"}),Le.jsx("span",{className:"min-w-0 break-words text-ink",children:Wc(b)})]},b)})})]}),Le.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Le.jsx("button",{type:"button",onClick:()=>i({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Le.jsx("button",{type:"button",onClick:n,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}var Vn=he(Er(),1);function wv(t){let[e,n]=P1.useState(!1);if(!("dim"in t))return Vn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("span",{className:"truncate",children:[Vn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?Vn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:r,model:i,filter:s,onRemove:o}=t;return Vn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":r.ref,"data-mode":s.mode,children:[Vn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("button",{type:"button","aria-label":`Edit filter ${r.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(a=>!a),className:"min-w-0 truncate text-left hover:text-ink",children:[Vn.jsx("span",{className:"text-faint",children:r.label})," ",z1(s)]}),Vn.jsx("button",{type:"button","aria-label":`Remove filter ${r.label}`,onClick:o,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?Vn.jsx(vI,{dim:r,model:i,onClose:()=>n(!1)}):null]})}var Je=he(Er(),1),_I={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function wI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:d=6,expanded:y=!1,onExpandedChange:v,containerRef:w}){let I=new Set(i),Y=y?r:r.slice(0,d),h=Math.max(1,...Y.map(_=>Math.abs(_.metric))),f=y||r.length>d,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:w,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(_=>Je.jsx("button",{type:"button",title:_.title,"aria-pressed":l===_.key,"data-context":_.key,"data-active":l===_.key||void 0,onClick:()=>c(_.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:_.label},_.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(_=>Je.jsx("div",{className:"skeleton h-5 w-full"},_))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):Y.map(_=>{let D=_.metric<0?"negative":"positive",N=I.has(_.value),S=`${Math.round(Math.abs(_.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":_.value,"data-selected":N||void 0,"data-tone":D,onClick:()=>a?.(_.value),"aria-pressed":N,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${D==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:S}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Wc(_.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(_.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":_.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${_I[_.context?.tone??"neutral"]}`,children:_.context?.label??"\u2014"}):null]},`${t}:${_.value}`)})}),f&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var SI=he($t(),1),_r=he($t(),1),yL=he($t(),1),bI=he(Er(),1);function xI({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?bI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=he(Er(),1);function II({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=_r.useRef(null),l=_r.useId(),u=_r.useRef(null),c=_r.useRef(null),[d,y]=_r.useState(200),[v,w]=_r.useState(null),[I,Y]=_r.useState(null),[h,f]=_r.useState(null);_r.useEffect(()=>{let B=a.current;if(!B||typeof ResizeObserver>"u")return;let b=new ResizeObserver(X=>{for(let Be of X)y(Math.max(40,Be.contentRect.width))});return b.observe(B),()=>b.disconnect()},[]);let m=t.map((B,b)=>({index:b,value:B})).filter(B=>Number.isFinite(B.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${d} ${n}`});let g=3,_=Math.min(...m.map(B=>B.value)),N=Math.max(...m.map(B=>B.value))-_||1,S=m.map((B,b)=>({...B,x:g+b/(m.length-1)*(d-g*2),y:g+(1-(B.value-_)/N)*(n-g*2)})),K=S.map(({x:B,y:b})=>`${B.toFixed(1)},${b.toFixed(1)}`).join(" L "),L=`M ${S[0].x.toFixed(1)},${n-g} L ${K} L ${S.at(-1).x.toFixed(1)},${n-g} Z`,ue=S.at(-1),Te=r||`Trend of ${m.length} points, latest ${i(ue.value)}`;function Re(B){let b=u.current?.getBoundingClientRect();return b?Math.max(g,Math.min(d-g,(B.clientX-b.left)/b.width*d)):g}function Ie(B){return Math.max(0,Math.min(S.length-1,Math.round((B-g)/(d-g*2)*(S.length-1))))}function ke(B){let b=Re(B),X=Ie(b),Be=S[X];w(X),f({content:`${e?.[Be.index]?`${e[Be.index]}: `:""}${i(Be.value)}`,x:B.clientX,y:B.clientY}),s?.({index:Be.index,label:e?.[Be.index],value:Be.value}),c.current!==null&&Y({a:c.current,b})}function Pe(B){if(!o||!e?.length)return;B.currentTarget.setPointerCapture(B.pointerId);let b=Re(B);c.current=b,Y({a:b,b})}function Fr(B){if(c.current===null||!o||!e?.length)return;B.currentTarget.hasPointerCapture(B.pointerId)&&B.currentTarget.releasePointerCapture(B.pointerId);let b=Re(B);if(Math.abs(b-c.current)>6){let X=S[Ie(Math.min(c.current,b))],Be=S[Ie(Math.max(c.current,b))];o({from:e[X.index],to:e[Be.index]})}c.current=null,Y(null)}function T(){w(null),f(null),s?.(null),c.current===null&&Y(null)}let M=v===null?null:S[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":Te,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${d} ${n}`,preserveAspectRatio:"none",onPointerMove:ke,onPointerDown:Pe,onPointerUp:Fr,onPointerCancel:T,onPointerLeave:T,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${K}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),I?st.jsx("rect",{x:Math.min(I.a,I.b),y:0,width:Math.abs(I.b-I.a),height:n,fill:"currentColor",opacity:.12}):null,M?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:M.x,x2:M.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:M.x,cy:M.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:ue.x,cy:ue.y,r:2.25,fill:"currentColor"})]}),st.jsx(xI,{tip:h})]})}var ot=he(Er(),1),BI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},DI={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function NI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:d,onSparkHover:y,onSparkBrush:v}){let[w,I]=SI.useState(null),Y=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),w?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:w.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):w?Pd(w.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${BI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:DI[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",f=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(II,{values:a,labels:l,onHover:m=>{I(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return d?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>d(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:Y}),f]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[Y,f]})}var gL=he(Er(),1);var Xr=he(Er(),1);function Vp({tone:t,title:e,message:n}){let r=t==="danger";return Xr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Xr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Xr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Xr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Xr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function TI({title:t="Loading",message:e="Loading metrics\u2026"}){return Xr.jsx(Vp,{tone:"loading",title:t,message:e})}function OI({title:t="No results",message:e}){return Xr.jsx(Vp,{tone:"muted",title:t,message:e})}function EI({title:t="Query failed",message:e}){return Xr.jsx(Vp,{tone:"danger",title:t,message:e})}var Sv=new WeakMap;function lf(t,e){let n=Sv.get(t);n||(t.replaceChildren(),n=U1.createRoot(t),Sv.set(t,n)),R1.flushSync(()=>n.render(e))}function FI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??Vc(e)}function fw(t,e){return typeof t=="function"?t(e):t}function kI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function AI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:kI(n)}}function dw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];lf(t,Jt.createElement(Jt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=Vc(s);return Jt.createElement(NI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:fw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function $p(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;lf(t,Jt.createElement(Jt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=AI({dimensions:[o],metrics:[n.metricRef],result:a}),u=FI(l),c=r===o;return Jt.createElement(wI,{key:o,dimension:o,title:s.label??Vc(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??Vc(n.metricRef),rows:u.map(d=>({value:Ji(d[zd(l,o)]),metric:Number(d[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:d=>jp(d,fw(n.valueFormat,{metric:n.metricRef,value:d})),onToggle:n.onSelect?d=>n.onSelect({dimension:o,value:d,row:u.find(y=>Ji(y[zd(l,o)])===d)}):void 0,onExpandedChange:n.expandable===!1?void 0:d=>{t.__sdmExpandedDim=d?o:void 0,$p(t,e,n)}})})))}function hw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return Jt.createElement(wv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(Jt.createElement(wv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));lf(t,i.length?Jt.createElement(Jt.Fragment,null,...i):r.emptyLabel?Jt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function pw(t,e){let n=e.kind==="error"?EI:e.kind==="loading"?TI:OI;lf(t,Jt.createElement(n,{message:e.message}))}function Wp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function mw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function yw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function gw(t,e){let n=mw(t),r=mw(e);if(!n||!r){let a=Wp(t),l=Wp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=yw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=yw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function LI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r
@@ -37,4 +37,4 @@ Error generating stack: `+s.message+`
- `;let n=e.querySelector(".filter-pills"),r=e.querySelector(".metrics-col"),i=e.querySelector(".dimensions-grid"),s=e.querySelector(".metric-select"),o=e.querySelector(".grain-select"),a=e.querySelector(".widget-status"),l=null;function u(){return t.get("filters")||{}}function c(S){t.set("filters",S),t.save_changes()}function d(){l&&clearTimeout(l),l=setTimeout(()=>{t.set("active_dimension",""),t.save_changes()},400)}function y(){l&&(clearTimeout(l),l=null),t.set("active_dimension","")}function v(S,K){t.set("active_dimension",S),c(ow(u(),S,K)),d()}function w(S,K){y(),c(aw(u(),S,K))}function I(S,K){S&&K?(y(),t.set("brush_selection",[S,K])):t.set("brush_selection",[]),t.save_changes()}function Y(){y(),t.set("brush_selection",[]),t.save_changes()}function h(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"",L=t.get("date_range")||[],ue=t.get("brush_selection")||[],Te=ue&&ue.length===2?ue:L,Re=t.get("metric_totals")||{},ke=(t.get("transport")||"base64")==="binary"?t.get("metric_series_data_binary"):t.get("metric_series_data");if(!ke||ke.byteLength!==void 0&&ke.byteLength===0){pw(r,{kind:"loading",message:"Loading metrics\u2026"});return}try{let Pe=vw(ke);if(!Pe){r.innerHTML='
Failed to parse data
';return}let M=(t.get("config")||{}).time_series_column||Object.keys(Pe[0]||{}).find(b=>b.includes("time")||b.includes("date")||b==="__time"),B=M?Pe.map(b=>Wp(b[M])):[];dw(r,{metrics:S,totals:{rows:[Re]},seriesRows:Pe,timeKey:M,selectedMetric:K,rangeLabel:Te?.length===2?gw(Te[0],Te[1]):"",valueFormat:b=>({format:S.find(X=>X.key===b)?.format}),onSelect:({metric:b})=>{t.set("selected_metric",b),t.save_changes()},onBrush:I})}catch(Pe){r.innerHTML=`
Error: ${Pe.message}
`}}function f(){let S=t.get("dimensions_config")||[],L=(t.get("transport")||"base64")==="binary"?t.get("dimension_data_binary")||{}:t.get("dimension_data")||{},ue=t.get("selected_metric")||"",Te=u(),Re=new Map;S.forEach(Ie=>{let ke=L[Ie.key];if(!ke||(typeof ke=="string"?ke.length===0:ke.byteLength===0)){Re.set(Ie.key,[]);return}try{let Pe=vw(ke);if(!Pe){Re.set(Ie.key,[]);return}Re.set(Ie.key,Pe)}catch{Re.set(Ie.key,[])}}),$p(i,S,{metricRef:ue,resultForDimension:Ie=>({rows:Re.get(Ie.key)||[]}),selectedValuesForDimension:Ie=>Te[Ie.key]||[],interactive:!0,expandable:!0,onSelect:({dimension:Ie,value:ke})=>v(Ie,ke)})}function m(){let S=u(),K=t.get("brush_selection")||[];hw(n,S,({dimension:L,value:ue})=>w(L,ue),{emptyLabel:"No filters",extraPills:K.length===2?[{key:"active-date-range",dimension:"__date_range",dimensionLabel:"Date",value:gw(K[0],K[1]),onRemove:Y}]:[]})}function g(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"";s.innerHTML=S.map(L=>``).join("")}function _(){let S=t.get("time_grain_options")||[],K=t.get("time_grain")||"";if(!S.length){o.innerHTML="",o.disabled=!0;return}o.disabled=!1,o.innerHTML=S.map(L=>{let ue=L.replace(/_/g," ").replace(/\b\w/g,Te=>Te.toUpperCase());return``}).join("")}function D(){let S=t.get("status")||"loading",K=t.get("error")||"";S==="error"&&K?(a.textContent=`Error: ${K}`,a.className="widget-status error"):S==="loading"?(a.textContent="Loading...",a.className="widget-status loading"):(a.textContent="",a.className="widget-status")}function N(){D(),m(),g(),_(),h(),f()}return s.addEventListener("change",S=>{y(),t.set("selected_metric",S.target.value),t.save_changes()}),o.addEventListener("change",S=>{t.set("time_grain",S.target.value),t.save_changes()}),t.on("change:metric_series_data",h),t.on("change:metric_totals",h),t.on("change:dimension_data",f),t.on("change:filters",()=>{m(),f()}),t.on("change:brush_selection",m),t.on("change:selected_metric",()=>{g(),h()}),t.on("change:time_grain",_),t.on("change:status",D),t.on("change:error",D),t.on("change:metrics_config",N),t.on("change:dimensions_config",N),t.on("change:time_grain_options",_),N(),()=>{t.off("change:metric_series_data",h),t.off("change:metric_totals",h),t.off("change:dimension_data",f),t.off("change:filters"),t.off("change:brush_selection",m),t.off("change:selected_metric"),t.off("change:time_grain",_),t.off("change:status",D),t.off("change:error",D),t.off("change:metrics_config",N),t.off("change:dimensions_config",N),t.off("change:time_grain_options",_)}}var _L={render:AI};export{_L as default}; + `;let n=e.querySelector(".filter-pills"),r=e.querySelector(".metrics-col"),i=e.querySelector(".dimensions-grid"),s=e.querySelector(".metric-select"),o=e.querySelector(".grain-select"),a=e.querySelector(".widget-status"),l=null;function u(){return t.get("filters")||{}}function c(S){t.set("filters",S),t.save_changes()}function d(){l&&clearTimeout(l),l=setTimeout(()=>{t.set("active_dimension",""),t.save_changes()},400)}function y(){l&&(clearTimeout(l),l=null),t.set("active_dimension","")}function v(S,K){t.set("active_dimension",S),c(ow(u(),S,K)),d()}function w(S,K){y(),c(aw(u(),S,K))}function I(S,K){S&&K?(y(),t.set("brush_selection",[S,K])):t.set("brush_selection",[]),t.save_changes()}function Y(){y(),t.set("brush_selection",[]),t.save_changes()}function h(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"",L=t.get("date_range")||[],ue=t.get("brush_selection")||[],Te=ue&&ue.length===2?ue:L,Re=t.get("metric_totals")||{},ke=(t.get("transport")||"base64")==="binary"?t.get("metric_series_data_binary"):t.get("metric_series_data");if(!ke||ke.byteLength!==void 0&&ke.byteLength===0){pw(r,{kind:"loading",message:"Loading metrics\u2026"});return}try{let Pe=vw(ke);if(!Pe){r.innerHTML='
Failed to parse data
';return}let M=(t.get("config")||{}).time_series_column||Object.keys(Pe[0]||{}).find(b=>b.includes("time")||b.includes("date")||b==="__time"),B=M?Pe.map(b=>Wp(b[M])):[];dw(r,{metrics:S,totals:{rows:[Re]},seriesRows:Pe,timeKey:M,selectedMetric:K,rangeLabel:Te?.length===2?gw(Te[0],Te[1]):"",valueFormat:b=>({format:S.find(X=>X.key===b)?.format}),onSelect:({metric:b})=>{t.set("selected_metric",b),t.save_changes()},onBrush:I})}catch(Pe){r.innerHTML=`
Error: ${Pe.message}
`}}function f(){let S=t.get("dimensions_config")||[],L=(t.get("transport")||"base64")==="binary"?t.get("dimension_data_binary")||{}:t.get("dimension_data")||{},ue=t.get("selected_metric")||"",Te=u(),Re=new Map;S.forEach(Ie=>{let ke=L[Ie.key];if(!ke||(typeof ke=="string"?ke.length===0:ke.byteLength===0)){Re.set(Ie.key,[]);return}try{let Pe=vw(ke);if(!Pe){Re.set(Ie.key,[]);return}Re.set(Ie.key,Pe)}catch{Re.set(Ie.key,[])}}),$p(i,S,{metricRef:ue,resultForDimension:Ie=>({rows:Re.get(Ie.key)||[]}),selectedValuesForDimension:Ie=>Te[Ie.key]||[],interactive:!0,expandable:!0,onSelect:({dimension:Ie,value:ke})=>v(Ie,ke)})}function m(){let S=u(),K=t.get("brush_selection")||[];hw(n,S,({dimension:L,value:ue})=>w(L,ue),{emptyLabel:"No filters",extraPills:K.length===2?[{key:"active-date-range",dimension:"__date_range",dimensionLabel:"Date",value:gw(K[0],K[1]),onRemove:Y}]:[]})}function g(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"";s.innerHTML=S.map(L=>``).join("")}function _(){let S=t.get("time_grain_options")||[],K=t.get("time_grain")||"";if(!S.length){o.innerHTML="",o.disabled=!0;return}o.disabled=!1,o.innerHTML=S.map(L=>{let ue=L.replace(/_/g," ").replace(/\b\w/g,Te=>Te.toUpperCase());return``}).join("")}function D(){let S=t.get("status")||"loading",K=t.get("error")||"";S==="error"&&K?(a.textContent=`Error: ${K}`,a.className="widget-status error"):S==="loading"?(a.textContent="Loading...",a.className="widget-status loading"):(a.textContent="",a.className="widget-status")}function N(){D(),m(),g(),_(),h(),f()}return s.addEventListener("change",S=>{y(),t.set("selected_metric",S.target.value),t.save_changes()}),o.addEventListener("change",S=>{t.set("time_grain",S.target.value),t.save_changes()}),t.on("change:metric_series_data",h),t.on("change:metric_totals",h),t.on("change:dimension_data",f),t.on("change:filters",()=>{m(),f()}),t.on("change:brush_selection",m),t.on("change:selected_metric",()=>{g(),h()}),t.on("change:time_grain",_),t.on("change:status",D),t.on("change:error",D),t.on("change:metrics_config",N),t.on("change:dimensions_config",N),t.on("change:time_grain_options",_),N(),()=>{t.off("change:metric_series_data",h),t.off("change:metric_totals",h),t.off("change:dimension_data",f),t.off("change:filters"),t.off("change:brush_selection",m),t.off("change:selected_metric"),t.off("change:time_grain",_),t.off("change:status",D),t.off("change:error",D),t.off("change:metrics_config",N),t.off("change:dimensions_config",N),t.off("change:time_grain_options",_)}}var SL={render:MI};export{SL as default}; diff --git a/webapp/playwright.ui.config.ts b/webapp/playwright.ui.config.ts new file mode 100644 index 000000000..d69c5966f --- /dev/null +++ b/webapp/playwright.ui.config.ts @@ -0,0 +1,16 @@ +import { defineConfig, devices } from "@playwright/test"; + +// Controlled HTTP responses exercise real browser layout without a native backend build. +export default defineConfig({ + testDir: "./tests", + testMatch: "filter-popovers.spec.ts", + workers: 1, + reporter: "list", + use: { baseURL: "http://127.0.0.1:4548", trace: "retain-on-failure" }, + webServer: { + command: "bun run dev --host 127.0.0.1 --port 4548", + url: "http://127.0.0.1:4548", + reuseExistingServer: false, + }, + projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }], +}); diff --git a/webapp/src/components/AddFilter.tsx b/webapp/src/components/AddFilter.tsx index 115c5d530..44bd1b1d3 100644 --- a/webapp/src/components/AddFilter.tsx +++ b/webapp/src/components/AddFilter.tsx @@ -3,6 +3,7 @@ import type { CatalogDimension, CatalogModel } from "../data/types"; import { joinedDimensionsForModel } from "../lib/catalog"; import { useExplorer } from "../state/ExplorerContext"; import { FilterEditor } from "./FilterEditor"; +import { useFilterPopover } from "./useFilterPopover"; /** "+ Filter" affordance: pick a dimension, then edit its filter in the same popover. Non-time * dimensions only (time is filtered via the date-range control). */ @@ -12,6 +13,8 @@ export function AddFilter({ model }: { model: CatalogModel }) { const [open, setOpen] = useState(false); const [picked, setPicked] = useState(null); const rootRef = useRef(null); + const menuRef = useRef(null); + useFilterPopover(menuRef, open && !picked); useEffect(() => { if (!open) return; @@ -51,9 +54,10 @@ export function AddFilter({ model }: { model: CatalogModel }) { {open && !picked ? (
{dims.map((dim) => ( diff --git a/webapp/src/components/AppShell.tsx b/webapp/src/components/AppShell.tsx index a7e87aa9e..82da5ad83 100644 --- a/webapp/src/components/AppShell.tsx +++ b/webapp/src/components/AppShell.tsx @@ -102,8 +102,8 @@ export function AppShell({ brand, toolbar, filters, rail, children, drawer, show {filters ? ( - // Fixed height so the bar doesn't jump when pills replace the "No filters" text. -
+ // Wrap crowded filters and keep their popovers above the stage without clipping them. +
{filters}
) : null} @@ -156,7 +156,7 @@ export function AppShell({ brand, toolbar, filters, rail, children, drawer, show ) : null} -
+
{children}
{drawer}
diff --git a/webapp/src/components/FilterEditor.tsx b/webapp/src/components/FilterEditor.tsx index ce329a609..c89f057fd 100644 --- a/webapp/src/components/FilterEditor.tsx +++ b/webapp/src/components/FilterEditor.tsx @@ -5,6 +5,7 @@ import { dashboardTabConfig } from "../lib/dashboard"; import { catalogDimTypes, composeFilters, distinctValues, containsExpr, type FilterMode } from "../lib/queries"; import { useExplorer } from "../state/ExplorerContext"; import { useQueryResult } from "../state/useQueryResult"; +import { useFilterPopover } from "./useFilterPopover"; const MODES: { mode: FilterMode; label: string }[] = [ { mode: "include", label: "Include" }, @@ -55,6 +56,7 @@ export function FilterEditor({ const selected = useMemo(() => new Set(filter?.mode !== "contains" ? (filter?.values ?? []) : []), [filter]); const panelRef = useRef(null); + useFilterPopover(panelRef); const searchRef = useRef(null); const labelId = useId(); @@ -169,15 +171,15 @@ export function FilterEditor({ aria-modal="true" aria-labelledby={labelId} onKeyDown={onKeyDown} - className="absolute left-0 z-50 mt-1 w-64 border border-line bg-surface p-2 text-2xs shadow-lg" + className="absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg" >
- {dim.label} + {dim.label} @@ -244,9 +246,9 @@ export function FilterEditor({ type="checkbox" checked={checked} onChange={() => dispatch({ type: "toggleFilter", dim: dim.ref, value, mode })} - className="size-3 accent-[var(--accent)]" + className="size-3 shrink-0 accent-[var(--accent)]" /> - {displayDimValue(value)} + {displayDimValue(value)} ); }) diff --git a/webapp/src/components/useFilterPopover.ts b/webapp/src/components/useFilterPopover.ts new file mode 100644 index 000000000..318085774 --- /dev/null +++ b/webapp/src/components/useFilterPopover.ts @@ -0,0 +1,34 @@ +import { useLayoutEffect, type RefObject } from "react"; + +/** Keep a filter popup below its chip and inside the viewport, including after pills wrap. */ +export function useFilterPopover(ref: RefObject, open = true) { + // Run after each render: adding a pill can move this anchor without resizing it. + useLayoutEffect(() => { + const panel = ref.current; + const anchor = panel?.parentElement; + if (!open || !panel || !anchor) return; + + function position() { + if (!panel || !anchor) return; + const bounds = anchor.getBoundingClientRect(); + const gutter = 8; + const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); + panel.style.left = `${left - bounds.left}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + } + + position(); + const observer = new ResizeObserver(position); + observer.observe(panel); + observer.observe(anchor); + // A sibling pill can wrap without changing this anchor's own size. + if (anchor.parentElement) observer.observe(anchor.parentElement); + window.addEventListener("resize", position); + window.addEventListener("scroll", position, true); + return () => { + observer.disconnect(); + window.removeEventListener("resize", position); + window.removeEventListener("scroll", position, true); + }; + }); +} diff --git a/webapp/tests/filter-popovers.spec.ts b/webapp/tests/filter-popovers.spec.ts new file mode 100644 index 000000000..0f6877ab4 --- /dev/null +++ b/webapp/tests/filter-popovers.spec.ts @@ -0,0 +1,112 @@ +import { expect, test, type Locator, type Page } from "@playwright/test"; + +const dimensions = ["status", "country", "device", "platform", "campaign", "channel"]; +const prefix = "A shared campaign prefix with enough detail to span several lines ".repeat(3); +const values = [`${prefix}first ending`, `${prefix}second ending`, "x".repeat(180)]; + +async function mockCatalog(page: Page) { + await page.route("**/*", async (route) => { + const path = new URL(route.request().url()).pathname; + const json = (body: unknown, status = 200) => route.fulfill({ status, json: body }); + if (path === "/health") return json({ status: "ok" }); + if (path === "/describe") return json({ + models: [{ + name: "activity", + dimensions: dimensions.map((name) => ({ name, type: "categorical" })), + metrics: [{ name: "revenue", agg: "sum" }], + }], + }); + if (path === "/graph") return json({ joinable_pairs: [] }); + if (path === "/dashboard") return json({ detail: "No dashboard configured" }, 404); + if (path === "/query") { + const query = route.request().postDataJSON(); + const rows = values.map((value) => Object.fromEntries([ + ...(query.dimensions ?? []).map((ref: string) => [ref.split(".").at(-1), value]), + ...(query.metrics ?? []).map((ref: string) => [ref.split(".").at(-1), 100]), + ])); + return json({ rows, row_count: rows.length, sql: "select 1" }); + } + return route.continue(); + }); +} + +async function expectInsideViewport(panel: Locator) { + await expect.poll(() => panel.evaluate((element) => { + const box = element.getBoundingClientRect(); + return { left: box.left >= 0, right: box.right <= innerWidth, top: box.top >= 0, bottom: box.bottom <= innerHeight }; + })).toEqual({ left: true, right: true, top: true, bottom: true }); + await expect.poll(() => panel.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true); +} + +async function expectHit(target: Locator) { + await target.scrollIntoViewIfNeeded(); + await expect.poll(() => target.evaluate((element) => { + const box = element.getBoundingClientRect(); + return element.contains(document.elementFromPoint(box.x + box.width / 2, box.y + box.height / 2)); + })).toBe(true); +} + +for (const width of [1280, 390, 320]) { + test(`filter menu and editor remain usable at ${width}px`, async ({ page }) => { + await page.setViewportSize({ width, height: 760 }); + await mockCatalog(page); + await page.goto("/?view=explore&model=activity&metric=activity.revenue"); + await page.getByRole("button", { name: "+ Filter" }).click(); + const menu = page.getByRole("menu"); + await expectInsideViewport(menu); + const channel = menu.getByRole("menuitem", { name: "Channel", exact: true }); + await expectHit(channel); + await channel.click(); + + const editor = page.getByRole("dialog", { name: /^Channel/ }); + await expectInsideViewport(editor); + await editor.getByRole("button", { name: "Exclude", exact: true }).click(); + const first = editor.getByRole("checkbox", { name: values[0], exact: true }); + await first.check(); + await expect(first).toBeChecked(); + await expectInsideViewport(editor); + const second = editor.getByRole("checkbox", { name: values[1], exact: true }); + await second.check(); + await expect(second).toBeChecked(); + // Both suffixes are rendered as wrapped text, not hidden by ellipsis. + for (const value of values) { + const text = editor.locator("label span").filter({ hasText: value }); + await expect(text).toHaveCSS("white-space", "normal"); + expect(await text.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true); + } + await expectHit(editor.getByRole("button", { name: "Done", exact: true })); + await editor.getByRole("button", { name: "Done", exact: true }).click(); + const pill = page.getByRole("button", { name: "Edit filter Channel", exact: true }); + await pill.click(); + await expectInsideViewport(editor); + await editor.getByRole("button", { name: "Clear", exact: true }).click(); + await expect(pill).toHaveCount(0); + }); +} + +test("crowded pills wrap and right-edge popovers follow viewport resizing", async ({ page }) => { + await page.setViewportSize({ width: 900, height: 640 }); + await mockCatalog(page); + const filters = Object.fromEntries(dimensions.map((dim) => [`activity.${dim}`, { mode: "include", values: ["Selected campaign value"] }])); + const params = new URLSearchParams({ view: "explore", model: "activity", metric: "activity.revenue", filters: JSON.stringify(filters) }); + await page.goto(`/?${params}`); + const pills = page.getByRole("button", { name: /^Edit filter / }); + await expect(pills).toHaveCount(dimensions.length); + const positions = await pills.evaluateAll((elements) => elements.map((element) => element.getBoundingClientRect().y)); + expect(new Set(positions).size).toBeGreaterThan(1); + const rightmost = await pills.evaluateAll((elements) => elements.reduce((index, element, next) => element.getBoundingClientRect().right > elements[index].getBoundingClientRect().right ? next : index, 0)); + await pills.nth(rightmost).click(); + const editor = page.getByRole("dialog"); + await expectInsideViewport(editor); + await page.setViewportSize({ width: 320, height: 640 }); + await expectInsideViewport(editor); + await expectHit(editor.getByRole("button", { name: "Done", exact: true })); + await editor.getByRole("button", { name: "Done", exact: true }).click(); + await page.setViewportSize({ width: 320, height: 480 }); + await page.getByRole("button", { name: "+ Filter" }).click(); + await expectInsideViewport(page.getByRole("menu")); + await page.getByRole("menuitem", { name: "Channel", exact: true }).click(); + await expectInsideViewport(editor); + await editor.getByRole("button", { name: "Done", exact: true }).click(); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true); +}); From 3d21ba59a3ace36fe5eacf8f1f1b4187e630310d Mon Sep 17 00:00:00 2001 From: Nico Ritschel Date: Mon, 19 Oct 2026 13:42:50 -0700 Subject: [PATCH 2/2] Bound the filter strip and portal its popovers --- .../sidemantic/sidemantic-ui-static.js | 40 +++++---- .../components/sidemantic/sidemantic-ui.css | 2 +- .../assets/ui-dist/sidemantic-ui-static.js | 40 +++++---- .../assets/ui-dist/sidemantic-ui.css | 2 +- .../assets/ui-dist/sidemantic-ui.js | 86 +++++++++++-------- sidemantic-rs/ui/assets/index-BCalwD9m.css | 1 - .../{index-gv_X5qC6.js => index-BizYMIT7.js} | 28 +++--- sidemantic-rs/ui/assets/index-DBXs5BBH.css | 1 + sidemantic-rs/ui/index.html | 4 +- .../ui/static/assets/index-BCalwD9m.css | 1 - .../{index-gv_X5qC6.js => index-BizYMIT7.js} | 28 +++--- .../ui/static/assets/index-DBXs5BBH.css | 1 + sidemantic/ui/static/index.html | 4 +- sidemantic/widget/static/widget.css | 2 +- sidemantic/widget/static/widget.js | 16 ++-- webapp/src/components/AddFilter.tsx | 21 +++-- webapp/src/components/AppShell.tsx | 4 +- webapp/src/components/FilterEditor.tsx | 20 +++-- webapp/src/components/FilterPill.tsx | 6 +- webapp/src/components/useFilterPopover.ts | 18 ++-- webapp/tests/filter-popovers.spec.ts | 48 ++++++++++- 21 files changed, 233 insertions(+), 140 deletions(-) delete mode 100644 sidemantic-rs/ui/assets/index-BCalwD9m.css rename sidemantic-rs/ui/assets/{index-gv_X5qC6.js => index-BizYMIT7.js} (57%) create mode 100644 sidemantic-rs/ui/assets/index-DBXs5BBH.css delete mode 100644 sidemantic/ui/static/assets/index-BCalwD9m.css rename sidemantic/ui/static/assets/{index-gv_X5qC6.js => index-BizYMIT7.js} (57%) create mode 100644 sidemantic/ui/static/assets/index-DBXs5BBH.css diff --git a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js index 64e225643..8957bf92c 100644 --- a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js +++ b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui-static.js @@ -7661,7 +7661,7 @@ var require_jsx_runtime = __commonJS(function(exports, module) { // webapp/src/static-api.tsx var import_react11 = __toESM(require_react(), 1); var import_client = __toESM(require_client(), 1); -var import_react_dom = __toESM(require_react_dom(), 1); +var import_react_dom2 = __toESM(require_react_dom(), 1); // webapp/src/components/DataTable.tsx var import_react = __toESM(require_react(), 1); @@ -7991,6 +7991,7 @@ function filterSummary(filter) { // webapp/src/components/FilterEditor.tsx var import_react6 = __toESM(require_react(), 1); +var import_react_dom = __toESM(require_react_dom(), 1); // webapp/src/lib/catalog.ts function graphMetricsForModel(catalog, modelName) { @@ -8264,27 +8265,32 @@ function useQueryResult(backend, query) { // webapp/src/components/useFilterPopover.ts var import_react5 = __toESM(require_react(), 1); -function useFilterPopover(ref, open = true) { +function useFilterPopover(ref, anchorRef, open = true) { import_react5.useLayoutEffect(() => { const panel = ref.current; - const anchor = panel?.parentElement; + const anchor = anchorRef.current; if (!open || !panel || !anchor) return; function position() { if (!panel || !anchor) return; const bounds = anchor.getBoundingClientRect(); + const strip2 = anchor.closest("[data-filter-strip]")?.getBoundingClientRect(); const gutter = 8; const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); - panel.style.left = `${left - bounds.left}px`; - panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + const bottom = strip2 ? Math.max(strip2.top, Math.min(bounds.bottom, strip2.bottom)) : bounds.bottom; + const top = Math.max(gutter, Math.min(bottom + 4, window.innerHeight - gutter)); + panel.style.left = `${left}px`; + panel.style.top = `${top}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - top - gutter)}px`); } position(); const observer = new ResizeObserver(position); observer.observe(panel); observer.observe(anchor); - if (anchor.parentElement) - observer.observe(anchor.parentElement); + const strip = anchor.closest("[data-filter-strip]"); + if (strip) + observer.observe(strip); window.addEventListener("resize", position); window.addEventListener("scroll", position, true); return () => { @@ -8315,6 +8321,7 @@ function useDebounced(value, delayMs) { function FilterEditor({ dim, model, + anchorRef, onClose }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); @@ -8323,7 +8330,7 @@ function FilterEditor({ const [mode, setModeState] = import_react6.useState(filter?.mode ?? "include"); const selected = import_react6.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); const panelRef = import_react6.useRef(null); - useFilterPopover(panelRef); + useFilterPopover(panelRef, anchorRef); const searchRef = import_react6.useRef(null); const labelId = import_react6.useId(); const [search, setSearch] = import_react6.useState(""); @@ -8332,10 +8339,10 @@ function FilterEditor({ const [patternDraft, setPatternDraft] = import_react6.useState(pattern); const debouncedPattern = useDebounced(patternDraft, SEARCH_DEBOUNCE_MS); import_react6.useEffect(() => { - const opener = document.activeElement; + const opener = anchorRef.current; searchRef.current?.focus(); - return () => opener?.focus?.(); - }, []); + return () => opener?.focus({ preventScroll: true }); + }, [anchorRef]); import_react6.useEffect(() => { function onKey(event) { if (event.key === "Escape") { @@ -8410,13 +8417,13 @@ function FilterEditor({ first.focus(); } } - return /* @__PURE__ */ jsx_runtime2.jsxs("div", { + return import_react_dom.createPortal(/* @__PURE__ */ jsx_runtime2.jsxs("div", { ref: panelRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", + className: "fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsx_runtime2.jsxs("div", { id: labelId, @@ -8520,13 +8527,14 @@ function FilterEditor({ ] }) ] - }); + }), document.body); } // webapp/src/components/FilterPill.tsx var jsx_runtime3 = __toESM(require_jsx_runtime(), 1); function FilterPill(props) { const [open, setOpen] = import_react7.useState(false); + const buttonRef = import_react7.useRef(null); if (!("dim" in props)) { return /* @__PURE__ */ jsx_runtime3.jsxs("span", { "data-dimension": props.dimension, @@ -8567,6 +8575,7 @@ function FilterPill(props) { className: "inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted", children: [ /* @__PURE__ */ jsx_runtime3.jsxs("button", { + ref: buttonRef, type: "button", "aria-label": `Edit filter ${dim.label}`, "aria-haspopup": "dialog", @@ -8594,6 +8603,7 @@ function FilterPill(props) { open ? /* @__PURE__ */ jsx_runtime3.jsx(FilterEditor, { dim, model, + anchorRef: buttonRef, onClose: () => setOpen(false) }) : null ] @@ -9298,7 +9308,7 @@ function mount(container, node) { root = import_client.createRoot(container); roots.set(container, root); } - import_react_dom.flushSync(() => root.render(node)); + import_react_dom2.flushSync(() => root.render(node)); } function rowsOf(query) { return query.result?.sample_rows ?? query.result?.rows ?? []; diff --git a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css index 8b6236f17..2e925c9ce 100644 --- a/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css +++ b/examples/sidemantic_wasm_demo/src/components/sidemantic/sidemantic-ui.css @@ -1 +1 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[min\(25dvh\2c 8rem\)\]{max-height:min(25dvh,8rem)}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js index 64e225643..8957bf92c 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui-static.js @@ -7661,7 +7661,7 @@ var require_jsx_runtime = __commonJS(function(exports, module) { // webapp/src/static-api.tsx var import_react11 = __toESM(require_react(), 1); var import_client = __toESM(require_client(), 1); -var import_react_dom = __toESM(require_react_dom(), 1); +var import_react_dom2 = __toESM(require_react_dom(), 1); // webapp/src/components/DataTable.tsx var import_react = __toESM(require_react(), 1); @@ -7991,6 +7991,7 @@ function filterSummary(filter) { // webapp/src/components/FilterEditor.tsx var import_react6 = __toESM(require_react(), 1); +var import_react_dom = __toESM(require_react_dom(), 1); // webapp/src/lib/catalog.ts function graphMetricsForModel(catalog, modelName) { @@ -8264,27 +8265,32 @@ function useQueryResult(backend, query) { // webapp/src/components/useFilterPopover.ts var import_react5 = __toESM(require_react(), 1); -function useFilterPopover(ref, open = true) { +function useFilterPopover(ref, anchorRef, open = true) { import_react5.useLayoutEffect(() => { const panel = ref.current; - const anchor = panel?.parentElement; + const anchor = anchorRef.current; if (!open || !panel || !anchor) return; function position() { if (!panel || !anchor) return; const bounds = anchor.getBoundingClientRect(); + const strip2 = anchor.closest("[data-filter-strip]")?.getBoundingClientRect(); const gutter = 8; const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); - panel.style.left = `${left - bounds.left}px`; - panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + const bottom = strip2 ? Math.max(strip2.top, Math.min(bounds.bottom, strip2.bottom)) : bounds.bottom; + const top = Math.max(gutter, Math.min(bottom + 4, window.innerHeight - gutter)); + panel.style.left = `${left}px`; + panel.style.top = `${top}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - top - gutter)}px`); } position(); const observer = new ResizeObserver(position); observer.observe(panel); observer.observe(anchor); - if (anchor.parentElement) - observer.observe(anchor.parentElement); + const strip = anchor.closest("[data-filter-strip]"); + if (strip) + observer.observe(strip); window.addEventListener("resize", position); window.addEventListener("scroll", position, true); return () => { @@ -8315,6 +8321,7 @@ function useDebounced(value, delayMs) { function FilterEditor({ dim, model, + anchorRef, onClose }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); @@ -8323,7 +8330,7 @@ function FilterEditor({ const [mode, setModeState] = import_react6.useState(filter?.mode ?? "include"); const selected = import_react6.useMemo(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); const panelRef = import_react6.useRef(null); - useFilterPopover(panelRef); + useFilterPopover(panelRef, anchorRef); const searchRef = import_react6.useRef(null); const labelId = import_react6.useId(); const [search, setSearch] = import_react6.useState(""); @@ -8332,10 +8339,10 @@ function FilterEditor({ const [patternDraft, setPatternDraft] = import_react6.useState(pattern); const debouncedPattern = useDebounced(patternDraft, SEARCH_DEBOUNCE_MS); import_react6.useEffect(() => { - const opener = document.activeElement; + const opener = anchorRef.current; searchRef.current?.focus(); - return () => opener?.focus?.(); - }, []); + return () => opener?.focus({ preventScroll: true }); + }, [anchorRef]); import_react6.useEffect(() => { function onKey(event) { if (event.key === "Escape") { @@ -8410,13 +8417,13 @@ function FilterEditor({ first.focus(); } } - return /* @__PURE__ */ jsx_runtime2.jsxs("div", { + return import_react_dom.createPortal(/* @__PURE__ */ jsx_runtime2.jsxs("div", { ref: panelRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", + className: "fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsx_runtime2.jsxs("div", { id: labelId, @@ -8520,13 +8527,14 @@ function FilterEditor({ ] }) ] - }); + }), document.body); } // webapp/src/components/FilterPill.tsx var jsx_runtime3 = __toESM(require_jsx_runtime(), 1); function FilterPill(props) { const [open, setOpen] = import_react7.useState(false); + const buttonRef = import_react7.useRef(null); if (!("dim" in props)) { return /* @__PURE__ */ jsx_runtime3.jsxs("span", { "data-dimension": props.dimension, @@ -8567,6 +8575,7 @@ function FilterPill(props) { className: "inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted", children: [ /* @__PURE__ */ jsx_runtime3.jsxs("button", { + ref: buttonRef, type: "button", "aria-label": `Edit filter ${dim.label}`, "aria-haspopup": "dialog", @@ -8594,6 +8603,7 @@ function FilterPill(props) { open ? /* @__PURE__ */ jsx_runtime3.jsx(FilterEditor, { dim, model, + anchorRef: buttonRef, onClose: () => setOpen(false) }) : null ] @@ -9298,7 +9308,7 @@ function mount(container, node) { root = import_client.createRoot(container); roots.set(container, root); } - import_react_dom.flushSync(() => root.render(node)); + import_react_dom2.flushSync(() => root.render(node)); } function rowsOf(query) { return query.result?.sample_rows ?? query.result?.rows ?? []; diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css index 8b6236f17..2e925c9ce 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.css @@ -1 +1 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[min\(25dvh\2c 8rem\)\]{max-height:min(25dvh,8rem)}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} \ No newline at end of file diff --git a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js index e7e482338..9907ca88b 100644 --- a/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js +++ b/plugins/sidemantic/skills/webapp-builder/assets/ui-dist/sidemantic-ui.js @@ -1271,10 +1271,11 @@ class ErrorBoundary extends Component { } } // webapp/src/components/FilterPill.tsx -import { useState as useState9 } from "react"; +import { useRef as useRef8, useState as useState9 } from "react"; // webapp/src/components/FilterEditor.tsx import { useEffect as useEffect8, useId, useMemo as useMemo3, useRef as useRef7, useState as useState8 } from "react"; +import { createPortal } from "react-dom"; // webapp/src/lib/catalog.ts function graphMetricsForModel(catalog, modelName) { @@ -1559,27 +1560,32 @@ function useQueryResult(backend, query) { // webapp/src/components/useFilterPopover.ts import { useLayoutEffect } from "react"; -function useFilterPopover(ref, open = true) { +function useFilterPopover(ref, anchorRef, open = true) { useLayoutEffect(() => { const panel = ref.current; - const anchor = panel?.parentElement; + const anchor = anchorRef.current; if (!open || !panel || !anchor) return; function position() { if (!panel || !anchor) return; const bounds = anchor.getBoundingClientRect(); + const strip2 = anchor.closest("[data-filter-strip]")?.getBoundingClientRect(); const gutter = 8; const left = Math.max(gutter, Math.min(bounds.left, window.innerWidth - panel.offsetWidth - gutter)); - panel.style.left = `${left - bounds.left}px`; - panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - bounds.bottom - gutter - 4)}px`); + const bottom = strip2 ? Math.max(strip2.top, Math.min(bounds.bottom, strip2.bottom)) : bounds.bottom; + const top = Math.max(gutter, Math.min(bottom + 4, window.innerHeight - gutter)); + panel.style.left = `${left}px`; + panel.style.top = `${top}px`; + panel.style.setProperty("--filter-popover-height", `${Math.max(0, window.innerHeight - top - gutter)}px`); } position(); const observer = new ResizeObserver(position); observer.observe(panel); observer.observe(anchor); - if (anchor.parentElement) - observer.observe(anchor.parentElement); + const strip = anchor.closest("[data-filter-strip]"); + if (strip) + observer.observe(strip); window.addEventListener("resize", position); window.addEventListener("scroll", position, true); return () => { @@ -1610,6 +1616,7 @@ function useDebounced(value, delayMs) { function FilterEditor({ dim, model, + anchorRef, onClose }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); @@ -1618,7 +1625,7 @@ function FilterEditor({ const [mode, setModeState] = useState8(filter?.mode ?? "include"); const selected = useMemo3(() => new Set(filter?.mode !== "contains" ? filter?.values ?? [] : []), [filter]); const panelRef = useRef7(null); - useFilterPopover(panelRef); + useFilterPopover(panelRef, anchorRef); const searchRef = useRef7(null); const labelId = useId(); const [search, setSearch] = useState8(""); @@ -1627,10 +1634,10 @@ function FilterEditor({ const [patternDraft, setPatternDraft] = useState8(pattern); const debouncedPattern = useDebounced(patternDraft, SEARCH_DEBOUNCE_MS); useEffect8(() => { - const opener = document.activeElement; + const opener = anchorRef.current; searchRef.current?.focus(); - return () => opener?.focus?.(); - }, []); + return () => opener?.focus({ preventScroll: true }); + }, [anchorRef]); useEffect8(() => { function onKey(event) { if (event.key === "Escape") { @@ -1705,13 +1712,13 @@ function FilterEditor({ first.focus(); } } - return /* @__PURE__ */ jsxs9("div", { + return createPortal(/* @__PURE__ */ jsxs9("div", { ref: panelRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelId, onKeyDown, - className: "absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", + className: "fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg", children: [ /* @__PURE__ */ jsxs9("div", { id: labelId, @@ -1815,13 +1822,14 @@ function FilterEditor({ ] }) ] - }); + }), document.body); } // webapp/src/components/FilterPill.tsx import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime"; function FilterPill(props) { const [open, setOpen] = useState9(false); + const buttonRef = useRef8(null); if (!("dim" in props)) { return /* @__PURE__ */ jsxs10("span", { "data-dimension": props.dimension, @@ -1862,6 +1870,7 @@ function FilterPill(props) { className: "inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted", children: [ /* @__PURE__ */ jsxs10("button", { + ref: buttonRef, type: "button", "aria-label": `Edit filter ${dim.label}`, "aria-haspopup": "dialog", @@ -1889,13 +1898,14 @@ function FilterPill(props) { open ? /* @__PURE__ */ jsx11(FilterEditor, { dim, model, + anchorRef: buttonRef, onClose: () => setOpen(false) }) : null ] }); } // webapp/src/components/HeatmapChart.tsx -import { useEffect as useEffect9, useRef as useRef8, useState as useState10 } from "react"; +import { useEffect as useEffect9, useRef as useRef9, useState as useState10 } from "react"; import { jsx as jsx12, jsxs as jsxs11, Fragment as Fragment4 } from "react/jsx-runtime"; var MARGIN3 = { top: 8, right: 8, bottom: 26, left: 76 }; function orderedLabels(cells, key, explicit) { @@ -1908,7 +1918,7 @@ function orderedLabels(cells, key, explicit) { return seen; } function HeatmapChart({ cells, xLabels, yLabels, height = 240, format = formatValue, ariaLabel }) { - const ref = useRef8(null); + const ref = useRef9(null); const [width, setWidth] = useState10(640); const { tip, handlers } = useChartTooltip(); useEffect9(() => observeWidth(ref.current, 240, setWidth), []); @@ -1982,7 +1992,7 @@ function HeatmapChart({ cells, xLabels, yLabels, height = 240, format = formatVa }); } // webapp/src/components/HistogramChart.tsx -import { useEffect as useEffect10, useRef as useRef9, useState as useState11 } from "react"; +import { useEffect as useEffect10, useRef as useRef10, useState as useState11 } from "react"; import { jsx as jsx13, jsxs as jsxs12, Fragment as Fragment5 } from "react/jsx-runtime"; function binValues(values, bins) { const finite = values.filter(Number.isFinite); @@ -2007,7 +2017,7 @@ function binValues(values, bins) { } var MARGIN4 = { top: 12, right: 14, bottom: 26, left: 44 }; function HistogramChart({ values, bins, height = 200, format = formatCompact, ariaLabel }) { - const ref = useRef9(null); + const ref = useRef10(null); const [width, setWidth] = useState11(640); const { tip, handlers } = useChartTooltip(); useEffect10(() => observeWidth(ref.current, 160, setWidth), []); @@ -2227,7 +2237,7 @@ function Leaderboard({ import { useState as useState13 } from "react"; // webapp/src/components/Sparkline.tsx -import { useEffect as useEffect11, useId as useId2, useRef as useRef10, useState as useState12 } from "react"; +import { useEffect as useEffect11, useId as useId2, useRef as useRef11, useState as useState12 } from "react"; import { jsx as jsx15, jsxs as jsxs14, Fragment as Fragment6 } from "react/jsx-runtime"; function Sparkline({ values, @@ -2238,10 +2248,10 @@ function Sparkline({ onHover, onBrush }) { - const containerRef = useRef10(null); + const containerRef = useRef11(null); const gradientId = useId2(); - const svgRef = useRef10(null); - const dragStart = useRef10(null); + const svgRef = useRef11(null); + const dragStart = useRef11(null); const [width, setWidth] = useState12(200); const [hover, setHover] = useState12(null); const [brush, setBrush] = useState12(null); @@ -2534,7 +2544,7 @@ function MetricCard({ }); } // webapp/src/components/NetworkChart.tsx -import { useEffect as useEffect12, useMemo as useMemo4, useRef as useRef11, useState as useState14 } from "react"; +import { useEffect as useEffect12, useMemo as useMemo4, useRef as useRef12, useState as useState14 } from "react"; import { jsx as jsx17, jsxs as jsxs16, Fragment as Fragment8 } from "react/jsx-runtime"; function hashSeed(text) { let hash = 2166136261; @@ -2631,7 +2641,7 @@ function layoutNetwork(nodes, links, { width = 640, height = 320, iterations = 1 })); } function NetworkChart({ nodes, links, height = 320, ariaLabel }) { - const ref = useRef11(null); + const ref = useRef12(null); const [width, setWidth] = useState14(640); const { tip, handlers } = useChartTooltip(); useEffect12(() => observeWidth(ref.current, 240, setWidth), []); @@ -2847,7 +2857,7 @@ ${sql}`).join(` }); } // webapp/src/components/ScatterChart.tsx -import { useEffect as useEffect13, useRef as useRef12, useState as useState15 } from "react"; +import { useEffect as useEffect13, useRef as useRef13, useState as useState15 } from "react"; import { jsx as jsx19, jsxs as jsxs18, Fragment as Fragment9 } from "react/jsx-runtime"; var MARGIN5 = { top: 12, right: 14, bottom: 30, left: 48 }; function ScatterChart({ @@ -2859,7 +2869,7 @@ function ScatterChart({ formatY = formatCompact, ariaLabel }) { - const ref = useRef12(null); + const ref = useRef13(null); const [width, setWidth] = useState15(640); const { tip, handlers } = useChartTooltip(); useEffect13(() => observeWidth(ref.current, 200, setWidth), []); @@ -2991,7 +3001,7 @@ function ScatterChart({ }); } // webapp/src/components/StackedAreaChart.tsx -import { useEffect as useEffect14, useRef as useRef13, useState as useState16 } from "react"; +import { useEffect as useEffect14, useRef as useRef14, useState as useState16 } from "react"; import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime"; var MARGIN6 = { top: 12, right: 14, bottom: 26, left: 48 }; function clamp2(value, min, max) { @@ -3005,7 +3015,7 @@ function StackedAreaChart({ formatLabel = (label) => label, ariaLabel }) { - const container = useRef13(null); + const container = useRef14(null); const [width, setWidth] = useState16(640); const [hover, setHover] = useState16(null); useEffect14(() => observeWidth(container.current, 240, setWidth), []); @@ -3212,7 +3222,7 @@ function StatusDot({ status }) { }); } // webapp/src/components/WaterfallChart.tsx -import { useEffect as useEffect15, useRef as useRef14, useState as useState17 } from "react"; +import { useEffect as useEffect15, useRef as useRef15, useState as useState17 } from "react"; import { jsx as jsx22, jsxs as jsxs21, Fragment as Fragment10 } from "react/jsx-runtime"; function waterfallSteps(data) { let running = 0; @@ -3229,7 +3239,7 @@ function waterfallSteps(data) { } var MARGIN7 = { top: 12, right: 14, bottom: 26, left: 48 }; function WaterfallChart({ data, height = 220, format = formatValue, ariaLabel }) { - const ref = useRef14(null); + const ref = useRef15(null); const [width, setWidth] = useState17(640); const { tip, handlers } = useChartTooltip(); useEffect15(() => observeWidth(ref.current, 200, setWidth), []); @@ -3359,7 +3369,7 @@ function Button({ variant = "secondary", size = "md", type = "button", className }); } // webapp/src/components/Combobox.tsx -import { useEffect as useEffect16, useId as useId3, useMemo as useMemo5, useRef as useRef15, useState as useState18 } from "react"; +import { useEffect as useEffect16, useId as useId3, useMemo as useMemo5, useRef as useRef16, useState as useState18 } from "react"; import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime"; function filterOptions(options, query) { const needle = query.trim().toLowerCase(); @@ -3370,7 +3380,7 @@ function filterOptions(options, query) { function Combobox(props) { const { options, placeholder = "Search…", ariaLabel, disabled, maxVisible = 50 } = props; const listId = useId3(); - const rootRef = useRef15(null); + const rootRef = useRef16(null); const [open, setOpen] = useState18(false); const [query, setQuery] = useState18(""); const [activeIndex, setActiveIndex] = useState18(0); @@ -3516,7 +3526,7 @@ function Combobox(props) { }); } // webapp/src/components/DatePicker.tsx -import { useRef as useRef16, useState as useState19 } from "react"; +import { useRef as useRef17, useState as useState19 } from "react"; import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime"; var WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; @@ -3554,7 +3564,7 @@ function DatePicker(props) { const [year, setYear] = useState19(() => Number((anchor ?? todayIso()).slice(0, 4))); const [monthIndex, setMonthIndex] = useState19(() => Number((anchor ?? todayIso()).slice(5, 7)) - 1); const [pending, setPending] = useState19(null); - const details = useRef16(null); + const details = useRef17(null); function shiftMonth(delta) { const next = new Date(Date.UTC(year, monthIndex + delta, 1)); setYear(next.getUTCFullYear()); @@ -3695,7 +3705,7 @@ function DatePicker(props) { }); } // webapp/src/components/DateRangeControl.tsx -import { useRef as useRef17, useState as useState20 } from "react"; +import { useRef as useRef18, useState as useState20 } from "react"; import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime"; var COMPARISON_OPTIONS = [ { key: "off", label: "Off" }, @@ -3711,7 +3721,7 @@ function DateRangeControl({ comparisonRange, onComparisonChange }) { - const details = useRef17(null); + const details = useRef18(null); const [from, setFrom] = useState20(range?.from ?? ""); const [to, setTo] = useState20(range?.to ?? ""); const [cmpFrom, setCmpFrom] = useState20(comparisonRange?.from ?? ""); @@ -4158,14 +4168,14 @@ function Tooltip({ content, children, className }) { }); } // webapp/src/components/ViewSwitcher.tsx -import { useRef as useRef18 } from "react"; +import { useRef as useRef19 } from "react"; import { jsx as jsx33 } from "react/jsx-runtime"; var SEGMENTS = [ { key: "explore", label: "Explore" }, { key: "pivot", label: "Pivot" } ]; function ViewSwitcher({ view, onChange }) { - const list = useRef18(null); + const list = useRef19(null); function move(direction) { const current = Math.max(0, SEGMENTS.findIndex((segment) => segment.key === view)); const next = SEGMENTS[(current + direction + SEGMENTS.length) % SEGMENTS.length]; diff --git a/sidemantic-rs/ui/assets/index-BCalwD9m.css b/sidemantic-rs/ui/assets/index-BCalwD9m.css deleted file mode 100644 index d502892bd..000000000 --- a/sidemantic-rs/ui/assets/index-BCalwD9m.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic-rs/ui/assets/index-gv_X5qC6.js b/sidemantic-rs/ui/assets/index-BizYMIT7.js similarity index 57% rename from sidemantic-rs/ui/assets/index-gv_X5qC6.js rename to sidemantic-rs/ui/assets/index-BizYMIT7.js index 706c5d746..e06b7effa 100644 --- a/sidemantic-rs/ui/assets/index-gv_X5qC6.js +++ b/sidemantic-rs/ui/assets/index-BizYMIT7.js @@ -1,4 +1,4 @@ -var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>cb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Ee={};/** +var ub=Object.defineProperty;var db=(n,e,t)=>e in n?ub(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>db(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Be={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var im;function ub(){if(im)return Ee;im=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.iterator;function b(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,C={};function T(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}T.prototype.isReactComponent={},T.prototype.setState=function(N,W){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,W,"setState")},T.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function $(){}$.prototype=T.prototype;function U(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}var B=U.prototype=new $;B.constructor=U,_(B,T.prototype),B.isPureReactComponent=!0;var F=Array.isArray,A=Object.prototype.hasOwnProperty,M={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function Y(N,W,J){var oe,te={},he=null,Ie=null;if(W!=null)for(oe in W.ref!==void 0&&(Ie=W.ref),W.key!==void 0&&(he=""+W.key),W)A.call(W,oe)&&!L.hasOwnProperty(oe)&&(te[oe]=W[oe]);var Fe=arguments.length-2;if(Fe===1)te.children=J;else if(1e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var am;function db(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function fb(){return lm||(lm=1,id.exports=db()),id.exports}var u=fb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** + */var am;function hb(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function pb(){return lm||(lm=1,id.exports=hb()),id.exports}var u=pb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var cm;function hb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,B(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(B(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),B(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function pb(){return um||(um=1,ld.exports=hb()),ld.exports}/** + */var cm;function mb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,V=O[N];if(0>>1;Na(q,H))cea(Ie,q)?(O[N]=Ie,O[ce]=H,N=ce):(O[N]=q,O[te]=H,N=te);else if(cea(Ie,H))O[N]=Ie,O[ce]=H,N=ce;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,E(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,P(Y),Y=-1),w=!0;var H=b;try{for(E(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!W());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var V=N(x.expirationTime<=G);G=n.unstable_now(),typeof V=="function"?x.callback=V:x===t(m)&&i(m),E(G)}else i(m);x=t(m)}if(x!==null)var de=!0;else{var te=t(g);te!==null&&re(F,te.startTime-G),de=!1}return de}finally{x=null,b=H,w=!1}}var M=!1,R=null,Y=-1,z=5,Q=-1;function W(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?(P(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=V,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function yb(){return um||(um=1,ld.exports=mb()),ld.exports}/** * @license React * react-dom.production.min.js * @@ -30,26 +30,26 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var dm;function mb(){if(dm)return zt;dm=1;var n=Vd(),e=pb();function t(r){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+r,o=1;o"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function B(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2S||d[y]!==h[S]){var j=` -`+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&B(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Er=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Er?Pn?Pn.push(r):Pn=[r]:Er=r}function Nf(){if(Er){var r=Er,s=Pn;if(Pn=Er=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(N0(r)/j0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function D0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return rx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ix(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ox(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function mx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Ix(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(E,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(E,ve),I=h(es,I,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(E,ze.value,ee),ze!==null&&(I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(E,De),pe}for(ve=l(E,ve);!ze.done;De++,ze=R.next())ze=se(ve,E,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ab){return s(E,ab)}),rt&&xs(E,De),pe}function ut(E,I,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(E,ge.sibling),I=d(ge,R.props.children),I.return=E,E=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Bh(pe)===ge.type){o(E,ge.sibling),I=d(ge,R.props),I.ref=yo(E,ge,R),I.return=E,E=I;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}R.type===L?(I=Is(R.props.children,E.mode,ee,R.key),I.return=E,E=I):(ee=il(R.type,R.key,R.props,null,E.mode,ee),ee.ref=yo(E,I,R),ee.return=E,E=ee)}return y(E);case M:e:{for(ge=R.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===R.containerInfo&&I.stateNode.implementation===R.implementation){o(E,I.sibling),I=d(I,R.children||[]),I.return=E,E=I;break e}else{o(E,I);break}else s(E,I);I=I.sibling}I=ed(R,E.mode,ee),I.return=E,E=I}return y(E);case ye:return ge=R._init,ut(E,I,ge(R._payload),ee)}if(Un(R))return ue(E,I,R,ee);if(G(R))return de(E,I,R,ee);Ea(E,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,I!==null&&I.tag===6?(o(E,I.sibling),I=d(I,R),I.return=E,E=I):(o(E,I),I=Xu(R,E.mode,ee),I.return=E,E=I),y(E)):o(E,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ba=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ba.current;et(Ba),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Fx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ox(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Tx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Fx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Cx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{de=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?V(r):""}function q(r){switch(r.tag){case 5:return V(r.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return r=te(r.type,!1),r;case 11:return r=te(r.type.render,!1),r;case 1:return r=te(r.type,!0),r;default:return""}}function ce(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case R:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case X:return"Suspense";case le:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case W:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case ne:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:ce(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return ce(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ce(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Me(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Me(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function oe(r,s){s=s.checked,s!=null&&E(r,"checked",s,!1)}function Oe(r,s){oe(r,s);var o=Me(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Me(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 he(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Br=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Br?Pn?Pn.push(r):Pn=[r]:Br=r}function Nf(){if(Br){var r=Br,s=Pn;if(Pn=Br=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(k0(r)/I0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function F0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return ix.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ax(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function lx(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function gx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Dx(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<Ce?(wt=ve,ve=null):wt=ve.sibling;var ze=K(B,ve,L[Ce],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(B,ve),I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(Ce===L.length)return o(B,ve),rt&&xs(B,Ce),pe;if(ve===null){for(;CeCe?(wt=ve,ve=null):wt=ve.sibling;var es=K(B,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(B,ve),I=h(es,I,Ce),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(B,ve),rt&&xs(B,Ce),pe;if(ve===null){for(;!ze.done;Ce++,ze=L.next())ze=Z(B,ze.value,ee),ze!==null&&(I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(B,Ce),pe}for(ve=l(B,ve);!ze.done;Ce++,ze=L.next())ze=se(ve,B,Ce,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?Ce:ze.key),I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(cb){return s(B,cb)}),rt&&xs(B,Ce),pe}function ut(B,I,L,ee){if(typeof L=="object"&&L!==null&&L.type===R&&L.key===null&&(L=L.props.children),typeof L=="object"&&L!==null){switch(L.$$typeof){case A:e:{for(var pe=L.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=L.type,pe===R){if(ge.tag===7){o(B,ge.sibling),I=d(ge,L.props.children),I.return=B,B=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Eh(pe)===ge.type){o(B,ge.sibling),I=d(ge,L.props),I.ref=yo(B,ge,L),I.return=B,B=I;break e}o(B,ge);break}else s(B,ge);ge=ge.sibling}L.type===R?(I=Is(L.props.children,B.mode,ee,L.key),I.return=B,B=I):(ee=il(L.type,L.key,L.props,null,B.mode,ee),ee.ref=yo(B,I,L),ee.return=B,B=ee)}return y(B);case M:e:{for(ge=L.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===L.containerInfo&&I.stateNode.implementation===L.implementation){o(B,I.sibling),I=d(I,L.children||[]),I.return=B,B=I;break e}else{o(B,I);break}else s(B,I);I=I.sibling}I=ed(L,B.mode,ee),I.return=B,B=I}return y(B);case ye:return ge=L._init,ut(B,I,ge(L._payload),ee)}if(Un(L))return ue(B,I,L,ee);if(G(L))return fe(B,I,L,ee);Ba(B,L)}return typeof L=="string"&&L!==""||typeof L=="number"?(L=""+L,I!==null&&I.tag===6?(o(B,I.sibling),I=d(I,L),I.return=B,B=I):(o(B,I),I=Xu(L,B.mode,ee),I.return=B,B=I),y(B)):o(B,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ea=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ea.current;et(Ea),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,$=j.next;j.next=null,y===null?h=$:y.next=$,y=j;var J=r.alternate;J!==null&&(J=J.updateQueue,S=J.lastBaseUpdate,S!==y&&(S===null?J.firstBaseUpdate=$:S.next=$,J.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,J=$=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){J!==null&&(J=J.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,fe=S;switch(K=s,se=o,fe.tag){case 1:if(ue=fe.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=fe.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},J===null?($=J=se,j=Z):J=J.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(J===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=$,d.lastBaseUpdate=J,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Tx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ax(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Bx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Tx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Ox.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function $x(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,zx=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Vx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,I=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[jx],delete s[kx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ep(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ep(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new zx),s.forEach(function(l){var d=Zx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Hx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function Zx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ux(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=eb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ba,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Xx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Xx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function eb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function tb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new tb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function nb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=mb(),ad.exports}var hm;function gb(){if(hm)return hl;hm=1;var n=yb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var vb=gb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function xb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function bb(n,e={}){return _y(n,{...e,compact:!0})}function wb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return xb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return bb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function Sb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function _b(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function Nb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function jb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function kb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of kb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Ib(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Mb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Db(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Cb=new TextDecoder("utf-8"),Md=n=>Cb.decode(n),Fb=new TextEncoder,Wd=n=>Fb.encode(n),Ob=n=>typeof n=="number",Tb=n=>typeof n=="boolean",At=n=>typeof n=="function",Bn=n=>n!=null&&Object(n)===n,Go=n=>Bn(n)&&At(n.then),mc=n=>Bn(n)&&At(n[Symbol.iterator]),Hd=n=>Bn(n)&&At(n[Symbol.asyncIterator]),Dd=n=>Bn(n)&&Bn(n.schema),Dy=n=>Bn(n)&&"done"in n&&"value"in n,Cy=n=>Bn(n)&&At(n.stat)&&Ob(n.fd),Fy=n=>Bn(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>Bn(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>Bn(n)&&At(n.read)&&At(n.pipe)&&Tb(n.readable)&&!Oy(n),Ab=n=>Bn(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Rb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Lb=n=>Ay(Uint8Array,n);function Ub(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Pb(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Rb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Wb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Hb=void 0;function Yo(n){if(n===null)return"null";if(n===Hb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Gb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Gb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Kb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Yb=BigInt(4294967296)*BigInt(4294967296),Qb=Yb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Et extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Et[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Et.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Jb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Jb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function qb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Zb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Xb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=Zb(t)},tw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Xb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},nw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),rw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},ow=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},aw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),hw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?dw(e,t):t instanceof Je?uw(e,t):Array.isArray(t)?cw(e,t):fw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},pw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},mw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},yw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},gw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},vw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xw(this[On],this[_i])}}class xw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const ww=(n,e)=>864e5*n[e],Sw=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},_w=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<ww(n,e),Bg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],Nw=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],jw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},kw=({values:n},e)=>n[e],Iw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Mw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Bg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Fw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Ow=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Tw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Aw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Rw=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Lw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Uw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(Sw);xe.prototype.visitBool=je(_w);xe.prototype.visitInt=je(kw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(Iw);xe.prototype.visitFloat16=je(Nw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(jw);xe.prototype.visitDate=je(Mw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Bg);xe.prototype.visitTimestamp=je(Dw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Cw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Fw);xe.prototype.visitList=je(Ow);xe.prototype.visitStruct=je(Aw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Rw);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Lw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Uw);xe.prototype.visitMap=je(Tw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new $w)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Pw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Pw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class $w{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Ei(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Ub(n,t):!1:n instanceof Map?Vw(n):Array.isArray(n)?zw(n):n instanceof Je?Ww(n):Hw(n,!0)}function zw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Gw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Yw(n,t):!1}}function Gw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ed(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Ed(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Kw(n,a>>3,i-a>>3)}function Kw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Jw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Jw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const qw=new Vo;function Be(n){return qw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function e1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return e1(n,t)}const i=Qt.getVisitFn(n),a=Ei(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new t1(f)})}class t1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Zw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var n1=By,r1=Ii;class rf{static decode(e){e=new r1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new s1(i,t)}static encode(e){const t=new n1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class o1 extends i1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new a1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof o1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class a1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class c1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ed(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?u1(i[t]):me.isBool(e)?Ed(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function u1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function d1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function f1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function m1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function y1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=d1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=f1;Se.prototype.visitStruct=h1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=p1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=m1;Se.prototype.visitMap=y1;const cs=new Se;function g1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return v1(n,e.map(t=>t.data.concat()))}function v1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Be({type:new Et(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function x1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Be({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Et)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!g1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+h.stack}return{value:r,source:s,stack:d,digest:null}}function Du(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Cu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Lx=typeof WeakMap=="function"?WeakMap:Map;function pp(r,s,o){o=fr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Xa||(Xa=!0,Hu=l),Cu(r,s)},o}function mp(r,s,o){o=fr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Cu(r,s)}}var h=r.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Cu(r,s),typeof l!="function"&&(Kr===null?Kr=new Set([this]):Kr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function yp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Lx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Zx.bind(null,r,s,o),s.then(r,r))}function gp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function vp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=fr(-1,1),s.tag=2,Yr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Ux=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Lh(s,null,o,l):Xs(s,r.child,o,l)}function xp(r,s,o,l,d){o=o.render;var h=s.ref;return ti(s,d),l=wu(r,s,o,l,h,d),o=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&o&&su(s),s.flags|=1,Ft(r,s,l,d),s.child)}function bp(r,s,o,l,d){if(r===null){var h=o.type;return typeof h=="function"&&!Zu(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=h,wp(r,s,h,l,d)):(r=il(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(h=r.child,(r.lanes&d)===0){var y=h.memoizedProps;if(o=o.compare,o=o!==null?o:lo,o(y,l)&&r.ref===s.ref)return hr(r,s,d)}return s.flags|=1,r=Xr(h,l),r.ref=s.ref,r.return=s,s.child=r}function wp(r,s,o,l,d){if(r!==null){var h=r.memoizedProps;if(lo(h,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=h,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,hr(r,s,d)}return Fu(r,s,o,l,d)}function Sp(r,s,o){var l=s.pendingProps,d=l.children,h=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(ii,Zt),Zt|=o;else{if((o&1073741824)===0)return r=h!==null?h.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(ii,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:o,qe(ii,Zt),Zt|=l}else h!==null?(l=h.baseLanes|o,s.memoizedState=null):l=o,qe(ii,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function _p(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Fu(r,s,o,l,d){var h=Lt(o)?gs:kt.current;return h=Ks(s,h),ti(s,d),o=wu(r,s,o,l,h,d),l=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&l&&su(s),s.flags|=1,Ft(r,s,o,d),s.child)}function Np(r,s,o,l,d){if(Lt(o)){var h=!0;Ca(s)}else h=!1;if(ti(s,d),s.stateNode===null)Qa(r,s),fp(s,o,l),Mu(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,$=o.contextType;typeof $=="object"&&$!==null?$=ln($):($=Lt(o)?gs:kt.current,$=Ks(s,$));var J=o.getDerivedStateFromProps,Z=typeof J=="function"||typeof y.getSnapshotBeforeUpdate=="function";Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==$)&&hp(s,y,l,$),Gr=!1;var K=s.memoizedState;y.state=K,Ua(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||Gr?(typeof J=="function"&&(Iu(s,o,J,l),j=s.memoizedState),(S=Gr||dp(s,o,S,l,K,j,$))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=$,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Ph(r,s),S=s.memoizedProps,$=s.type===s.elementType?S:jn(s.type,S),y.props=$,Z=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=ln(j):(j=Lt(o)?gs:kt.current,j=Ks(s,j));var se=o.getDerivedStateFromProps;(J=typeof se=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Z||K!==j)&&hp(s,y,l,j),Gr=!1,K=s.memoizedState,y.state=K,Ua(s,l,y,d);var ue=s.memoizedState;S!==Z||K!==ue||Rt.current||Gr?(typeof se=="function"&&(Iu(s,o,se,l),ue=s.memoizedState),($=Gr||dp(s,o,$,l,K,ue,j)||!1)?(J||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=$):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Ou(r,s,o,l,h,d)}function Ou(r,s,o,l,d,h){_p(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Dh(s,o,!1),hr(r,s,h);l=s.stateNode,Ux.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=Xs(s,r.child,null,h),s.child=Xs(s,null,S,h)):Ft(r,s,S,h),s.memoizedState=l.state,d&&Dh(s,o,!0),s.child}function jp(r){var s=r.stateNode;s.pendingContext?Ih(r,s.pendingContext,s.pendingContext!==s.context):s.context&&Ih(r,s.context,!1),mu(r,s.containerInfo)}function kp(r,s,o,l,d){return Zs(),lu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Tu={dehydrated:null,treeContext:null,retryLane:0};function Au(r){return{baseLanes:r,cachePool:null,transitions:null}}function Ip(r,s,o){var l=s.pendingProps,d=it.current,h=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(h=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return au(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,h?(l=s.mode,h=s.child,y={mode:"hidden",children:y},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=y):h=ol(y,l,0,null),r=Is(r,l,o,null),h.return=s,r.return=s,h.sibling=r,s.child=h,s.child.memoizedState=Au(o),s.memoizedState=Tu,r):Bu(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Px(r,s,y,l,S,d,o);if(h){h=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Xr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?h=Xr(S,h):(h=Is(h,y,o,null),h.flags|=2),h.return=s,l.return=s,l.sibling=h,s.child=l,l=h,h=s.child,y=r.child.memoizedState,y=y===null?Au(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},h.memoizedState=y,h.childLanes=r.childLanes&~o,s.memoizedState=Tu,l}return h=r.child,r=h.sibling,l=Xr(h,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Bu(r,s){return s=ol({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Ya(r,s,o,l){return l!==null&&lu(l),Xs(s,r.child,null,o),r=Bu(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Px(r,s,o,l,d,h,y){if(o)return s.flags&256?(s.flags&=-257,l=Du(Error(t(422))),Ya(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(h=l.fallback,d=s.mode,l=ol({mode:"visible",children:l.children},d,0,null),h=Is(h,d,y,null),h.flags|=2,l.return=s,h.return=s,l.sibling=h,s.child=l,(s.mode&1)!==0&&Xs(s,r.child,null,y),s.child.memoizedState=Au(y),s.memoizedState=Tu,h);if((s.mode&1)===0)return Ya(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,h=Error(t(419)),l=Du(h,l,void 0),Ya(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,dr(r,d),Mn(l,r,d,-1))}return qu(),l=Du(Error(t(421))),Ya(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=Xx.bind(null,r),d._reactRetry=s,null):(r=h.treeContext,qt=zr(d.nextSibling),Jt=s,rt=!0,Nn=null,r!==null&&(on[an++]=cr,on[an++]=ur,on[an++]=vs,cr=r.id,ur=r.overflow,vs=s),s=Bu(s,l.children),s.flags|=4096,s)}function Mp(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),fu(r.return,s,o)}function Eu(r,s,o,l,d){var h=r.memoizedState;h===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(h.isBackwards=s,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=o,h.tailMode=d)}function Dp(r,s,o){var l=s.pendingProps,d=l.revealOrder,h=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Mp(r,o,s);else if(r.tag===19)Mp(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Pa(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Eu(s,!1,d,o,h);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Pa(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Eu(s,!0,o,null,h);break;case"together":Eu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Qa(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function hr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),_s|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Xr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Xr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function $x(r,s,o){switch(s.tag){case 3:jp(s),Zs();break;case 5:Vh(s);break;case 1:Lt(s.type)&&Ca(s);break;case 4:mu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ea,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?Ip(r,s,o):(qe(it,it.current&1),r=hr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Dp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,Sp(r,s,o)}return hr(r,s,o)}var Cp,Ru,Fp,Op;Cp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ru=function(){},Fp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,ws(Vn.current);var h=null;switch(o){case"input":d=or(r,d),l=or(r,l),h=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),h=[];break;case"textarea":d=Ui(r,d),l=Ui(r,l),h=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Ia)}he(o,l);var y;o=null;for($ in d)if(!l.hasOwnProperty($)&&d.hasOwnProperty($)&&d[$]!=null)if($==="style"){var S=d[$];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else $!=="dangerouslySetInnerHTML"&&$!=="children"&&$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(a.hasOwnProperty($)?h||(h=[]):(h=h||[]).push($,null));for($ in l){var j=l[$];if(S=d!=null?d[$]:void 0,l.hasOwnProperty($)&&j!==S&&(j!=null||S!=null))if($==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(h||(h=[]),h.push($,o)),o=j;else $==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(h=h||[]).push($,j)):$==="children"?typeof j!="string"&&typeof j!="number"||(h=h||[]).push($,""+j):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&(a.hasOwnProperty($)?(j!=null&&$==="onScroll"&&Xe("scroll",r),h||S===j||(h=[])):(h=h||[]).push($,j))}o&&(h=h||[]).push("style",o);var $=h;(s.updateQueue=$)&&(s.flags|=4)}},Op=function(r,s,o,l){o!==l&&(s.flags|=4)};function No(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function Mt(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function zx(r,s,o){var l=s.pendingProps;switch(iu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mt(s),null;case 1:return Lt(s.type)&&Da(),Mt(s),null;case 3:return l=s.stateNode,ni(),et(Rt),et(kt),vu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Aa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Nn!==null&&(Qu(Nn),Nn=null))),Ru(r,s),Mt(s),null;case 5:yu(s);var d=ws(xo.current);if(o=s.type,r!==null&&s.stateNode!=null)Fp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return Mt(s),null}if(r=ws(Vn.current),Aa(s)){l=s.stateNode,o=s.type;var h=s.memoizedProps;switch(l[zn]=s,l[po]=h,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Vx(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,Wx=typeof WeakSet=="function"?WeakSet:Set,ae=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Hx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,$=0,J=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++$===d&&(S=y),K===h&&++J===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ae=s;ae!==null;)if(s=ae,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ae=r;else for(;ae!==null;){s=ae;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var fe=ue.memoizedProps,ut=ue.memoizedState,B=s.stateNode,I=B.getSnapshotBeforeUpdate(s.elementType===s.type?fe:jn(s.type,fe),ut);B.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var L=s.stateNode.containerInfo;L.nodeType===1?L.textContent="":L.nodeType===9&&L.documentElement&&L.removeChild(L.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ae=r;break}ae=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[Ix],delete s[Mx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Bp(r){return r.tag===5||r.tag===3||r.tag===4}function Ep(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bp(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Wx),s.forEach(function(l){var d=eb.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Yx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ae=r.current;ae!==null;){var h=ae,y=h.child;if((ae.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function Xx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function eb(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,$x(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=nb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ea,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var $=h.updateQueue;if($!==null){$=$.shared;var J=$.pending;J===null?j.next=j:(j.next=J.next,J.next=j),$.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function tb(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new tb(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function nb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ne)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case R:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case X:return r=dn(13,o,s,d),r.elementType=X,r.lanes=h,r;case le:return r=dn(19,o,s,d),r.elementType=le,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case W:y=9;break e;case ne:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function rb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new rb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function sb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=gb(),ad.exports}var hm;function vb(){if(hm)return hl;hm=1;var n=_y();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var xb=vb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function bb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Ny(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function wb(n,e={}){return Ny(n,{...e,compact:!0})}function Sb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return bb(n)}function pt(n,e={}){return Ny(n,e)}function Gt(n,e={}){return wb(n,e)}function jy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function _b(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function Nb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:jy(i)}}function jb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:jy(t)}}function ky(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function kb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,Iy=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function My(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Iy.test(t.name))}function Ib(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function Dy(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of Ib(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Mb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=My(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:Dy(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Db(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:Iy.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=My(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:Dy(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Cb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,P){c.push([w,C,T,P])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Fb=new TextDecoder("utf-8"),Md=n=>Fb.decode(n),Ob=new TextEncoder,Wd=n=>Ob.encode(n),Tb=n=>typeof n=="number",Ab=n=>typeof n=="boolean",At=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Go=n=>En(n)&&At(n.then),mc=n=>En(n)&&At(n[Symbol.iterator]),Hd=n=>En(n)&&At(n[Symbol.asyncIterator]),Dd=n=>En(n)&&En(n.schema),Cy=n=>En(n)&&"done"in n&&"value"in n,Fy=n=>En(n)&&At(n.stat)&&Tb(n.fd),Oy=n=>En(n)&&Gd(n.body),Ty=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>En(n)&&At(n.cancel)&&At(n.getReader)&&!Ty(n),Ay=n=>En(n)&&At(n.read)&&At(n.pipe)&&Ab(n.readable)&&!Ty(n),Bb=n=>En(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Rb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Lb=n=>Rb(Uint8Array,n);function By(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(By(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Ub=n=>By(Uint8Array,n);function Pb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*$b(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Lb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Hb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[P,U]of w)n.off(P,U);try{const P=n.destroy;P&&P.call(n,_),_=void 0}catch(P){_=P||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Gb=void 0;function Yo(n){if(n===null)return"null";if(n===Gb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function $y(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Yb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Yb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return zy(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return zy(this);case"string":return Ko(this);case"default":return Jb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Qb=BigInt(4294967296)*BigInt(4294967296),Kb=Qb-BigInt(1);function zy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Wy=Symbol.toStringTag;ls[Wy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Hy=Symbol.toStringTag;Os[Hy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Gy=Symbol.toStringTag;Ll[Gy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Yy=Symbol.toStringTag;Ul[Yy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Qy=Symbol.toStringTag;Pl[Qy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Ky=Symbol.toStringTag;$l[Ky]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Jy=Symbol.toStringTag;zl[Jy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}qy=Symbol.toStringTag;Vl[qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Zy=Symbol.toStringTag;Wl[Zy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Xy=Symbol.toStringTag;Hl[Xy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}eg=Symbol.toStringTag;Gl[eg]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}tg=Symbol.toStringTag;Yl[tg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}ng=Symbol.toStringTag;Ql[ng]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}rg=Symbol.toStringTag;Kl[rg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}sg=Symbol.toStringTag;Jl[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Bt extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ig=Symbol.toStringTag;Bt[ig]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Bt.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}og=Symbol.toStringTag;ql[og]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}ag=Symbol.toStringTag;Zl[ag]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}lg=Symbol.toStringTag;Xl[lg]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}cg=Symbol.toStringTag;ec[cg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const qb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?qb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ug=Symbol.toStringTag;Di[ug]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Zb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Zb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const dg=new Float64Array(1),li=new Uint32Array(dg.buffer);function fg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Xb(n){if(n!==n)return 32256;dg[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function De(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const ew=(n,e,t)=>{n[e]=Math.floor(t/864e5)},hg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},pg=({values:n},e,t)=>{n[e]=Xb(t)},nw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return pg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},mg=({values:n},e,t)=>{ew(n,e,t.valueOf())},yg=({values:n},e,t)=>{n[e]=BigInt(t)},rw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},gg=({values:n,valueOffsets:e},t,i)=>hg(n,e,t,i),vg=({values:n,valueOffsets:e},t,i)=>hg(n,e,t,Wd(i)),sw=(n,e,t)=>{n.type.unit===bn.DAY?mg(n,e,t):yg(n,e,t)},xg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},bg=({values:n},e,t)=>{n[e]=BigInt(t)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},Sg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return xg(n,e,t);case _e.MILLISECOND:return bg(n,e,t);case _e.MICROSECOND:return wg(n,e,t);case _e.NANOSECOND:return Sg(n,e,t)}},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},kg=({values:n},e,t)=>{n[e]=t},ow=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return _g(n,e,t);case _e.MILLISECOND:return Ng(n,e,t);case _e.MICROSECOND:return jg(n,e,t);case _e.NANOSECOND:return kg(n,e,t)}},aw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},lw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),hw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),pw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?fw(e,t):t instanceof Je?dw(e,t):Array.isArray(t)?uw(e,t):hw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},mw=(n,e,t)=>{n.type.mode===Yt.Dense?Ig(n,e,t):Mg(n,e,t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Mg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},yw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},gw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Dg(n,e,t):Cg(n,e,t)},Dg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Cg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},Ag=({values:n},e,t)=>{n[e]=t},vw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Fg(n,e,t);case _e.MILLISECOND:return Og(n,e,t);case _e.MICROSECOND:return Tg(n,e,t);case _e.NANOSECOND:return Ag(n,e,t)}},xw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new bw(this[On],this[_i])}}class bw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const Sw=(n,e)=>864e5*n[e],_w=(n,e)=>null,Bg=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},Nw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<Sw(n,e),Rg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],jw=({stride:n,values:e},t)=>fg(e[n*t]),Lg=({values:n},e)=>n[e],kw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Ug=({values:n,valueOffsets:e},t)=>Bg(n,e,t),Pg=({values:n,valueOffsets:e},t)=>{const i=Bg(n,e,t);return i!==null?Md(i):null},Iw=({values:n},e)=>n[e],Mw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:fg(e[t]),Dw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Rg(n,e),$g=({values:n},e)=>1e3*tt(n[e]),zg=({values:n},e)=>tt(n[e]),Vg=({values:n},e)=>$y(n[e],BigInt(1e3)),Wg=({values:n},e)=>$y(n[e],BigInt(1e6)),Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return $g(n,e);case _e.MILLISECOND:return zg(n,e);case _e.MICROSECOND:return Vg(n,e);case _e.NANOSECOND:return Wg(n,e)}},Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Qg=({values:n},e)=>n[e],Fw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Hg(n,e);case _e.MILLISECOND:return Gg(n,e);case _e.MICROSECOND:return Yg(n,e);case _e.NANOSECOND:return Qg(n,e)}},Ow=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Tw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Aw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Bw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Kg(n,e):Jg(n,e),Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Jg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Rw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Lw=(n,e)=>n.type.unit===rr.DAY_TIME?qg(n,e):Zg(n,e),qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Zg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],nv=({values:n},e)=>n[e],Uw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Xg(n,e);case _e.MILLISECOND:return ev(n,e);case _e.MICROSECOND:return tv(n,e);case _e.NANOSECOND:return nv(n,e)}},Pw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(_w);xe.prototype.visitBool=je(Nw);xe.prototype.visitInt=je(Iw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Lg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Lg);xe.prototype.visitFloat=je(Mw);xe.prototype.visitFloat16=je(jw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Pg);xe.prototype.visitLargeUtf8=je(Pg);xe.prototype.visitBinary=je(Ug);xe.prototype.visitLargeBinary=je(Ug);xe.prototype.visitFixedSizeBinary=je(kw);xe.prototype.visitDate=je(Dw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Rg);xe.prototype.visitTimestamp=je(Cw);xe.prototype.visitTimestampSecond=je($g);xe.prototype.visitTimestampMillisecond=je(zg);xe.prototype.visitTimestampMicrosecond=je(Vg);xe.prototype.visitTimestampNanosecond=je(Wg);xe.prototype.visitTime=je(Fw);xe.prototype.visitTimeSecond=je(Hg);xe.prototype.visitTimeMillisecond=je(Gg);xe.prototype.visitTimeMicrosecond=je(Yg);xe.prototype.visitTimeNanosecond=je(Qg);xe.prototype.visitDecimal=je(Ow);xe.prototype.visitList=je(Tw);xe.prototype.visitStruct=je(Bw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Kg);xe.prototype.visitSparseUnion=je(Jg);xe.prototype.visitDictionary=je(Rw);xe.prototype.visitInterval=je(Lw);xe.prototype.visitIntervalDayTime=je(qg);xe.prototype.visitIntervalYearMonth=je(Zg);xe.prototype.visitDuration=je(Uw);xe.prototype.visitDurationSecond=je(Xg);xe.prototype.visitDurationMillisecond=je(ev);xe.prototype.visitDurationMicrosecond=je(tv);xe.prototype.visitDurationNanosecond=je(nv);xe.prototype.visitFixedSizeList=je(Pw);xe.prototype.visitMap=je(Aw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new zw)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new $w(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class $w{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class zw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function rv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Bi(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Pb(n,t):!1:n instanceof Map?Ww(n):Array.isArray(n)?Vw(n):n instanceof Je?Hw(n):Gw(n,!0)}function Vw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Yw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Qw(n,t):!1}}function Yw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Bd(new Xd(t,n,e,null,sv)).subarray(0,i)),a}return t}function Bd(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Ed(n,e,a)+Ed(n,i,t)+Jw(n,a>>3,i-a>>3)}function Jw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const qw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=qw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Ed(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const Zw=new Vo;function Ee(n){return Zw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function iv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function ov(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function av(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function t1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,sv)){if(!a)return i;++i}return-1}function Fe(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return t1(n,t)}const i=Qt.getVisitFn(n),a=Bi(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new n1(f)})}class n1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=fv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,hv[f.typeId]),this._offsets=ov(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Xw(this.data)}get nullCount(){return iv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(rv(this,e,t,({data:i,_offsets:a},c,f)=>av(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}dv=Symbol.toStringTag;Je[dv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);fv[t]={get:i,set:a,indexOf:c},hv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:lv(wn.getVisitFnByTypeId(t))},indexOf:{value:cv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var r1=Ry,s1=Ii;class rf{static decode(e){e=new s1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new i1(i,t)}static encode(e){const t=new r1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class a1 extends o1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new l1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof a1?this.source=new Ms(mn.fromAsyncIterable(e)):Ay(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Oy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class l1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class u1 extends yv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Bd(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?d1(i[t]):me.isBool(e)?Bd(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function d1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Et(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Et(n,e)}function Mr(n,e){return n===e||Et(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Et(n,e)&&n.precision===e.precision}function f1(n,e){return n===e||Et(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function h1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Et(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function m1(n,e){return n===e||Et(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function y1(n,e){return n===e||Et(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function g1(n,e){return n===e||Et(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=f1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=h1;Se.prototype.visitStruct=p1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=m1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=y1;Se.prototype.visitMap=g1;const cs=new Se;function v1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return x1(n,e.map(t=>t.data.concat()))}function x1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Ee({type:new Bt(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function b1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Ee({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var gv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Bt)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!v1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??ov(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=iv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Be({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Be({nullCount:0,type:new Et(this.schema.fields),children:this.schema.fields.map(t=>Be({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Be({type:new Et(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Be({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Be({type:new Et(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Be({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Be({type:new Et(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cBe({type:a.type})),i=Be({type:new Et(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class b1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new b1;function w1(n,e=new Map){return new We(_1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function S1(n){return new kr(bv(n.data),n.id,n.isDelta)}function _1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Em(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Bi(t.count,N1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function j1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Em(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Bm(i):new Jo,e.set(t,f=Rm(n,Em(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Et(e||[]);case"struct_":return new Et(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var k1=By,I1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=M1(e,t),i}static decode(e){e=new I1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=D1(t,c),f}static encode(e){const t=new k1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Bi{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=P1;nt.decode=L1;nt.fromJSON=j1;We.encode=U1;We.decode=C1;We.fromJSON=w1;Rn.encode=$1;Rn.decode=F1;Rn.fromJSON=bv;kr.encode=z1;kr.decode=O1;kr.fromJSON=S1;Bi.encode=V1;Bi.decode=A1;_r.encode=W1;_r.decode=T1;function C1(n,e=new Map,t=ht.V5){const i=R1(n,e);return new We(i,Tl(n),e,t)}function F1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),B1(n,e))}function O1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function T1(n){return new _r(n.offset(),n.length())}function A1(n){return new Bi(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,H1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function P1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function $1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Bi.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function z1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function V1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function W1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const H1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?Z1(e):Cy(e)?tS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?eS(new Fi(e)):X1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class K1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Be({type:new Et(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new Y1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new G1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function eS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function tS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Q1&&df(yield t.readAt(0,na+7&-8))?new K1(new J1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function nS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function rS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const iS="application/vnd.apache.arrow.stream";class oS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function aS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class lS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new oS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return aS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Ib(await t.json());try{return Db(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Mb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?sS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:iS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=rS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var B,F;return(F=(B=w.current)==null?void 0:B.querySelector("button"))==null?void 0:F.focus()});function U(B){var L;if(B.key==="Escape"){B.preventDefault(),x(!1);return}if(B.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];B.shiftKey&&document.activeElement===A?(B.preventDefault(),M.focus()):!B.shiftKey&&document.activeElement===M&&(B.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"relative z-30 flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function cS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const uS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function dS(n,e){const t=n.split("__").at(-1);return t&&uS.has(t)?t:e}function fS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function hS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",B=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:B,selectedMetric:C,grain:$?dS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:hS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??fS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function pS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function mS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function yS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=mS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function gS(n){return{from:Vm(n.from),to:Vm(n.to)}}function vS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function xS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function bS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function wS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${wS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function SS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Ev(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=SS(a,c,f,e.dialect);p&&t.push(p)}return t}function Es(n,e={}){const t=Ev(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...xS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const _S={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:_S[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function NS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function jS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function kS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function IS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function MS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=IS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function DS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Bv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??DS(n),c=(i==null?void 0:i.selectedMetric)??Bv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function CS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const FS=["home","explore","pivot"],OS=new Set(Pd),TS=new Set(["none","pctTotal","delta","deltaPct"]),AS=new Set(["off","previous","year","custom"]),ES="none",BS="previous",RS="UTC";function LS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const US=new Set(["include","exclude","contains"]);function PS(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!US.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function $S(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=PS(i);a&&(e[t]=a)}return e}function zS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function VS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==RS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(zS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function WS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&FS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&OS.has(m)&&(i.grain=m);const g=t.get("tz");LS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&TS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&AS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=$S(bl(t.get("filters")));U&&(i.filters=U);const B=bl(t.get("jdims"));Wo(B)&&(i.joinedDims=[...new Set(B)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=k.createContext(null);function Qm(n){const e=VS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=WS(n,i),c=Ts(e,t,a.dashboardTab);return c?CS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function HS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Rv(n,t),[n,t]),[p,m]=k.useReducer(MS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function GS(){Cs.active+=1,Uv()}function YS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const QS=80;function En(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{GS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>YS())},QS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function $v(n,e=!0){k.useLayoutEffect(()=>{const t=n.current,i=t==null?void 0:t.parentElement;if(!e||!t||!i)return;function a(){if(!t||!i)return;const f=i.getBoundingClientRect(),p=8,m=Math.max(p,Math.min(f.left,window.innerWidth-t.offsetWidth-p));t.style.left=`${m-f.left}px`,t.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-f.bottom-p-4)}px`)}a();const c=new ResizeObserver(a);return c.observe(t),c.observe(i),i.parentElement&&c.observe(i.parentElement),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{c.disconnect(),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}})}const KS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],JS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function zv({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=k.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=k.useState((g==null?void 0:g.mode)??"include"),b=k.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=k.useRef(null);$v(w);const _=k.useRef(null),C=k.useId(),[T,$]=k.useState(""),U=Zm(T,qm),B=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=k.useState(B),M=Zm(F,qm);k.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),k.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),k.useEffect(()=>{v==="contains"&&M!==B&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=k.useMemo(()=>xc(f),[f]),Q=k.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Es(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=En(c,V?NS(n.ref,Q,JS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=k.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(B)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:KS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function qS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(v=>v.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null);$v(m,i&&!c),k.useEffect(()=>{if(!i)return;function v(b){b.key==="Escape"&&g()}function x(b){c||p.current&&!p.current.contains(b.target)&&g()}return document.addEventListener("keydown",v,!0),document.addEventListener("mousedown",x,!0),()=>{document.removeEventListener("keydown",v,!0),document.removeEventListener("mousedown",x,!0)}},[i,c]);function g(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?g():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 top-full z-50 mt-1 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(v=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(v),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:v.label},v.ref))}):null,i&&c?u.jsx(zv,{dim:c,model:n,onClose:g}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function ZS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class XS extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const e_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Vv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",B=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${B?"opacity-50":""}`,children:e_.map(F=>u.jsx("button",{type:"button",disabled:B,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!B?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",jb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(zv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const t_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function n_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function r_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function s_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(t_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();n_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=r_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function i_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const o_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:B,visibleRows:F}=wb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},B+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=i_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:o_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[B+1,"–",Math.min(B+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function a_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function l_(){var U,B;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=a_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((B=f==null?void 0:f.timeDimension)==null?void 0:B.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Es(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?kS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=En(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Wv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Wv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Hv(n){document.documentElement.dataset.theme=n}function c_(){Hv(yf())}function u_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Wv,n),Hv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(u_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Gv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Yv="dashboard_filters",Qv="dashboard_ranges",Kv="dashboard_filter_sources",Jv="dashboard_range_sources",qv="dashboard_chart_filters",Zv="dashboard_chart_ranges";function d_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function f_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function h_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function p_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=p_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function m_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function y_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function g_(n,e,t){return[e,...t].some(i=>gf(n,i))}const v_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return v_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Xv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function e0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function t0(n,e,t){const i=Fs(n);if(i){const a=e0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function x_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[t0(n,{from:e,to:e},i)]:Ev({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function b_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Xv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([B,F])=>x_(B,F,i,f)),...Object.entries(p.ranges).map(([B,F])=>t0(B,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=e0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function w_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,B=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return B&&(w.set("from",B.from),w.set("to",B.to)),`/explore?${w}`}function S_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function __(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function s0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function i0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function N_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Yv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Qv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Kv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Jv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Zv)??"{}")}catch{x={}}const b=s0(e),w=i0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:n0(v,w),chartRanges:r0(x,w)}}function j_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Yv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Qv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Kv,JSON.stringify(i)),Object.keys(a).length&&t.set(Jv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Zv,JSON.stringify(n.chartRanges)),t.toString()}function o0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function k_(n){try{const e=JSON.parse(localStorage.getItem(o0(n))??"[]");if(!Array.isArray(e))return[];const t=s0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=i0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:n0(c.chartFilters,p),chartRanges:r0(c.chartRanges,p)}}]})}catch{return[]}}function I_(n,e){try{return localStorage.setItem(o0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function M_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r -`)}function D_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function C_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Bv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const F_="600px";function O_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function T_(n,e,t=F_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:O_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const A_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function a0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,B=m!=="none",F=B?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),B?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${A_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],R_=[];function L_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=R_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=k.useRef(null),[U,B]=k.useState(!1);k.useEffect(()=>{if(!(U||!$.current))return T_($.current,()=>B(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Es(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=En(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=k.useMemo(()=>ae&&f&&F&&ie?[...p,...Es(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=En(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=k.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:Sb(he,c);case"delta":return _b(he,H.get(te),N);case"deltaPct":return Nb(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(a0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:E_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function l0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[$,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const B=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(B.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...B.map(H=>H.value)),L=Math.max(...B.map(H=>H.value))-A||1,Y=B.map((H,N)=>({...H,x:F+N/(B.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${B.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const U_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},P_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${U_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:P_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(l0,{values:p,labels:m,onHover:B=>{C(B),b==null||b(B)},onBrush:w,formatValue:B=>pt(B,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,$]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},B({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},B({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,B(null)}function W(){$(null),b.current=!1,w.current=null,B(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const $_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function z_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${$_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const V_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function W_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} +]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=rv({length:this.numRows},e,t);const a=av(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Ee({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}gv=Symbol.toStringTag;vn[gv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=lv(wn.getVisitFn(D.Struct)),n.indexOf=cv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var vv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ee({nullCount:0,type:new Bt(this.schema.fields),children:this.schema.fields.map(t=>Ee({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Ee({type:new Bt(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=xv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Ee({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Ee({type:new Bt(t.fields),length:this.numRows,children:i});return new zo(t,a)}};vv=Symbol.toStringTag;Tn[vv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Ee({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Ee({type:new Bt(a),length:t,children:c})]}function xv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cEe({type:a.type})),i=Ee({type:new Bt(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class w1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new w1;function S1(n,e=new Map){return new We(N1(n,e),Ol(n.metadata),e)}function wv(n){return new Rn(n.count,Sv(n.columns),_v(n.columns))}function _1(n){return new kr(wv(n.data),n.id,n.isDelta)}function N1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Bm(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Sv(n){return(n||[]).reduce((e,t)=>[...e,new Ei(t.count,j1(t.VALIDITY)),...Sv(t.children)],[])}function _v(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function k1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Bm(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Em(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Em(i):new Jo,e.set(t,f=Rm(n,Bm(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Em(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Bt(e||[]);case"struct_":return new Bt(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var I1=Ry,M1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=D1(e,t),i}static decode(e){e=new M1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=C1(t,c),f}static encode(e){const t=new I1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ei{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function C1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=$1;nt.decode=U1;nt.fromJSON=k1;We.encode=P1;We.decode=F1;We.fromJSON=S1;Rn.encode=z1;Rn.decode=O1;Rn.fromJSON=wv;kr.encode=V1;kr.decode=T1;kr.fromJSON=_1;Ei.encode=W1;Ei.decode=B1;_r.encode=H1;_r.decode=A1;function F1(n,e=new Map,t=ht.V5){const i=L1(n,e);return new We(i,Tl(n),e,t)}function O1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),R1(n,e))}function T1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function A1(n){return new _r(n.offset(),n.length())}function B1(n){return new Ei(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,G1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function $1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function z1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ei.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function V1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function W1(n,e){return Py.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function H1(n,e){return Uy.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const G1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,Nv=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,jv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class kv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?X1(e):Fy(e)?nS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Oy(e)||Gd(e)||Ay(e)||Hd(e)?tS(new Fi(e)):eS(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Cy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Mv extends ac{constructor(e){super(e),this._impl=e}}class J1 extends lc{constructor(e){super(e),this._impl=e}}class Dv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Ee({type:new Bt(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new yv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Dv{constructor(e,t){super(t),this._reader=Dd(e)?new Q1(this._handle=e):new kv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Fv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Dv{constructor(e,t){super(t),this._reader=new Y1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Fv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Cv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-Iv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-Iv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Mv(new Cv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function tS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Mv(new Cv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function nS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=K1&&df(yield t.readAt(0,na+7&-8))?new J1(new q1(t)):new lc(new uc(t))})}function Ov(n){const e=jr.from(n);return Go(e)?e.then(t=>Ov(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function rS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function sS(n){const e=Ov(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const oS="application/vnd.apache.arrow.stream";class aS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function lS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class cS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new aS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return lS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Mb(await t.json());try{return Cb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Db(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?iS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:oS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=sS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Tv({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),P=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",P),()=>T.removeEventListener("change",P)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,P=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var E,F;return(F=(E=w.current)==null?void 0:E.querySelector("button"))==null?void 0:F.focus()});function U(E){var R;if(E.key==="Escape"){E.preventDefault(),x(!1);return}if(E.key!=="Tab")return;const F=(R=w.current)==null?void 0:R.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];E.shiftKey&&document.activeElement===A?(E.preventDefault(),M.focus()):!E.shiftKey&&document.activeElement===M&&(E.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{"data-filter-strip":!0,role:"region","aria-label":"Active filters",className:"relative z-30 flex max-h-[min(25dvh,8rem)] min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-y-auto border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function uS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}var Av=_y();const dS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function fS(n,e){const t=n.split("__").at(-1);return t&&dS.has(t)?t:e}function hS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function pS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,R,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(W=>W.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(W=>{var ne;return(ne=n.graphMetrics.find(X=>X.ref===W))==null?void 0:ne.ownerModel}).find(W=>!!W),m=((F=f.find(W=>W.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(W=>W.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(W=>W.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(W=>W.metrics),...ki(n,g.name)],x=f.map(W=>v.find(ne=>ne.ref===W)).filter(W=>!!W),b=c.map(W=>vl(n,W)).filter((W,ne,X)=>!!W&&X.findIndex(le=>(le==null?void 0:le.ref)===(W==null?void 0:W.ref))===ne),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(W=>x.some(ne=>ne.ref===W))??((R=x[0])==null?void 0:R.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,P=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(W=>{var ne;return((ne=vl(n,W))==null?void 0:ne.type)==="time"}),U=g.defaultGrain??"month",E=P?vl(n,P):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:E,selectedMetric:C,grain:P?fS(P,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:pS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??hS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function mS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function yS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function gS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=yS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function vS(n){return{from:Vm(n.from),to:Vm(n.to)}}function xS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Bv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function bS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function wS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function SS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Ev(n,e,t){const i=Kn(`%${SS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function _S(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Rv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Ev(a,c.pattern??"",e.dialect));continue}const p=_S(a,c,f,e.dialect);p&&t.push(p)}return t}function Bs(n,e={}){const t=Rv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...bS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const NS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:NS[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function jS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function kS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function IS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function MS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function DS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=MS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function CS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Lv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Uv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??CS(n),c=(i==null?void 0:i.selectedMetric)??Lv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function FS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const OS=["home","explore","pivot"],TS=new Set(Pd),AS=new Set(["none","pctTotal","delta","deltaPct"]),BS=new Set(["off","previous","year","custom"]),ES="none",RS="previous",LS="UTC";function US(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const PS=new Set(["include","exclude","contains"]);function $S(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!PS.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function zS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=$S(i);a&&(e[t]=a)}return e}function VS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function WS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==LS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==RS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(VS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function HS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&OS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&TS.has(m)&&(i.grain=m);const g=t.get("tz");US(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Bv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&AS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&BS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),P=t.get("cto");i.comparison==="custom"&&wl(T)&&wl(P)&&Date.parse(T)<=Date.parse(P)&&(i.comparisonRange={from:T,to:P});const U=zS(bl(t.get("filters")));U&&(i.filters=U);const E=bl(t.get("jdims"));Wo(E)&&(i.joinedDims=[...new Set(E)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Pv=k.createContext(null);function Qm(n){const e=WS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=HS(n,i),c=Ts(e,t,a.dashboardTab);return c?FS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function GS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Uv(n,t),[n,t]),[p,m]=k.useReducer(DS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Pv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Pv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function $v(){for(const n of Cs.listeners)n()}function YS(){Cs.active+=1,$v()}function QS(){Cs.active=Math.max(0,Cs.active-1),$v()}function zv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const KS=80;function Bn(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{YS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>QS())},KS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function Vv(n,e,t=!0){k.useLayoutEffect(()=>{const i=n.current,a=e.current;if(!t||!i||!a)return;function c(){var _;if(!i||!a)return;const m=a.getBoundingClientRect(),g=(_=a.closest("[data-filter-strip]"))==null?void 0:_.getBoundingClientRect(),v=8,x=Math.max(v,Math.min(m.left,window.innerWidth-i.offsetWidth-v)),b=g?Math.max(g.top,Math.min(m.bottom,g.bottom)):m.bottom,w=Math.max(v,Math.min(b+4,window.innerHeight-v));i.style.left=`${x}px`,i.style.top=`${w}px`,i.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-w-v)}px`)}c();const f=new ResizeObserver(c);f.observe(i),f.observe(a);const p=a.closest("[data-filter-strip]");return p&&f.observe(p),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{f.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}})}const JS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],qS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function Wv({dim:n,model:e,anchorRef:t,onClose:i}){var V,de;const{state:a,dispatch:c,backend:f,catalog:p,dashboard:m}=Dr(),g=k.useMemo(()=>Ts(p,m,a.dashboardTab),[p,m,a.dashboardTab]),v=a.filters[n.ref],[x,b]=k.useState((v==null?void 0:v.mode)??"include"),w=k.useMemo(()=>new Set((v==null?void 0:v.mode)!=="contains"?(v==null?void 0:v.values)??[]:[]),[v]),_=k.useRef(null);Vv(_,t);const C=k.useRef(null),T=k.useId(),[P,U]=k.useState(""),E=Zm(P,qm),F=(v==null?void 0:v.mode)==="contains"?v.pattern??"":"",[A,M]=k.useState(F),R=Zm(A,qm);k.useEffect(()=>{var q;const te=t.current;return(q=C.current)==null||q.focus(),()=>te==null?void 0:te.focus({preventScroll:!0})},[t]),k.useEffect(()=>{function te(ce){ce.key==="Escape"&&(ce.stopPropagation(),i())}function q(ce){_.current&&!_.current.contains(ce.target)&&i()}return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",q,!0),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",q,!0)}},[i]),k.useEffect(()=>{x==="contains"&&R!==F&&c({type:"setFilterPattern",dim:n.ref,pattern:R})},[R,x,n.ref,c]);const Y=p.models.find(te=>te.name===a.model)??e,z=((V=g==null?void 0:g.timeDimension)==null?void 0:V.ref)??((de=Y.timeDimension)==null?void 0:de.ref),Q=k.useMemo(()=>xc(p),[p]),W=k.useMemo(()=>{const te=[...(g==null?void 0:g.filters)??[],...Bs(a.filters,{timeRef:z,range:a.dateRange,excludeDim:n.ref,types:Q,dialect:p.dialect})];return E.trim()&&te.push(Ev(n.ref,E.trim(),p.dialect)),te},[g,a.filters,z,a.dateRange,n.ref,E,Q,p.dialect]),ne=x!=="contains",{result:X,loading:le,error:ie}=Bn(f,ne?jS(n.ref,W,qS,g==null?void 0:g.segments,g==null?void 0:g.usePreaggregations):null),ye=Ho(n.ref),re=k.useMemo(()=>X?X.rows.map(te=>{const q=te[ye];return q==null?tr:String(q)}):[],[X,ye]),O=!!X&&X.rows.length>0&&!X.columns.includes(ye),G=ne&&(le||O);function H(te){b(te),v&&c({type:"setFilterMode",dim:n.ref,mode:te}),te==="contains"&&M(F)}function N(te){var Me;if(te.key!=="Tab")return;const q=(Me=_.current)==null?void 0:Me.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!q||q.length===0)return;const ce=q[0],Ie=q[q.length-1];te.shiftKey&&document.activeElement===ce?(te.preventDefault(),Ie.focus()):!te.shiftKey&&document.activeElement===Ie&&(te.preventDefault(),ce.focus())}return Av.createPortal(u.jsxs("div",{ref:_,role:"dialog","aria-modal":"true","aria-labelledby":T,onKeyDown:N,className:"fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:T,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:i,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:JS.map(({mode:te,label:q})=>u.jsx("button",{type:"button","aria-pressed":x===te,onClick:()=>H(te),className:`px-1.5 py-1 text-center ${x===te?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:q},te))}),x==="contains"?u.jsx("input",{ref:C,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:A,onChange:te=>M(te.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:P,onChange:te=>U(te.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ie?u.jsx("p",{className:"px-1 py-2 text-danger",children:ie}):G?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(te=>u.jsx("div",{className:"skeleton h-4 w-full"},te))}):re.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):re.map(te=>{const q=w.has(te);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:q,onChange:()=>c({type:"toggleFilter",dim:n.ref,value:te,mode:x}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(te)})]},te)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>c({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:i,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]}),document.body)}function ZS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(x=>x.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null),g=k.useRef(null);Vv(m,g,i&&!c),k.useEffect(()=>{if(!i)return;function x(w){var _;w.key==="Escape"&&(v(),(_=g.current)==null||_.focus({preventScroll:!0}))}function b(w){var _,C;c||!((_=p.current)!=null&&_.contains(w.target))&&!((C=m.current)!=null&&C.contains(w.target))&&v()}return document.addEventListener("keydown",x,!0),document.addEventListener("mousedown",b,!0),()=>{document.removeEventListener("keydown",x,!0),document.removeEventListener("mousedown",b,!0)}},[i,c]);function v(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{ref:g,type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?v():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?Av.createPortal(u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"fixed z-30 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(x=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(x),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:x.label},x.ref))}),document.body):null,i&&c?u.jsx(Wv,{dim:c,model:n,anchorRef:g,onClose:v}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function XS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class e_ extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const t_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Hv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function P(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",E=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Bv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${E?"opacity-50":""}`,children:t_.map(F=>u.jsx("button",{type:"button",disabled:E,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>P(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!E?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1),i=k.useRef(null);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:a,model:c,filter:f,onRemove:p}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":a.ref,"data-mode":f.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{ref:i,type:"button","aria-label":`Edit filter ${a.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(m=>!m),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:a.label})," ",kb(f)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${a.label}`,onClick:p,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(Wv,{dim:a,model:c,anchorRef:i,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const n_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function r_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function s_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function i_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(n_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();r_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=s_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function o_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const a_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(R=>n.some(Y=>String(R[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:P,safePage:U,start:E,visibleRows:F}=Sb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const R=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${R?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${R?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:R?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,R)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},E+R))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const R=g==null?void 0:g[M.key];if(!R)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=o_(C,M.key,R),z=R==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":R,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:a_[R]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[E+1,"–",Math.min(E+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=P-1,onClick:()=>b(M=>Math.min(P-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function l_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function c_(){var U,E;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=l_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((E=f==null?void 0:f.timeDimension)==null?void 0:E.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Bs(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?IS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),P=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):P.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:P,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Gv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Gv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Yv(n){document.documentElement.dataset.theme=n}function u_(){Yv(yf())}function d_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Gv,n),Yv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(d_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Qv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Kv="dashboard_filters",Jv="dashboard_ranges",qv="dashboard_filter_sources",Zv="dashboard_range_sources",Xv="dashboard_chart_filters",e0="dashboard_chart_ranges";function f_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function h_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function p_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function m_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=m_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function y_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function g_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function v_(n,e,t){return[e,...t].some(i=>gf(n,i))}const x_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return x_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function t0(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function n0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function r0(n,e,t){const i=Fs(n);if(i){const a=n0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function b_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[r0(n,{from:e,to:e},i)]:Rv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function w_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,P,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(t0(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([E,F])=>b_(E,F,i,f)),...Object.entries(p.ranges).map(([E,F])=>r0(E,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=(P=n.defaults)==null?void 0:P.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=n0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function S_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(R=>R.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([R,Y])=>{const z=Fs(R);return z?[{dimension:R,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([R,Y])=>{const z=Fs(R);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[R,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:R,value:Y})=>Y!==tr&&(!g||R.startsWith(`${g}.`))),T=Object.keys(v.ranges),P=[_,...T].find((R,Y,z)=>{if(!R||z.indexOf(R)!==Y||!v.ranges[R])return!1;const Q=Fs(R);return((i[R]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||R.startsWith(`${g}.`))}),U=P?v.ranges[P]:void 0,E=C?sy(C.dimension,{from:C.value,to:C.value}):P&&U?sy(P,U):null;return E&&(w.set("from",E.from),w.set("to",E.to)),`/explore?${w}`}function __(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function N_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function s0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function i0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function o0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function a0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function j_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Kv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Jv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(qv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Zv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Xv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(e0)??"{}")}catch{x={}}const b=o0(e),w=a0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:s0(v,w),chartRanges:i0(x,w)}}function k_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Kv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Jv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(qv,JSON.stringify(i)),Object.keys(a).length&&t.set(Zv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Xv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(e0,JSON.stringify(n.chartRanges)),t.toString()}function l0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function I_(n){try{const e=JSON.parse(localStorage.getItem(l0(n))??"[]");if(!Array.isArray(e))return[];const t=o0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=a0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:s0(c.chartFilters,p),chartRanges:i0(c.chartRanges,p)}}]})}catch{return[]}}function M_(n,e){try{return localStorage.setItem(l0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function D_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r +`)}function C_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function F_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Lv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const O_="600px";function T_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function A_(n,e,t=O_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:T_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const B_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function c0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),P=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,E=m!=="none",F=E?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,W;const M=A.metric<0?"negative":"positive",R=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/P*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":R||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":R,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),E?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${B_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((W=A.context)==null?void 0:W.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],R_=[],L_=[];function U_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=R_,baseSegments:m=L_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var te;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),P=k.useRef(null),[U,E]=k.useState(!1);k.useEffect(()=>{if(!(U||!P.current))return A_(P.current,()=>E(!0))},[U]);const F=t??((te=e.timeDimension)==null?void 0:te.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Bs(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:R,loading:Y,error:z}=Bn(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],W=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,ne=[i.ref,n.ref],X=Tt(n.ref,ne),le=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!R||!R.columns.includes(X))return null;const q=[];let ce=!1;for(const Me of R.rows){const Ue=Me[X];Ue==null?ce=!0:q.push(String(Ue))}const Ie=[];return q.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${q.map(Me=>Kn(Me,T.dialect)).join(", ")})`),ce&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[R,X,n.ref,T.dialect]),ye=k.useMemo(()=>le&&f&&F&&ie?[...p,...Bs(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[le,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=Bn(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,ne),G=!!R&&R.rows.length>0&&!R.columns.includes(O),H=k.useMemo(()=>{const q=new Map;if(!re.result||!re.result.columns.includes(O))return q;for(const ce of re.result.rows){const Ie=ce[X],Me=Ie==null?tr:String(Ie);q.set(Me,Number(ce[O]))}return q},[re.result,X,O]),N={format:i.format,type:i.type};function V(q,ce){switch(a){case"pctTotal":return c===void 0?void 0:_b(ce,c);case"delta":return Nb(ce,H.get(q),N);case"deltaPct":return jb(ce,H.get(q));default:return}}const de=R&&!G?R.rows.map(q=>{const ce=q[X],Ie=ce==null?tr:String(ce),Me=Number(q[O]??0);return{value:Ie,metric:Me,context:V(Ie,Me)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(c0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:de,containerRef:P,loading:!U||Y||G,selectedValues:W,formatMetric:q=>Gt(q,N),onToggle:q=>_({type:"toggleFilter",dim:n.ref,value:q}),contextColumn:a,contextOptions:E_,onContextColumn:q=>_({type:"setContextColumn",column:q}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function u0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[P,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(V=>{for(const de of V)b(Math.max(40,de.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const E=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(E.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...E.map(H=>H.value)),R=Math.max(...E.map(H=>H.value))-A||1,Y=E.map((H,N)=>({...H,x:F+N/(E.length-1)*(x-F*2),y:F+(1-(H.value-A)/R)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,W=Y.at(-1),ne=i||`Trend of ${E.length} points, latest ${a(W.value)}`;function X(H){var V;const N=(V=g.current)==null?void 0:V.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function le(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=X(H),V=le(N),de=Y[V];_(V),U({content:`${e!=null&&e[de.index]?`${e[de.index]}: `:""}${a(de.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:de.index,label:e==null?void 0:e[de.index],value:de.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=X(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=X(H);if(Math.abs(N-v.current)>6){const V=Y[le(Math.min(v.current,N))],de=Y[le(Math.max(v.current,N))];f({from:e[V.index],to:e[de.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":ne,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:W.x,cy:W.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:P})]})}const P_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},$_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${P_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:$_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),P="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(u0,{values:p,labels:m,onHover:E=>{C(E),b==null||b(E)},onBrush:w,formatValue:E=>pt(E,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:P,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:P,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,P]=k.useState(null),[U,E]=k.useState(null);k.useEffect(()=>{const oe=v.current;if(!oe)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(oe),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(oe=>oe.points),...i??[]].map(oe=>oe.y).filter(Number.isFinite),R=F<2||M.length===0,Y=R?0:Math.min(0,...M),z=R?1:Math.max(...M),Q=z-Y||1,W=_-Xt.left-Xt.right,ne=_l-Xt.top-Xt.bottom,X=oe=>Xt.left+(F<=1?0:oe/(F-1)*W),le=oe=>Xt.top+(1-(oe-Y)/Q)*ne,ie=oe=>ay(Math.round((oe-Xt.left)/W*(F-1)),0,F-1),ye=oe=>{const Oe=[];let st=[];return oe.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${X(Un).toFixed(1)},${le(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=R||n.some(oe=>!Number.isFinite(oe.y))?"":`M ${X(0).toFixed(1)},${le(Y).toFixed(1)} L ${n.map((oe,Oe)=>`${X(Oe).toFixed(1)},${le(oe.y).toFixed(1)}`).join(" L ")} L ${X(F-1).toFixed(1)},${le(Y).toFixed(1)} Z`;function O(oe){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?oe.clientX-Oe.left:0}function G(oe){if(R)return;const Oe=O(oe);P(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},E({...w.current}))}function H(oe){if(R||!g)return;oe.currentTarget.setPointerCapture(oe.pointerId),b.current=!0;const Oe=O(oe);w.current={a:Oe,b:Oe},E({...w.current})}function N(oe){oe.currentTarget.hasPointerCapture(oe.pointerId)&&oe.currentTarget.releasePointerCapture(oe.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,E(null)}function V(){P(null),b.current=!1,w.current=null,E(null)}const de=Math.max(1,Math.ceil(F/8)),te=[z,Y+Q*.66,Y+Q*.33,Y],q=T!=null&&T>=0&&T{const st=oe.points[q];return st&&Number.isFinite(st.y)?[{...oe,point:st,index:Oe}]:[]}),dt=q!=null?(i==null?void 0:i[q])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=q!=null?ay(X(q),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(R?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((oe,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",oe.label]},`${oe.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:R?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:V,onPointerCancel:V,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),te.map((oe,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:le(oe),y2:le(oe),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:le(oe)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(oe)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((oe,Oe)=>u.jsx("path",{d:ye(oe.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${oe.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:ne,className:"fill-chart-primary",opacity:.12}):null,q!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:X(q),x2:X(q),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:X(q),cy:le(St.y),r:3,className:"fill-faint"}):null,Ue.map(oe=>u.jsx("circle",{cx:X(q),cy:le(oe.point.y),r:3.5,fill:wd(oe.index)},`${oe.label}-${oe.index}`))]}):null,n.map((oe,Oe)=>Oe%de===0||Oe===F-1?u.jsx("text",{x:X(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(oe.x)},oe.x):null)]})}),Ue.length&&Me?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Me)}),Ue.map(oe=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:oe.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(oe.point.y)})]},`${oe.label}-${oe.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const z_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function V_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?ky(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${z_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const W_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function H_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} ${c}`).join(` -`),i=W_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function H_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const G_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!G_.has(n.type)}function Y_(n,e){return!!(n&&n===e)}function Q_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function K_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:bS(n.to,e)}}function J_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(fe=>fe.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=k.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),B=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?gS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:yS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=En(i,!C&&$.length?L(vd($,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=En(i,!C&&$.length&&w?L(Gm($,w,n.grain,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=En(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=En(i,C?L(vd([C.ref],B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=En(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Q_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Y_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:K_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Er=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,H_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Er,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(z_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>vS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(L_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function q_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),$=k.useMemo(()=>Es(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),B=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?jS(w,v,$,B,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=En(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function Z_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function c0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),B=Math.max(8,Math.min(48,U*.62)),F=Z_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-B)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:B,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+B/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Bs(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function u0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),B=Math.max(...C),F=$-T||1,A=B-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Bs(U,B,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Bs(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function X_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function e2(n){return pf(n.models.flatMap(e=>e.dimensions))}function t2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function n2({chart:n,columns:e,rows:t}){const i=M_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function r2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=f_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function s2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>e2(t),[t]),v=k.useMemo(()=>b_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=En(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=m_(e),$=T[0]??t2(e),U=br(C,w),B=vf(n,e,a),F=Xv(e,g),A=h_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=g_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(u0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=__(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=S_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(c0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:B.filters[C],onSelect:Y?he=>{c(y_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:w_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(n2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(r2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function i2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>k_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!I_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function o2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function a2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>N_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=j_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const B={...U.chartRanges??{}},F={...B[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?B[C]=F:delete B[C],{...U,chartRanges:B}});return}a(U=>{const B={...U.ranges},F={...U.rangeSources};return _?(B[w]=_,F[w]=C):(delete B[w],delete F[w]),{...U,ranges:B,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(i2,{document:n,state:i,onLoad:a}),u.jsx(o2,{}),u.jsx(Zo,{}),u.jsx(X_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:D_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(s2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function l2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function c2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function u2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(B=>B.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=pS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const B=new Map;for(const F of t.models)for(const A of F.dimensions)B.set(A.ref,{dim:A,model:F});return B},[t]),C=Object.entries(n.filters).flatMap(([B,F])=>{const A=_.get(B);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:B})},B)]:[]}),T=u.jsx(cS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(B=>{const F=B.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,B.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:B.label??B.id},B.id)})}):u.jsx(Gv,{view:n.view,onChange:B=>e({type:"setView",view:B})}),u.jsx(Vv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(B,F)=>e({type:"setDateRange",range:B,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(B,F)=>e({type:"setComparison",comparison:B,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:B=>e({type:"setGrain",grain:B})}),u.jsx(s_,{timezone:n.timezone,disabled:!b,onChange:B=>e({type:"setTimezone",timezone:B})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(l2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(qS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(ZS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(l_,{}),children:u.jsxs(XS,{children:[n.view==="home"?u.jsx(C_,{}):null,n.view==="explore"?u.jsx(J_,{}):null,n.view==="pivot"?u.jsx(q_,{}):null]},n.view)})}function d2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new lS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=d_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(c2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(a2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(HS,{catalog:i.catalog,backend:t,children:u.jsx(u2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function f2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),B=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/B)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Bs(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Bs($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const h2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${h2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function p2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>p2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};k.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function B(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:B,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function m2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const y2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function d0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function g2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:d0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return d0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:y2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:g2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const B=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:B}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function v2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function x2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const f0=Math.PI*2;function b2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*f0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function w2(n,e,t,i,a,c){const f=Math.min(c-a,f0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function S2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=b2(n),x=v.reduce((U,B)=>U+B.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:w2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function _2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,B=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*B+B/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*B+.5,width:Math.max(1,U-1),height:Math.max(1,B-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function N2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function j2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=N2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(B=>B.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=B=>Fn.top+(1-B/x)*w,C=b/v.length,T=Bs(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((B,F)=>{const A=_(B);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(B)})]},F)}),v.map((B,F)=>{const A=Fn.left+C*F,M=_(B.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":B.x0,"data-x1":B.x1,"data-count":B.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(B.x0)} – ${i(B.x1)}`,rows:[{label:"Count",value:B.count.toLocaleString()}]}))},F)}),v.map((B,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(B.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function k2(n){let e=2166136261;for(let t=0;t>>0}function I2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function M2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=I2(k2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function D2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>M2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function C2(n,e,t){return Math.min(Math.max(n,e),t)}function F2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,B=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${B(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${B(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Bs(0,C,4).map((z,Q)=>{const V=B(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function O2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function T2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function A2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),B=Bs(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[B.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function R2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function L2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,R2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const U2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],P2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],$2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),z2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),V2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),W2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function H2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,$]=k.useState("orders.revenue"),[U,B]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,L]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,V]=k.useState("2025-06-15"),[X,ne]=k.useState({from:"2025-06-01",to:"2025-06-21"}),ae=k.useMemo(()=>L2($2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:U2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(a0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Vv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Gv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(l0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(c0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(x2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(S2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(F2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(f2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(j2,{values:V2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(u0,{points:z2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(_2,{cells:W2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(D2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(O2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(T2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(A2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:B,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:P2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(v2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue +`),i=H_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function G_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const Y_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!Y_.has(n.type)}function Q_(n,e){return!!(n&&n===e)}function K_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function J_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:wS(n.to,e)}}function q_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(he=>he.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(he=>he.ref)),b=ki(t,n.model).filter(he=>!m||x.has(he.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(he=>he.ref===n.selectedMetric)??b.find(he=>he.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(he=>he.ref===_.ref),P=k.useMemo(()=>{const he=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...he,_.ref]:he},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),E=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?vS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:gS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,R=he=>he?{...he,timezone:M}:null,Y=Bn(i,!C&&P.length?R(vd(P,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=Bn(i,!C&&P.length&&w?R(Gm(P,w,n.grain,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=Bn(i,!C&&P.length&&A?R(vd(P,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),W=Bn(i,C?R(vd([C.ref],E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),ne=Bn(i,!C&&_&&w&&A?R(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),X=Y.error??z.error??Q.error??ne.error??W.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const le=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(le.map(he=>he.ref)),ye=pc(t,p.name).filter(he=>n.joinedDims.includes(he.ref)&&!ie.has(he.ref)),re=[...le,...ye].filter(he=>he.type!=="time"),O=K_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...P,H]:P,V=_&&H?[_.ref,H]:[],de=v[0]?Tt(v[0].ref,P):_?Tt(_.ref,P):null,te=he=>!he||!de||he.columns.includes(de),q=te(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,ce=te(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=te(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Me=_?Tt(_.ref,P):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,V):"",St=H?Tt(H,N):"",ir=H?Tt(H,V):"",rn=St?cy(Ie,St):Ie,or=q&&Me?Number(q[Me]):NaN,hs=ce&&Me?Number(ce[Me]):void 0,oe=Ue?rn.map(he=>({x:String(he[St]??""),y:Number(he[Ue])})):[],Oe=ir?cy(((ps=ne.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&oe.length>0&&Oe.length>0?(()=>{const he=String(Oe[0][ir]??""),mt=oe[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(he,String(sn[ir]??""),n.grain),Number(sn[dt]));return oe.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Q_(W.resultKey,W.queryKey),Un=_t?((Wi=W.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=W.result)==null?void 0:Or.columns)??[]:[]).map(he=>({key:he,label:Re(he),numeric:Un.some(mt=>typeof mt[he]=="number")}));function Ui(he){e(he?{type:"setDateRange",range:J_(he,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[X?u.jsx(Li,{message:X}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(he=>{const mt=Tt(he.ref,P),Ar=Tt(he.ref,N),sn=q?Number(q[mt]):NaN,Us=ce?Number(ce[mt]):void 0,Br=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:he.ref,label:he.label,valueText:pt(sn,G_(he)),delta:Us!==void 0?ky(sn,Us):null,sparkValues:Br,selected:n.selectedMetric===he.ref,loading:Y.loading&&!q,onSelect:Pn=>e({type:"setMetric",metric:Pn})},he.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),W.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(he,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(V_,{metric:_,points:oe,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:he=>xS(he,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(he=>O===null||O===he.ref).map(he=>u.jsx(U_,{dim:he,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===he.ref,onExpandedChange:mt=>f(mt?he.ref:null)},he.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=ne.result)==null?void 0:Gi.sql,"Focused metric":(ia=W.result)==null?void 0:ia.sql}})]})}function Z_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),P=k.useMemo(()=>Bs(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),E=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?kS(w,v,P,E,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:R,error:Y}=Bn(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),W=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),ne=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function X(re){const O=W.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function le(re,O){if(re.numeric){const G=Q.get(W.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):ne.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:ne,rows:(M==null?void 0:M.rows)??[],loading:R,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:X,renderCell:le}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function X_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function d0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const R=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return R.observe(M),()=>R.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,P=T(0),U=_/Math.max(n.length,1),E=Math.max(8,Math.min(48,U*.62)),F=X_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,R)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},R)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:P,y2:P,className:"stroke-line"}),n.map((M,R)=>{const Y=M.filterValue??M.label,z=v[R]??0,Q=T(z),W=Math.abs(Q-P),ne=Cn.left+U*R+(U-E)/2,X=Math.min(Q,P);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?le=>{(le.key==="Enter"||le.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:ne,y:X,width:E,height:W,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:ne+E/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${R}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Es(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function f0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(W=>Number.isFinite(W.x)&&Number.isFinite(W.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(W=>W.series??""))],_=b.map(W=>W.x),C=b.map(W=>W.y),T=Math.min(..._),P=Math.max(..._),U=Math.min(...C),E=Math.max(...C),F=P-T||1,A=E-U||1,M=m-Vt.left-Vt.right,R=e-Vt.top-Vt.bottom,Y=W=>Vt.left+(W-T)/F*M,z=W=>Vt.top+(1-(W-U)/A)*R,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((W,ne)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(ne)}}),W||"(default)"]},W||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Es(U,E,4).map((W,ne)=>{const X=z(W);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:X,y2:X,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:X+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(W)})]},`y${ne}`)}),Es(T,P,5).map((W,ne)=>{const X=Y(W);return u.jsxs("g",{children:[u.jsx("line",{x1:X,x2:X,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:X,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(W)})]},`x${ne}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+R/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+R/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((W,ne)=>u.jsx("circle",{cx:Y(W.x),cy:z(W.y),r:3.5,fill:xn(w.indexOf(W.series??"")),fillOpacity:.75,"data-x":W.x,"data-y":W.y,"data-label":W.label,...x(u.jsx(us,{title:W.label??W.series,rows:[{label:t??"x",value:a(W.x)},{label:i??"y",value:c(W.y)}]}))},ne))]}),u.jsx(sr,{tip:v})]})}function e2(){const n=zv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function t2(n){return pf(n.models.flatMap(e=>e.dimensions))}function n2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function r2({chart:n,columns:e,rows:t}){const i=D_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function s2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=h_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function i2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var W,ne,X,le,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>t2(t),[t]),v=k.useMemo(()=>w_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=Bn(i,v),b=((W=x.result)==null?void 0:W.rows)??[],w=((ne=x.result)==null?void 0:ne.columns)??[],_=e.query.dimensions??[],C=((X=e.encoding)==null?void 0:X.x)??_[0]??"",T=y_(e),P=T[0]??n2(e),U=br(C,w),E=vf(n,e,a),F=t0(e,g),A=p_(e,C),M=((le=e.title)==null?void 0:le.trim())||Re(e.id),R=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=v_(e,C,R),z=R.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(V=>({x:Number(V[U]),y:Number(V[H]),label:String(V[U]??""),series:O?String(V[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(f0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:V=>pt(V,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=N_(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:V=>pt(V,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?V=>f(C,V):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=__(b,U,G,z);return H.map((N,V)=>{const de=N.data.slice(0,30),te=T.length>1||H.length>1,q=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[te?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:q}):null,u.jsx(d0,{data:de,ariaLabel:`${M}, ${q||Re(O)}, ${de.length} categories`,selectedLabel:E.filters[C],onSelect:Y?ce=>{c(g_(e,C,ce,R,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${V}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re(P),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:S_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(r2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(s2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function o2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>I_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!M_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function a2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function l2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>j_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=k_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a(P=>{var U;return{...P,chartFilters:{...P.chartFilters??{},[_]:{...((U=P.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a(P=>({...P,filters:{...P.filters,...w},filterSources:{...P.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,P;const C=fc(n,b);if((((P=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:P.scope)??"dashboard")==="chart"){a(U=>{const E={...U.chartRanges??{}},F={...E[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?E[C]=F:delete E[C],{...U,chartRanges:E}});return}a(U=>{const E={...U.ranges},F={...U.rangeSources};return _?(E[w]=_,F[w]=C):(delete E[w],delete F[w]),{...U,ranges:E,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(o2,{document:n,state:i,onLoad:a}),u.jsx(a2,{}),u.jsx(Zo,{}),u.jsx(e2,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},P={...T[b]??{}};return delete P[w],Object.keys(P).length?T[b]=P:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},P={...T[b]??{}};return delete P[w],Object.keys(P).length?T[b]=P:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Tv,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:C_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(i2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=zv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function c2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function u2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function d2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(E=>E.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Uv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=mS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const E=new Map;for(const F of t.models)for(const A of F.dimensions)E.set(A.ref,{dim:A,model:F});return E},[t]),C=Object.entries(n.filters).flatMap(([E,F])=>{const A=_.get(E);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:E})},E)]:[]}),T=u.jsx(uS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),P=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(E=>{const F=E.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,E.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:E.label??E.id},E.id)})}):u.jsx(Qv,{view:n.view,onChange:E=>e({type:"setView",view:E})}),u.jsx(Hv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(E,F)=>e({type:"setDateRange",range:E,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(E,F)=>e({type:"setComparison",comparison:E,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:E=>e({type:"setGrain",grain:E})}),u.jsx(i_,{timezone:n.timezone,disabled:!b,onChange:E=>e({type:"setTimezone",timezone:E})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(c2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(ZS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Tv,{brand:T,toolbar:P,filters:f?void 0:U,rail:u.jsx(XS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(c_,{}),children:u.jsxs(e_,{children:[n.view==="home"?u.jsx(F_,{}):null,n.view==="explore"?u.jsx(q_,{}):null,n.view==="pivot"?u.jsx(Z_,{}):null]},n.view)})}function f2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new cS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=f_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(u2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(l2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(GS,{catalog:i.catalog,backend:t,children:u.jsx(d2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function h2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,P=Math.min(...w),U=Math.max(...w),E=U-P||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,R=ie=>en.top+(1-(ie-P)/E)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,W=M(0),ne=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${R(w[ye]).toFixed(1)}`).join(" L "),X=xn(1),le=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:X}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":le,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Es(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Es(P,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:R(ie)+3,textAnchor:"start",className:"text-[10px]",fill:X,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:W,y2:W,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,W),width:z,height:Math.abs(O-W),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:X}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${ne}`,fill:"none",stroke:X,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:R(w[ye]),r:3,fill:X,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:X}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const p2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${p2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function m2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>m2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),P=M=>{var R;return((R=e.find(Y=>Y.value===M))==null?void 0:R.label)??M};k.useEffect(()=>{if(!m)return;function M(R){p.current&&!p.current.contains(R.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const R=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(R);return}n.onChange(M.value),x(""),g(!1)}}function E(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(R=>Math.min(R+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(R=>Math.max(R-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?P(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:P(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${P(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(R=>R!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:E,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,R)=>u.jsxs("li",{id:`${f}-${R}`,role:"option","aria-selected":T.has(M.value),"data-active":R===b||void 0,onMouseEnter:()=>w(R),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function y2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const g2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function h0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function v2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:h0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return h0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,R]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:R}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const P=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:g2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:v2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(R=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(R.iso),"data-date":R.iso,onClick:()=>_(R.iso),className:`py-1 text-center tnum ${T(R.iso)?"bg-accent text-surface":C(R.iso)?"bg-accent-soft text-accent":R.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${R.iso===P?"underline underline-offset-2":""}`,children:R.day},R.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const E=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:E}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function x2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function b2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const p0=Math.PI*2;function w2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*p0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function S2(n,e,t,i,a,c){const f=Math.min(c-a,p0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function _2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=w2(n),x=v.reduce((U,E)=>U+E.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),P=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":P,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:S2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function N2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,P=i-mr.top-mr.bottom,U=T/x.length,E=P/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,R)=>u.jsx("text",{x:mr.left-6,y:mr.top+R*E+E/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,R)=>R%F===0?u.jsx("text",{x:mr.left+R*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,R)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),W=Q!=null&&Number.isFinite(Q),ne=W?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+R*E+.5,width:Math.max(1,U-1),height:Math.max(1,E-1),"data-x":Y,"data-y":M,"data-value":W?Q:void 0,className:W&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:W?ne:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:W?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function j2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function k2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=j2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(E=>E.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=E=>Fn.top+(1-E/x)*w,C=b/v.length,T=Es(0,x,4),P=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((E,F)=>{const A=_(E);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(E)})]},F)}),v.map((E,F)=>{const A=Fn.left+C*F,M=_(E.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":E.x0,"data-x1":E.x1,"data-count":E.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(E.x0)} – ${i(E.x1)}`,rows:[{label:"Count",value:E.count.toLocaleString()}]}))},F)}),v.map((E,F)=>F%P===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(E.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function I2(n){let e=2166136261;for(let t=0;t>>0}function M2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function D2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=M2(I2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:P+(p[z]-U)/M*(t-P*2),y:P+(m[z]-F)/R*(i-P*2),degree:x[z]}))}function C2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>D2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),P=v.get(_.target);return!T||!P?null:u.jsx("line",{x1:T.x,y1:T.y,x2:P.x,y2:P.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function F2(n,e,t){return Math.min(Math.max(n,e),t)}function O2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,W)=>{const ne=z.values[W];return Number.isFinite(ne)&&ne>0?ne:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((W,ne)=>_[ne]+W);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,P=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,E=z=>fn.top+(1-z/C)*P,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],W=z===0?n.map(()=>0):w[z-1],ne=Q.map((le,ie)=>`${U(ie).toFixed(1)},${E(le).toFixed(1)}`).join(" L "),X=[...W.keys()].reverse().map(le=>`${U(le).toFixed(1)},${E(W[le]).toFixed(1)}`).join(" L ");return`M ${ne} L ${X} Z`}function R(z){const Q=z.currentTarget.getBoundingClientRect(),W=(z.clientX-Q.left)/Q.width*p,ne=Math.round((W-fn.left)/T*(x-1));v(ne>=0&&neu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:R,onMouseLeave:()=>v(null),children:[Es(0,C,4).map((z,Q)=>{const W=E(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:W,y2:W,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:W+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function T2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function A2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function B2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function R2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,P=_/g.length,U=Math.max(10,Math.min(56,P*.62)),E=Es(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[E.map((A,M)=>{const R=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:R,y2:R,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:R+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const R=hn.left+P*M+(P-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",W=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",ne=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:R,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:W,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),ne?u.jsx("line",{x1:R+U,x2:hn.left+P*(M+1)+(P-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:R+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function L2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function U2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,L2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const P2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],$2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],z2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),V2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),W2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),H2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function G2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,P]=k.useState("orders.revenue"),[U,E]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,R]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,W]=k.useState("2025-06-15"),[ne,X]=k.useState({from:"2025-06-01",to:"2025-06-21"}),le=k.useMemo(()=>U2(z2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],V=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?V:-V}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:P2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(c0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(V=>V!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(V=>V!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Hv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Qv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(u0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(d0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(b2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(_2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(O2,{labels:le.labels,series:le.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(h2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(k2,{values:W2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(f0,{points:V2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(N2,{cells:H2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(R2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(C2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(T2,{checked:M,onChange:R,label:"Compact rows"}),u.jsx(A2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(B2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:P,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:E,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:W,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:ne,onChange:X,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:$2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(x2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue FROM orders WHERE orders.status = 'completed' GROUP BY orders.region -ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(m2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],G2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Y2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Q2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],K2=[31,42,38,55,60,74],J2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),q2=`select region, sum(revenue) as revenue +ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(y2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],Y2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Q2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],K2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],J2=[31,42,38,55,60,74],q2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),Z2=`select region, sum(revenue) as revenue from orders where created_at >= date '2025-01-01' group by all -order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function Z2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:G2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:K2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:J2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:q2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Y2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Q2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}c_();const h0=document.getElementById("root");if(!h0)throw new Error("Missing #root element");vb.createRoot(h0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(H2,{}):window.location.pathname==="/typography"?u.jsx(Z2,{}):u.jsx(d2,{})})); +order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function X2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:Y2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:J2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:q2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:Z2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Q2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:K2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}u_();const m0=document.getElementById("root");if(!m0)throw new Error("Missing #root element");xb.createRoot(m0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(G2,{}):window.location.pathname==="/typography"?u.jsx(X2,{}):u.jsx(f2,{})})); diff --git a/sidemantic-rs/ui/assets/index-DBXs5BBH.css b/sidemantic-rs/ui/assets/index-DBXs5BBH.css new file mode 100644 index 000000000..e6340e97b --- /dev/null +++ b/sidemantic-rs/ui/assets/index-DBXs5BBH.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[min\(25dvh\,8rem\)\]{max-height:min(25dvh,8rem)}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic-rs/ui/index.html b/sidemantic-rs/ui/index.html index 55587f6f8..6536f910e 100644 --- a/sidemantic-rs/ui/index.html +++ b/sidemantic-rs/ui/index.html @@ -4,8 +4,8 @@ Sidemantic - - + +
diff --git a/sidemantic/ui/static/assets/index-BCalwD9m.css b/sidemantic/ui/static/assets/index-BCalwD9m.css deleted file mode 100644 index d502892bd..000000000 --- a/sidemantic/ui/static/assets/index-BCalwD9m.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic/ui/static/assets/index-gv_X5qC6.js b/sidemantic/ui/static/assets/index-BizYMIT7.js similarity index 57% rename from sidemantic/ui/static/assets/index-gv_X5qC6.js rename to sidemantic/ui/static/assets/index-BizYMIT7.js index 706c5d746..e06b7effa 100644 --- a/sidemantic/ui/static/assets/index-gv_X5qC6.js +++ b/sidemantic/ui/static/assets/index-BizYMIT7.js @@ -1,4 +1,4 @@ -var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>cb(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Ee={};/** +var ub=Object.defineProperty;var db=(n,e,t)=>e in n?ub(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Dn=(n,e,t)=>db(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(a){if(a.ep)return;a.ep=!0;const c=t(a);fetch(a.href,c)}})();var id={exports:{}},Co={},od={exports:{}},Be={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var im;function ub(){if(im)return Ee;im=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.iterator;function b(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,C={};function T(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}T.prototype.isReactComponent={},T.prototype.setState=function(N,W){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,W,"setState")},T.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function $(){}$.prototype=T.prototype;function U(N,W,J){this.props=N,this.context=W,this.refs=C,this.updater=J||w}var B=U.prototype=new $;B.constructor=U,_(B,T.prototype),B.isPureReactComponent=!0;var F=Array.isArray,A=Object.prototype.hasOwnProperty,M={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function Y(N,W,J){var oe,te={},he=null,Ie=null;if(W!=null)for(oe in W.ref!==void 0&&(Ie=W.ref),W.key!==void 0&&(he=""+W.key),W)A.call(W,oe)&&!L.hasOwnProperty(oe)&&(te[oe]=W[oe]);var Fe=arguments.length-2;if(Fe===1)te.children=J;else if(1e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var am;function db(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function fb(){return lm||(lm=1,id.exports=db()),id.exports}var u=fb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** + */var am;function hb(){if(am)return Co;am=1;var n=Vd(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function f(p,m,g){var v,x={},b=null,w=null;g!==void 0&&(b=""+g),m.key!==void 0&&(b=""+m.key),m.ref!==void 0&&(w=m.ref);for(v in m)i.call(m,v)&&!c.hasOwnProperty(v)&&(x[v]=m[v]);if(p&&p.defaultProps)for(v in m=p.defaultProps,m)x[v]===void 0&&(x[v]=m[v]);return{$$typeof:e,type:p,key:b,ref:w,props:x,_owner:a.current}}return Co.Fragment=t,Co.jsx=f,Co.jsxs=f,Co}var lm;function pb(){return lm||(lm=1,id.exports=hb()),id.exports}var u=pb(),k=Vd(),hl={},ad={exports:{}},zt={},ld={exports:{}},cd={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var cm;function hb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,W=O[N];if(0>>1;Na(te,H))hea(Ie,te)?(O[N]=Ie,O[he]=H,N=he):(O[N]=te,O[oe]=H,N=oe);else if(hea(Ie,H))O[N]=Ie,O[he]=H,N=he;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,B(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,$(Y),Y=-1),w=!0;var H=b;try{for(B(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!V());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var W=N(x.expirationTime<=G);G=n.unstable_now(),typeof W=="function"?x.callback=W:x===t(m)&&i(m),B(G)}else i(m);x=t(m)}if(x!==null)var J=!0;else{var oe=t(g);oe!==null&&re(F,oe.startTime-G),J=!1}return J}finally{x=null,b=H,w=!1}}var M=!1,L=null,Y=-1,z=5,Q=-1;function V(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?($(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=W,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function pb(){return um||(um=1,ld.exports=hb()),ld.exports}/** + */var cm;function mb(){return cm||(cm=1,(function(n){function e(O,G){var H=O.length;O.push(G);e:for(;0>>1,V=O[N];if(0>>1;Na(q,H))cea(Ie,q)?(O[N]=Ie,O[ce]=H,N=ce):(O[N]=q,O[te]=H,N=te);else if(cea(Ie,H))O[N]=Ie,O[ce]=H,N=ce;else break e}}return G}function a(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var m=[],g=[],v=1,x=null,b=3,w=!1,_=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(O){for(var G=t(g);G!==null;){if(G.callback===null)i(g);else if(G.startTime<=O)i(g),G.sortIndex=G.expirationTime,e(m,G);else break;G=t(g)}}function F(O){if(C=!1,E(O),!_)if(t(m)!==null)_=!0,ye(A);else{var G=t(g);G!==null&&re(F,G.startTime-O)}}function A(O,G){_=!1,C&&(C=!1,P(Y),Y=-1),w=!0;var H=b;try{for(E(G),x=t(m);x!==null&&(!(x.expirationTime>G)||O&&!W());){var N=x.callback;if(typeof N=="function"){x.callback=null,b=x.priorityLevel;var V=N(x.expirationTime<=G);G=n.unstable_now(),typeof V=="function"?x.callback=V:x===t(m)&&i(m),E(G)}else i(m);x=t(m)}if(x!==null)var de=!0;else{var te=t(g);te!==null&&re(F,te.startTime-G),de=!1}return de}finally{x=null,b=H,w=!1}}var M=!1,R=null,Y=-1,z=5,Q=-1;function W(){return!(n.unstable_now()-QO||125N?(O.sortIndex=H,e(g,O),t(m)===null&&O===t(g)&&(C?(P(Y),Y=-1):C=!0,re(F,H-N))):(O.sortIndex=V,e(m,O),_||w||(_=!0,ye(A))),O},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(O){var G=b;return function(){var H=b;b=G;try{return O.apply(this,arguments)}finally{b=H}}}})(cd)),cd}var um;function yb(){return um||(um=1,ld.exports=mb()),ld.exports}/** * @license React * react-dom.production.min.js * @@ -30,26 +30,26 @@ var lb=Object.defineProperty;var cb=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var dm;function mb(){if(dm)return zt;dm=1;var n=Vd(),e=pb();function t(r){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+r,o=1;o"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var $=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace($,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function B(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function b(r){return m.call(x,r)?!0:m.call(v,r)?!1:g.test(r)?x[r]=!0:(v[r]=!0,!1)}function w(r,s,o,l){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return l?!1:o!==null?!o.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function _(r,s,o,l){if(s===null||typeof s>"u"||w(r,s,o,l))return!0;if(l)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function C(r,s,o,l,d,h,y){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=o,this.propertyName=r,this.type=s,this.sanitizeURL=h,this.removeEmptyString=y}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){T[r]=new C(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var s=r[0];T[s]=new C(s,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){T[r]=new C(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){T[r]=new C(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){T[r]=new C(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){T[r]=new C(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){T[r]=new C(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){T[r]=new C(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){T[r]=new C(r,5,!1,r.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function U(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var s=r.replace(P,U);T[s]=new C(s,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!1,!1)}),T.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){T[r]=new C(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,s,o,l){var d=T.hasOwnProperty(s)?T[s]:null;(d!==null?d.type!==0:l||!(2S||d[y]!==h[S]){var j=` -`+d[y].replace(" at new "," at ");return r.displayName&&j.includes("")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{J=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?W(r):""}function te(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=oe(r.type,!1),r;case 11:return r=oe(r.type.render,!1),r;case 1:return r=oe(r.type,!0),r;default:return""}}function he(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case L:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case ne:return"Suspense";case ae:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case V:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case X:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:he(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return he(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Fe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Fe(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function le(r,s){s=s.checked,s!=null&&B(r,"checked",s,!1)}function Oe(r,s){le(r,s);var o=Fe(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Fe(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 fe(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Er=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Er?Pn?Pn.push(r):Pn=[r]:Er=r}function Nf(){if(Er){var r=Er,s=Pn;if(Pn=Er=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(N0(r)/j0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function D0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return rx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ix(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function ox(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function mx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Ix(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<De?(wt=ve,ve=null):wt=ve.sibling;var ze=K(E,ve,R[De],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(E,ve),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(De===R.length)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;DeDe?(wt=ve,ve=null):wt=ve.sibling;var es=K(E,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(E,ve),I=h(es,I,De),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(E,ve),rt&&xs(E,De),pe;if(ve===null){for(;!ze.done;De++,ze=R.next())ze=Z(E,ze.value,ee),ze!==null&&(I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(E,De),pe}for(ve=l(E,ve);!ze.done;De++,ze=R.next())ze=se(ve,E,De,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?De:ze.key),I=h(ze,I,De),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(ab){return s(E,ab)}),rt&&xs(E,De),pe}function ut(E,I,R,ee){if(typeof R=="object"&&R!==null&&R.type===L&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case A:e:{for(var pe=R.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=R.type,pe===L){if(ge.tag===7){o(E,ge.sibling),I=d(ge,R.props.children),I.return=E,E=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Bh(pe)===ge.type){o(E,ge.sibling),I=d(ge,R.props),I.ref=yo(E,ge,R),I.return=E,E=I;break e}o(E,ge);break}else s(E,ge);ge=ge.sibling}R.type===L?(I=Is(R.props.children,E.mode,ee,R.key),I.return=E,E=I):(ee=il(R.type,R.key,R.props,null,E.mode,ee),ee.ref=yo(E,I,R),ee.return=E,E=ee)}return y(E);case M:e:{for(ge=R.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===R.containerInfo&&I.stateNode.implementation===R.implementation){o(E,I.sibling),I=d(I,R.children||[]),I.return=E,E=I;break e}else{o(E,I);break}else s(E,I);I=I.sibling}I=ed(R,E.mode,ee),I.return=E,E=I}return y(E);case ye:return ge=R._init,ut(E,I,ge(R._payload),ee)}if(Un(R))return ue(E,I,R,ee);if(G(R))return de(E,I,R,ee);Ea(E,R)}return typeof R=="string"&&R!==""||typeof R=="number"?(R=""+R,I!==null&&I.tag===6?(o(E,I.sibling),I=d(I,R),I.return=E,E=I):(o(E,I),I=Xu(R,E.mode,ee),I.return=E,E=I),y(E)):o(E,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ba=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ba.current;et(Ba),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,P=j.next;j.next=null,y===null?h=P:y.next=P,y=j;var q=r.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==y&&(S===null?q.firstBaseUpdate=P:S.next=P,q.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,q=P=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){q!==null&&(q=q.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,de=S;switch(K=s,se=o,de.tag){case 1:if(ue=de.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=de.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(P=q=se,j=Z):q=q.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(q===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=P,d.lastBaseUpdate=q,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Fx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ox(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Tx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Fx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Cx.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0")&&(j=j.replace("",r.displayName)),j}while(1<=y&&0<=S);break}}}finally{de=!1,Error.prepareStackTrace=o}return(r=r?r.displayName||r.name:"")?V(r):""}function q(r){switch(r.tag){case 5:return V(r.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return r=te(r.type,!1),r;case 11:return r=te(r.type.render,!1),r;case 1:return r=te(r.type,!0),r;default:return""}}function ce(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case R:return"Fragment";case M:return"Portal";case z:return"Profiler";case Y:return"StrictMode";case X:return"Suspense";case le:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case W:return(r.displayName||"Context")+".Consumer";case Q:return(r._context.displayName||"Context")+".Provider";case ne:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case ie:return s=r.displayName||null,s!==null?s:ce(r.type)||"Memo";case ye:s=r._payload,r=r._init;try{return ce(r(s))}catch{}}return null}function Ie(r){var s=r.type;switch(r.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=s.render,r=r.displayName||r.name||"",s.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ce(s);case 8:return s===Y?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Me(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ue(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function dt(r){var s=Ue(r)?"checked":"value",o=Object.getOwnPropertyDescriptor(r.constructor.prototype,s),l=""+r[s];if(!r.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){l=""+y,h.call(this,y)}}),Object.defineProperty(r,s,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function St(r){r._valueTracker||(r._valueTracker=dt(r))}function ir(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var o=s.getValue(),l="";return r&&(l=Ue(r)?r.checked?"true":"false":r.value),r=l,r!==o?(s.setValue(r),!0):!1}function rn(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function or(r,s){var o=s.checked;return H({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??r._wrapperState.initialChecked})}function hs(r,s){var o=s.defaultValue==null?"":s.defaultValue,l=s.checked!=null?s.checked:s.defaultChecked;o=Me(s.value!=null?s.value:o),r._wrapperState={initialChecked:l,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function oe(r,s){s=s.checked,s!=null&&E(r,"checked",s,!1)}function Oe(r,s){oe(r,s);var o=Me(s.value),l=s.type;if(o!=null)l==="number"?(o===0&&r.value===""||r.value!=o)&&(r.value=""+o):r.value!==""+o&&(r.value=""+o);else if(l==="submit"||l==="reset"){r.removeAttribute("value");return}s.hasOwnProperty("value")?_t(r,s.type,o):s.hasOwnProperty("defaultValue")&&_t(r,s.type,Me(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(r.defaultChecked=!!s.defaultChecked)}function st(r,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var l=s.type;if(!(l!=="submit"&&l!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+r._wrapperState.initialValue,o||s===r.value||(r.value=s),r.defaultValue=s}o=r.name,o!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,o!==""&&(r.name=o)}function _t(r,s,o){(s!=="number"||rn(r.ownerDocument)!==r)&&(o==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+o&&(r.defaultValue=""+o))}var Un=Array.isArray;function Fr(r,s,o,l){if(r=r.options,s){s={};for(var d=0;d"+s.valueOf().toString()+"",s=ps.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;s.firstChild;)r.appendChild(s.firstChild)}});function Or(r,s){if(s){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=s;return}}r.textContent=s}var Tr={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},sa=["Webkit","ms","Moz","O"];Object.keys(Tr).forEach(function(r){sa.forEach(function(s){s=s+r.charAt(0).toUpperCase()+r.substring(1),Tr[s]=Tr[r]})});function Hi(r,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Tr.hasOwnProperty(r)&&Tr[r]?(""+s).trim():s+"px"}function Gi(r,s){r=r.style;for(var o in s)if(s.hasOwnProperty(o)){var l=o.indexOf("--")===0,d=Hi(o,s[o],l);o==="float"&&(o="cssFloat"),l?r.setProperty(o,d):r[o]=d}}var ia=H({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 he(r,s){if(s){if(ia[r]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(t(137,r));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(t(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(t(61))}if(s.style!=null&&typeof s.style!="object")throw Error(t(62))}}function mt(r,s){if(r.indexOf("-")===-1)return typeof s.is=="string";switch(r){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 Ar=null;function sn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Us=null,Br=null,Pn=null;function Sf(r){if(r=mo(r)){if(typeof Us!="function")throw Error(t(280));var s=r.stateNode;s&&(s=Ma(s),Us(r.stateNode,r.type,s))}}function _f(r){Br?Pn?Pn.push(r):Pn=[r]:Br=r}function Nf(){if(Br){var r=Br,s=Pn;if(Pn=Br=null,Sf(r),s)for(r=0;r>>=0,r===0?32:31-(k0(r)/I0|0)|0}var ua=64,da=4194304;function Ji(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function fa(r,s){var o=r.pendingLanes;if(o===0)return 0;var l=0,d=r.suspendedLanes,h=r.pingedLanes,y=o&268435455;if(y!==0){var S=y&~d;S!==0?l=Ji(S):(h&=y,h!==0&&(l=Ji(h)))}else y=o&~d,y!==0?l=Ji(y):h!==0&&(l=Ji(h));if(l===0)return 0;if(s!==0&&s!==l&&(s&d)===0&&(d=l&-l,h=s&-s,d>=h||d===16&&(h&4194240)!==0))return s;if((l&4)!==0&&(l|=o&16),s=r.entangledLanes,s!==0)for(r=r.entanglements,s&=l;0o;o++)s.push(r);return s}function qi(r,s,o){r.pendingLanes|=s,s!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,s=31-Sn(s),r[s]=o}function F0(r,s){var o=r.pendingLanes&~s;r.pendingLanes=s,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=s,r.mutableReadLanes&=s,r.entangledLanes&=s,s=r.entanglements;var l=r.eventTimes;for(r=r.expirationTimes;0=io),Zf=" ",Xf=!1;function eh(r,s){switch(r){case"keyup":return ix.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function th(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var zs=!1;function ax(r,s){switch(r){case"compositionend":return th(s);case"keypress":return s.which!==32?null:(Xf=!0,Zf);case"textInput":return r=s.data,r===Zf&&Xf?null:r;default:return null}}function lx(r,s){if(zs)return r==="compositionend"||!Uc&&eh(r,s)?(r=Gf(),ga=Tc=Pr=null,zs=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:o,offset:s-r};r=l}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=lh(o)}}function uh(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?uh(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function dh(){for(var r=window,s=rn();s instanceof r.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)r=s.contentWindow;else break;s=rn(r.document)}return s}function zc(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}function gx(r){var s=dh(),o=r.focusedElem,l=r.selectionRange;if(s!==o&&o&&o.ownerDocument&&uh(o.ownerDocument.documentElement,o)){if(l!==null&&zc(o)){if(s=l.start,r=l.end,r===void 0&&(r=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(r,o.value.length);else if(r=(s=o.ownerDocument||document)&&s.defaultView||window,r.getSelection){r=r.getSelection();var d=o.textContent.length,h=Math.min(l.start,d);l=l.end===void 0?h:Math.min(l.end,d),!r.extend&&h>l&&(d=l,l=h,h=d),d=ch(o,h);var y=ch(o,l);d&&y&&(r.rangeCount!==1||r.anchorNode!==d.node||r.anchorOffset!==d.offset||r.focusNode!==y.node||r.focusOffset!==y.offset)&&(s=s.createRange(),s.setStart(d.node,d.offset),r.removeAllRanges(),h>l?(r.addRange(s),r.extend(y.node,y.offset)):(s.setEnd(y.node,y.offset),r.addRange(s)))}}for(s=[],r=o;r=r.parentNode;)r.nodeType===1&&s.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Vs=null,Vc=null,co=null,Wc=!1;function fh(r,s,o){var l=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wc||Vs==null||Vs!==rn(l)||(l=Vs,"selectionStart"in l&&zc(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),co&&lo(co,l)||(co=l,l=ja(Vc,"onSelect"),0Qs||(r.current=nu[Qs],nu[Qs]=null,Qs--)}function qe(r,s){Qs++,nu[Qs]=r.current,r.current=s}var Wr={},kt=Vr(Wr),Rt=Vr(!1),gs=Wr;function Ks(r,s){var o=r.type.contextTypes;if(!o)return Wr;var l=r.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===s)return l.__reactInternalMemoizedMaskedChildContext;var d={},h;for(h in o)d[h]=s[h];return l&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=s,r.__reactInternalMemoizedMaskedChildContext=d),d}function Lt(r){return r=r.childContextTypes,r!=null}function Da(){et(Rt),et(kt)}function Ih(r,s,o){if(kt.current!==Wr)throw Error(t(168));qe(kt,s),qe(Rt,o)}function Mh(r,s,o){var l=r.stateNode;if(s=s.childContextTypes,typeof l.getChildContext!="function")return o;l=l.getChildContext();for(var d in l)if(!(d in s))throw Error(t(108,Ie(r)||"Unknown",d));return H({},o,l)}function Ca(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Wr,gs=kt.current,qe(kt,r),qe(Rt,Rt.current),!0}function Dh(r,s,o){var l=r.stateNode;if(!l)throw Error(t(169));o?(r=Mh(r,s,gs),l.__reactInternalMemoizedMergedChildContext=r,et(Rt),et(kt),qe(kt,r)):et(Rt),qe(Rt,o)}var lr=null,Fa=!1,ru=!1;function Ch(r){lr===null?lr=[r]:lr.push(r)}function Dx(r){Fa=!0,Ch(r)}function Hr(){if(!ru&&lr!==null){ru=!0;var r=0,s=Ge;try{var o=lr;for(Ge=1;r>=y,d-=y,cr=1<<32-Sn(s)+d|o<Ce?(wt=ve,ve=null):wt=ve.sibling;var ze=K(B,ve,L[Ce],ee);if(ze===null){ve===null&&(ve=wt);break}r&&ve&&ze.alternate===null&&s(B,ve),I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze,ve=wt}if(Ce===L.length)return o(B,ve),rt&&xs(B,Ce),pe;if(ve===null){for(;CeCe?(wt=ve,ve=null):wt=ve.sibling;var es=K(B,ve,ze.value,ee);if(es===null){ve===null&&(ve=wt);break}r&&ve&&es.alternate===null&&s(B,ve),I=h(es,I,Ce),ge===null?pe=es:ge.sibling=es,ge=es,ve=wt}if(ze.done)return o(B,ve),rt&&xs(B,Ce),pe;if(ve===null){for(;!ze.done;Ce++,ze=L.next())ze=Z(B,ze.value,ee),ze!==null&&(I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze);return rt&&xs(B,Ce),pe}for(ve=l(B,ve);!ze.done;Ce++,ze=L.next())ze=se(ve,B,Ce,ze.value,ee),ze!==null&&(r&&ze.alternate!==null&&ve.delete(ze.key===null?Ce:ze.key),I=h(ze,I,Ce),ge===null?pe=ze:ge.sibling=ze,ge=ze);return r&&ve.forEach(function(cb){return s(B,cb)}),rt&&xs(B,Ce),pe}function ut(B,I,L,ee){if(typeof L=="object"&&L!==null&&L.type===R&&L.key===null&&(L=L.props.children),typeof L=="object"&&L!==null){switch(L.$$typeof){case A:e:{for(var pe=L.key,ge=I;ge!==null;){if(ge.key===pe){if(pe=L.type,pe===R){if(ge.tag===7){o(B,ge.sibling),I=d(ge,L.props.children),I.return=B,B=I;break e}}else if(ge.elementType===pe||typeof pe=="object"&&pe!==null&&pe.$$typeof===ye&&Eh(pe)===ge.type){o(B,ge.sibling),I=d(ge,L.props),I.ref=yo(B,ge,L),I.return=B,B=I;break e}o(B,ge);break}else s(B,ge);ge=ge.sibling}L.type===R?(I=Is(L.props.children,B.mode,ee,L.key),I.return=B,B=I):(ee=il(L.type,L.key,L.props,null,B.mode,ee),ee.ref=yo(B,I,L),ee.return=B,B=ee)}return y(B);case M:e:{for(ge=L.key;I!==null;){if(I.key===ge)if(I.tag===4&&I.stateNode.containerInfo===L.containerInfo&&I.stateNode.implementation===L.implementation){o(B,I.sibling),I=d(I,L.children||[]),I.return=B,B=I;break e}else{o(B,I);break}else s(B,I);I=I.sibling}I=ed(L,B.mode,ee),I.return=B,B=I}return y(B);case ye:return ge=L._init,ut(B,I,ge(L._payload),ee)}if(Un(L))return ue(B,I,L,ee);if(G(L))return fe(B,I,L,ee);Ba(B,L)}return typeof L=="string"&&L!==""||typeof L=="number"?(L=""+L,I!==null&&I.tag===6?(o(B,I.sibling),I=d(I,L),I.return=B,B=I):(o(B,I),I=Xu(L,B.mode,ee),I.return=B,B=I),y(B)):o(B,I)}return ut}var Xs=Rh(!0),Lh=Rh(!1),Ea=Vr(null),Ra=null,ei=null,cu=null;function uu(){cu=ei=Ra=null}function du(r){var s=Ea.current;et(Ea),r._currentValue=s}function fu(r,s,o){for(;r!==null;){var l=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),r===o)break;r=r.return}}function ti(r,s){Ra=r,cu=ei=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&s)!==0&&(Ut=!0),r.firstContext=null)}function ln(r){var s=r._currentValue;if(cu!==r)if(r={context:r,memoizedValue:s,next:null},ei===null){if(Ra===null)throw Error(t(308));ei=r,Ra.dependencies={lanes:0,firstContext:r}}else ei=ei.next=r;return s}var bs=null;function hu(r){bs===null?bs=[r]:bs.push(r)}function Uh(r,s,o,l){var d=s.interleaved;return d===null?(o.next=o,hu(s)):(o.next=d.next,d.next=o),s.interleaved=o,dr(r,l)}function dr(r,s){r.lanes|=s;var o=r.alternate;for(o!==null&&(o.lanes|=s),o=r,r=r.return;r!==null;)r.childLanes|=s,o=r.alternate,o!==null&&(o.childLanes|=s),o=r,r=r.return;return o.tag===3?o.stateNode:null}var Gr=!1;function pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ph(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function fr(r,s){return{eventTime:r,lane:s,tag:0,payload:null,callback:null,next:null}}function Yr(r,s,o){var l=r.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,dr(r,o)}return d=l.interleaved,d===null?(s.next=s,hu(l)):(s.next=d.next,d.next=s),l.interleaved=s,dr(r,o)}function La(r,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}function $h(r,s){var o=r.updateQueue,l=r.alternate;if(l!==null&&(l=l.updateQueue,o===l)){var d=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var y={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?d=h=y:h=h.next=y,o=o.next}while(o!==null);h===null?d=h=s:h=h.next=s}else d=h=s;o={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,effects:l.effects},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=s:r.next=s,o.lastBaseUpdate=s}function Ua(r,s,o,l){var d=r.updateQueue;Gr=!1;var h=d.firstBaseUpdate,y=d.lastBaseUpdate,S=d.shared.pending;if(S!==null){d.shared.pending=null;var j=S,$=j.next;j.next=null,y===null?h=$:y.next=$,y=j;var J=r.alternate;J!==null&&(J=J.updateQueue,S=J.lastBaseUpdate,S!==y&&(S===null?J.firstBaseUpdate=$:S.next=$,J.lastBaseUpdate=j))}if(h!==null){var Z=d.baseState;y=0,J=$=j=null,S=h;do{var K=S.lane,se=S.eventTime;if((l&K)===K){J!==null&&(J=J.next={eventTime:se,lane:0,tag:S.tag,payload:S.payload,callback:S.callback,next:null});e:{var ue=r,fe=S;switch(K=s,se=o,fe.tag){case 1:if(ue=fe.payload,typeof ue=="function"){Z=ue.call(se,Z,K);break e}Z=ue;break e;case 3:ue.flags=ue.flags&-65537|128;case 0:if(ue=fe.payload,K=typeof ue=="function"?ue.call(se,Z,K):ue,K==null)break e;Z=H({},Z,K);break e;case 2:Gr=!0}}S.callback!==null&&S.lane!==0&&(r.flags|=64,K=d.effects,K===null?d.effects=[S]:K.push(S))}else se={eventTime:se,lane:K,tag:S.tag,payload:S.payload,callback:S.callback,next:null},J===null?($=J=se,j=Z):J=J.next=se,y|=K;if(S=S.next,S===null){if(S=d.shared.pending,S===null)break;K=S,S=K.next,K.next=null,d.lastBaseUpdate=K,d.shared.pending=null}}while(!0);if(J===null&&(j=Z),d.baseState=j,d.firstBaseUpdate=$,d.lastBaseUpdate=J,s=d.shared.interleaved,s!==null){d=s;do y|=d.lane,d=d.next;while(d!==s)}else h===null&&(d.shared.lanes=0);_s|=y,r.lanes=y,r.memoizedState=Z}}function zh(r,s,o){if(r=s.effects,s.effects=null,r!==null)for(s=0;so?o:4,r(!0);var l=xu.transition;xu.transition={};try{r(!1),s()}finally{Ge=o,xu.transition=l}}function ap(){return cn().memoizedState}function Tx(r,s,o){var l=qr(r);if(o={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null},lp(r))cp(s,o);else if(o=Uh(r,s,o,l),o!==null){var d=Ot();Mn(o,r,l,d),up(o,s,l)}}function Ax(r,s,o){var l=qr(r),d={lane:l,action:o,hasEagerState:!1,eagerState:null,next:null};if(lp(r))cp(s,d);else{var h=r.alternate;if(r.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var y=s.lastRenderedState,S=h(y,o);if(d.hasEagerState=!0,d.eagerState=S,_n(S,y)){var j=s.interleaved;j===null?(d.next=d,hu(s)):(d.next=j.next,j.next=d),s.interleaved=d;return}}catch{}finally{}o=Uh(r,s,d,l),o!==null&&(d=Ot(),Mn(o,r,l,d),up(o,s,l))}}function lp(r){var s=r.alternate;return r===ot||s!==null&&s===ot}function cp(r,s){bo=za=!0;var o=r.pending;o===null?s.next=s:(s.next=o.next,o.next=s),r.pending=s}function up(r,s,o){if((o&4194240)!==0){var l=s.lanes;l&=r.pendingLanes,o|=l,s.lanes=o,Mc(r,o)}}var Ha={readContext:ln,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Bx={readContext:ln,useCallback:function(r,s){return Wn().memoizedState=[r,s===void 0?null:s],r},useContext:ln,useEffect:Xh,useImperativeHandle:function(r,s,o){return o=o!=null?o.concat([r]):null,Va(4194308,4,np.bind(null,s,r),o)},useLayoutEffect:function(r,s){return Va(4194308,4,r,s)},useInsertionEffect:function(r,s){return Va(4,2,r,s)},useMemo:function(r,s){var o=Wn();return s=s===void 0?null:s,r=r(),o.memoizedState=[r,s],r},useReducer:function(r,s,o){var l=Wn();return s=o!==void 0?o(s):s,l.memoizedState=l.baseState=s,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:s},l.queue=r,r=r.dispatch=Tx.bind(null,ot,r),[l.memoizedState,r]},useRef:function(r){var s=Wn();return r={current:r},s.memoizedState=r},useState:qh,useDebugValue:ku,useDeferredValue:function(r){return Wn().memoizedState=r},useTransition:function(){var r=qh(!1),s=r[0];return r=Ox.bind(null,r[1]),Wn().memoizedState=r,[s,r]},useMutableSource:function(){},useSyncExternalStore:function(r,s,o){var l=ot,d=Wn();if(rt){if(o===void 0)throw Error(t(407));o=o()}else{if(o=s(),bt===null)throw Error(t(349));(Ss&30)!==0||Gh(l,s,o)}d.memoizedState=o;var h={value:o,getSnapshot:s};return d.queue=h,Xh(Qh.bind(null,l,h,r),[r]),l.flags|=2048,_o(9,Yh.bind(null,l,h,o,s),void 0,null),o},useId:function(){var r=Wn(),s=bt.identifierPrefix;if(rt){var o=ur,l=cr;o=(l&~(1<<32-Sn(l)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function $x(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,zx=typeof WeakSet=="function"?WeakSet:Set,ce=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Vx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,P=0,q=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++P===d&&(S=y),K===h&&++q===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ce=s;ce!==null;)if(s=ce,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ce=r;else for(;ce!==null;){s=ce;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var de=ue.memoizedProps,ut=ue.memoizedState,E=s.stateNode,I=E.getSnapshotBeforeUpdate(s.elementType===s.type?de:jn(s.type,de),ut);E.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var R=s.stateNode.containerInfo;R.nodeType===1?R.textContent="":R.nodeType===9&&R.documentElement&&R.removeChild(R.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ce=r;break}ce=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[jx],delete s[kx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Ep(r){return r.tag===5||r.tag===3||r.tag===4}function Bp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Ep(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new zx),s.forEach(function(l){var d=Zx.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Hx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ce=r.current;ce!==null;){var h=ce,y=h.child;if((ce.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function qx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function Zx(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,Ux(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=eb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ba,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var P=h.updateQueue;if(P!==null){P=P.shared;var q=P.pending;q===null?j.next=j:(j.next=q.next,q.next=j),P.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function Xx(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new Xx(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function eb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===X)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case L:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case ne:return r=dn(13,o,s,d),r.elementType=ne,r.lanes=h,r;case ae:return r=dn(19,o,s,d),r.elementType=ae,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case V:y=9;break e;case X:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function tb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new tb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function nb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=mb(),ad.exports}var hm;function gb(){if(hm)return hl;hm=1;var n=yb();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var vb=gb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function xb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function _y(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function bb(n,e={}){return _y(n,{...e,compact:!0})}function wb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return xb(n)}function pt(n,e={}){return _y(n,e)}function Gt(n,e={}){return bb(n,e)}function Ny(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function Sb(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function _b(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:Ny(i)}}function Nb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:Ny(t)}}function jy(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function jb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,ky=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function Iy(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>ky.test(t.name))}function kb(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function My(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of kb(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Ib(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=Iy(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:My(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Mb(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:ky.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=Iy(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:My(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Db(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,$){c.push([w,C,T,$])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Cb=new TextDecoder("utf-8"),Md=n=>Cb.decode(n),Fb=new TextEncoder,Wd=n=>Fb.encode(n),Ob=n=>typeof n=="number",Tb=n=>typeof n=="boolean",At=n=>typeof n=="function",Bn=n=>n!=null&&Object(n)===n,Go=n=>Bn(n)&&At(n.then),mc=n=>Bn(n)&&At(n[Symbol.iterator]),Hd=n=>Bn(n)&&At(n[Symbol.asyncIterator]),Dd=n=>Bn(n)&&Bn(n.schema),Dy=n=>Bn(n)&&"done"in n&&"value"in n,Cy=n=>Bn(n)&&At(n.stat)&&Ob(n.fd),Fy=n=>Bn(n)&&Gd(n.body),Oy=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>Bn(n)&&At(n.cancel)&&At(n.getReader)&&!Oy(n),Ty=n=>Bn(n)&&At(n.read)&&At(n.pipe)&&Tb(n.readable)&&!Oy(n),Ab=n=>Bn(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Bb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Rb=n=>Bb(Uint8Array,n);function Ay(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(Ay(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Lb=n=>Ay(Uint8Array,n);function Ub(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*Pb(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Rb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Wb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[$,U]of w)n.off($,U);try{const $=n.destroy;$&&$.call(n,_),_=void 0}catch($){_=$||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Hb=void 0;function Yo(n){if(n===null)return"null";if(n===Hb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function Py(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Gb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Gb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return $y(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return $y(this);case"string":return Ko(this);case"default":return Kb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Yb=BigInt(4294967296)*BigInt(4294967296),Qb=Yb-BigInt(1);function $y(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Vy=Symbol.toStringTag;ls[Vy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Wy=Symbol.toStringTag;Os[Wy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Hy=Symbol.toStringTag;Ll[Hy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Gy=Symbol.toStringTag;Ul[Gy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Yy=Symbol.toStringTag;Pl[Yy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Qy=Symbol.toStringTag;$l[Qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Ky=Symbol.toStringTag;zl[Ky]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}Jy=Symbol.toStringTag;Vl[Jy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}qy=Symbol.toStringTag;Wl[qy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Zy=Symbol.toStringTag;Hl[Zy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Xy=Symbol.toStringTag;Gl[Xy]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}eg=Symbol.toStringTag;Yl[eg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}tg=Symbol.toStringTag;Ql[tg]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}ng=Symbol.toStringTag;Kl[ng]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}rg=Symbol.toStringTag;Jl[rg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Et extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}sg=Symbol.toStringTag;Et[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Et.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}ig=Symbol.toStringTag;ql[ig]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}og=Symbol.toStringTag;Zl[og]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ag=Symbol.toStringTag;Xl[ag]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}lg=Symbol.toStringTag;ec[lg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const Jb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?Jb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}cg=Symbol.toStringTag;Di[cg]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return qb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function qb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const ug=new Float64Array(1),li=new Uint32Array(ug.buffer);function dg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Zb(n){if(n!==n)return 32256;ug[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function Me(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const Xb=(n,e,t)=>{n[e]=Math.floor(t/864e5)},fg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},hg=({values:n},e,t)=>{n[e]=Zb(t)},tw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return hg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},pg=({values:n},e,t)=>{Xb(n,e,t.valueOf())},mg=({values:n},e,t)=>{n[e]=BigInt(t)},nw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},yg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,i),gg=({values:n,valueOffsets:e},t,i)=>fg(n,e,t,Wd(i)),rw=(n,e,t)=>{n.type.unit===bn.DAY?pg(n,e,t):mg(n,e,t)},vg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},xg=({values:n},e,t)=>{n[e]=BigInt(t)},bg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},sw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return vg(n,e,t);case _e.MILLISECOND:return xg(n,e,t);case _e.MICROSECOND:return bg(n,e,t);case _e.NANOSECOND:return wg(n,e,t)}},Sg=({values:n},e,t)=>{n[e]=t},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Sg(n,e,t);case _e.MILLISECOND:return _g(n,e,t);case _e.MICROSECOND:return Ng(n,e,t);case _e.NANOSECOND:return jg(n,e,t)}},ow=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},aw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},cw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),hw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?dw(e,t):t instanceof Je?uw(e,t):Array.isArray(t)?cw(e,t):fw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},pw=(n,e,t)=>{n.type.mode===Yt.Dense?kg(n,e,t):Ig(n,e,t)},kg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},mw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},yw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Mg(n,e,t):Dg(n,e,t)},Mg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Dg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Cg=({values:n},e,t)=>{n[e]=t},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},gw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Cg(n,e,t);case _e.MILLISECOND:return Fg(n,e,t);case _e.MICROSECOND:return Og(n,e,t);case _e.NANOSECOND:return Tg(n,e,t)}},vw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xw(this[On],this[_i])}}class xw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const ww=(n,e)=>864e5*n[e],Sw=(n,e)=>null,Ag=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},_w=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<ww(n,e),Bg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],Nw=({stride:n,values:e},t)=>dg(e[n*t]),Rg=({values:n},e)=>n[e],jw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Lg=({values:n,valueOffsets:e},t)=>Ag(n,e,t),Ug=({values:n,valueOffsets:e},t)=>{const i=Ag(n,e,t);return i!==null?Md(i):null},kw=({values:n},e)=>n[e],Iw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:dg(e[t]),Mw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Bg(n,e),Pg=({values:n},e)=>1e3*tt(n[e]),$g=({values:n},e)=>tt(n[e]),zg=({values:n},e)=>Py(n[e],BigInt(1e3)),Vg=({values:n},e)=>Py(n[e],BigInt(1e6)),Dw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Pg(n,e);case _e.MILLISECOND:return $g(n,e);case _e.MICROSECOND:return zg(n,e);case _e.NANOSECOND:return Vg(n,e)}},Wg=({values:n},e)=>n[e],Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Wg(n,e);case _e.MILLISECOND:return Hg(n,e);case _e.MICROSECOND:return Gg(n,e);case _e.NANOSECOND:return Yg(n,e)}},Fw=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Ow=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Tw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Aw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Qg(n,e):Kg(n,e),Qg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Bw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Rw=(n,e)=>n.type.unit===rr.DAY_TIME?Jg(n,e):qg(n,e),Jg=({values:n},e)=>n.subarray(2*e,2*(e+1)),qg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Zg=({values:n},e)=>n[e],Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],Lw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Zg(n,e);case _e.MILLISECOND:return Xg(n,e);case _e.MICROSECOND:return ev(n,e);case _e.NANOSECOND:return tv(n,e)}},Uw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(Sw);xe.prototype.visitBool=je(_w);xe.prototype.visitInt=je(kw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Rg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Rg);xe.prototype.visitFloat=je(Iw);xe.prototype.visitFloat16=je(Nw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Ug);xe.prototype.visitLargeUtf8=je(Ug);xe.prototype.visitBinary=je(Lg);xe.prototype.visitLargeBinary=je(Lg);xe.prototype.visitFixedSizeBinary=je(jw);xe.prototype.visitDate=je(Mw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Bg);xe.prototype.visitTimestamp=je(Dw);xe.prototype.visitTimestampSecond=je(Pg);xe.prototype.visitTimestampMillisecond=je($g);xe.prototype.visitTimestampMicrosecond=je(zg);xe.prototype.visitTimestampNanosecond=je(Vg);xe.prototype.visitTime=je(Cw);xe.prototype.visitTimeSecond=je(Wg);xe.prototype.visitTimeMillisecond=je(Hg);xe.prototype.visitTimeMicrosecond=je(Gg);xe.prototype.visitTimeNanosecond=je(Yg);xe.prototype.visitDecimal=je(Fw);xe.prototype.visitList=je(Ow);xe.prototype.visitStruct=je(Aw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Qg);xe.prototype.visitSparseUnion=je(Kg);xe.prototype.visitDictionary=je(Bw);xe.prototype.visitInterval=je(Rw);xe.prototype.visitIntervalDayTime=je(Jg);xe.prototype.visitIntervalYearMonth=je(qg);xe.prototype.visitDuration=je(Lw);xe.prototype.visitDurationSecond=je(Zg);xe.prototype.visitDurationMillisecond=je(Xg);xe.prototype.visitDurationMicrosecond=je(ev);xe.prototype.visitDurationNanosecond=je(tv);xe.prototype.visitFixedSizeList=je(Uw);xe.prototype.visitMap=je(Tw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new $w)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new Pw(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Pw{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class $w{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function nv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Ei(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Ub(n,t):!1:n instanceof Map?Vw(n):Array.isArray(n)?zw(n):n instanceof Je?Ww(n):Hw(n,!0)}function zw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Gw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Yw(n,t):!1}}function Gw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Ed(new Xd(t,n,e,null,rv)).subarray(0,i)),a}return t}function Ed(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Bd(n,e,a)+Bd(n,i,t)+Kw(n,a>>3,i-a>>3)}function Kw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const Jw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=Jw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Bd(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const qw=new Vo;function Be(n){return qw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function sv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function iv(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function ov(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function e1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,rv)){if(!a)return i;++i}return-1}function Ce(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return e1(n,t)}const i=Qt.getVisitFn(n),a=Ei(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new t1(f)})}class t1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=dv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,fv[f.typeId]),this._offsets=iv(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Zw(this.data)}get nullCount(){return sv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(nv(this,e,t,({data:i,_offsets:a},c,f)=>ov(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}uv=Symbol.toStringTag;Je[uv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);dv[t]={get:i,set:a,indexOf:c},fv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:av(wn.getVisitFnByTypeId(t))},indexOf:{value:lv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var n1=By,r1=Ii;class rf{static decode(e){e=new r1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new s1(i,t)}static encode(e){const t=new n1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class o1 extends i1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new a1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof o1?this.source=new Ms(mn.fromAsyncIterable(e)):Ty(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Fy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class a1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class c1 extends mv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Ed(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?u1(i[t]):me.isBool(e)?Ed(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function u1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Bt(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Bt(n,e)}function Mr(n,e){return n===e||Bt(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Bt(n,e)&&n.precision===e.precision}function d1(n,e){return n===e||Bt(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Bt(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function f1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function h1(n,e){return n===e||Bt(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Bt(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Bt(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Bt(n,e)&&n.unit===e.unit}function m1(n,e){return n===e||Bt(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function y1(n,e){return n===e||Bt(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=d1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=f1;Se.prototype.visitStruct=h1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=p1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=m1;Se.prototype.visitMap=y1;const cs=new Se;function g1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return v1(n,e.map(t=>t.data.concat()))}function v1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Be({type:new Et(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function x1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Be({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var yv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Et)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!g1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??iv(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=sv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +`+h.stack}return{value:r,source:s,stack:d,digest:null}}function Du(r,s,o){return{value:r,source:null,stack:o??null,digest:s??null}}function Cu(r,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Lx=typeof WeakMap=="function"?WeakMap:Map;function pp(r,s,o){o=fr(-1,o),o.tag=3,o.payload={element:null};var l=s.value;return o.callback=function(){Xa||(Xa=!0,Hu=l),Cu(r,s)},o}function mp(r,s,o){o=fr(-1,o),o.tag=3;var l=r.type.getDerivedStateFromError;if(typeof l=="function"){var d=s.value;o.payload=function(){return l(d)},o.callback=function(){Cu(r,s)}}var h=r.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(o.callback=function(){Cu(r,s),typeof l!="function"&&(Kr===null?Kr=new Set([this]):Kr.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})}),o}function yp(r,s,o){var l=r.pingCache;if(l===null){l=r.pingCache=new Lx;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(o)||(d.add(o),r=Zx.bind(null,r,s,o),s.then(r,r))}function gp(r){do{var s;if((s=r.tag===13)&&(s=r.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return r;r=r.return}while(r!==null);return null}function vp(r,s,o,l,d){return(r.mode&1)===0?(r===s?r.flags|=65536:(r.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=fr(-1,1),s.tag=2,Yr(o,s,1))),o.lanes|=1),r):(r.flags|=65536,r.lanes=d,r)}var Ux=F.ReactCurrentOwner,Ut=!1;function Ft(r,s,o,l){s.child=r===null?Lh(s,null,o,l):Xs(s,r.child,o,l)}function xp(r,s,o,l,d){o=o.render;var h=s.ref;return ti(s,d),l=wu(r,s,o,l,h,d),o=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&o&&su(s),s.flags|=1,Ft(r,s,l,d),s.child)}function bp(r,s,o,l,d){if(r===null){var h=o.type;return typeof h=="function"&&!Zu(h)&&h.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=h,wp(r,s,h,l,d)):(r=il(o.type,null,l,s,s.mode,d),r.ref=s.ref,r.return=s,s.child=r)}if(h=r.child,(r.lanes&d)===0){var y=h.memoizedProps;if(o=o.compare,o=o!==null?o:lo,o(y,l)&&r.ref===s.ref)return hr(r,s,d)}return s.flags|=1,r=Xr(h,l),r.ref=s.ref,r.return=s,s.child=r}function wp(r,s,o,l,d){if(r!==null){var h=r.memoizedProps;if(lo(h,l)&&r.ref===s.ref)if(Ut=!1,s.pendingProps=l=h,(r.lanes&d)!==0)(r.flags&131072)!==0&&(Ut=!0);else return s.lanes=r.lanes,hr(r,s,d)}return Fu(r,s,o,l,d)}function Sp(r,s,o){var l=s.pendingProps,d=l.children,h=r!==null?r.memoizedState:null;if(l.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(ii,Zt),Zt|=o;else{if((o&1073741824)===0)return r=h!==null?h.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:r,cachePool:null,transitions:null},s.updateQueue=null,qe(ii,Zt),Zt|=r,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:o,qe(ii,Zt),Zt|=l}else h!==null?(l=h.baseLanes|o,s.memoizedState=null):l=o,qe(ii,Zt),Zt|=l;return Ft(r,s,d,o),s.child}function _p(r,s){var o=s.ref;(r===null&&o!==null||r!==null&&r.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Fu(r,s,o,l,d){var h=Lt(o)?gs:kt.current;return h=Ks(s,h),ti(s,d),o=wu(r,s,o,l,h,d),l=Su(),r!==null&&!Ut?(s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~d,hr(r,s,d)):(rt&&l&&su(s),s.flags|=1,Ft(r,s,o,d),s.child)}function Np(r,s,o,l,d){if(Lt(o)){var h=!0;Ca(s)}else h=!1;if(ti(s,d),s.stateNode===null)Qa(r,s),fp(s,o,l),Mu(s,o,l,d),l=!0;else if(r===null){var y=s.stateNode,S=s.memoizedProps;y.props=S;var j=y.context,$=o.contextType;typeof $=="object"&&$!==null?$=ln($):($=Lt(o)?gs:kt.current,$=Ks(s,$));var J=o.getDerivedStateFromProps,Z=typeof J=="function"||typeof y.getSnapshotBeforeUpdate=="function";Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==l||j!==$)&&hp(s,y,l,$),Gr=!1;var K=s.memoizedState;y.state=K,Ua(s,l,y,d),j=s.memoizedState,S!==l||K!==j||Rt.current||Gr?(typeof J=="function"&&(Iu(s,o,J,l),j=s.memoizedState),(S=Gr||dp(s,o,S,l,K,j,$))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(s.flags|=4194308)):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=j),y.props=l,y.state=j,y.context=$,l=S):(typeof y.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{y=s.stateNode,Ph(r,s),S=s.memoizedProps,$=s.type===s.elementType?S:jn(s.type,S),y.props=$,Z=s.pendingProps,K=y.context,j=o.contextType,typeof j=="object"&&j!==null?j=ln(j):(j=Lt(o)?gs:kt.current,j=Ks(s,j));var se=o.getDerivedStateFromProps;(J=typeof se=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(S!==Z||K!==j)&&hp(s,y,l,j),Gr=!1,K=s.memoizedState,y.state=K,Ua(s,l,y,d);var ue=s.memoizedState;S!==Z||K!==ue||Rt.current||Gr?(typeof se=="function"&&(Iu(s,o,se,l),ue=s.memoizedState),($=Gr||dp(s,o,$,l,K,ue,j)||!1)?(J||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,ue,j),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,ue,j)),typeof y.componentDidUpdate=="function"&&(s.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ue),y.props=l,y.state=ue,y.context=j,l=$):(typeof y.componentDidUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||S===r.memoizedProps&&K===r.memoizedState||(s.flags|=1024),l=!1)}return Ou(r,s,o,l,h,d)}function Ou(r,s,o,l,d,h){_p(r,s);var y=(s.flags&128)!==0;if(!l&&!y)return d&&Dh(s,o,!1),hr(r,s,h);l=s.stateNode,Ux.current=s;var S=y&&typeof o.getDerivedStateFromError!="function"?null:l.render();return s.flags|=1,r!==null&&y?(s.child=Xs(s,r.child,null,h),s.child=Xs(s,null,S,h)):Ft(r,s,S,h),s.memoizedState=l.state,d&&Dh(s,o,!0),s.child}function jp(r){var s=r.stateNode;s.pendingContext?Ih(r,s.pendingContext,s.pendingContext!==s.context):s.context&&Ih(r,s.context,!1),mu(r,s.containerInfo)}function kp(r,s,o,l,d){return Zs(),lu(d),s.flags|=256,Ft(r,s,o,l),s.child}var Tu={dehydrated:null,treeContext:null,retryLane:0};function Au(r){return{baseLanes:r,cachePool:null,transitions:null}}function Ip(r,s,o){var l=s.pendingProps,d=it.current,h=!1,y=(s.flags&128)!==0,S;if((S=y)||(S=r!==null&&r.memoizedState===null?!1:(d&2)!==0),S?(h=!0,s.flags&=-129):(r===null||r.memoizedState!==null)&&(d|=1),qe(it,d&1),r===null)return au(s),r=s.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((s.mode&1)===0?s.lanes=1:r.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(y=l.children,r=l.fallback,h?(l=s.mode,h=s.child,y={mode:"hidden",children:y},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=y):h=ol(y,l,0,null),r=Is(r,l,o,null),h.return=s,r.return=s,h.sibling=r,s.child=h,s.child.memoizedState=Au(o),s.memoizedState=Tu,r):Bu(s,y));if(d=r.memoizedState,d!==null&&(S=d.dehydrated,S!==null))return Px(r,s,y,l,S,d,o);if(h){h=l.fallback,y=s.mode,d=r.child,S=d.sibling;var j={mode:"hidden",children:l.children};return(y&1)===0&&s.child!==d?(l=s.child,l.childLanes=0,l.pendingProps=j,s.deletions=null):(l=Xr(d,j),l.subtreeFlags=d.subtreeFlags&14680064),S!==null?h=Xr(S,h):(h=Is(h,y,o,null),h.flags|=2),h.return=s,l.return=s,l.sibling=h,s.child=l,l=h,h=s.child,y=r.child.memoizedState,y=y===null?Au(o):{baseLanes:y.baseLanes|o,cachePool:null,transitions:y.transitions},h.memoizedState=y,h.childLanes=r.childLanes&~o,s.memoizedState=Tu,l}return h=r.child,r=h.sibling,l=Xr(h,{mode:"visible",children:l.children}),(s.mode&1)===0&&(l.lanes=o),l.return=s,l.sibling=null,r!==null&&(o=s.deletions,o===null?(s.deletions=[r],s.flags|=16):o.push(r)),s.child=l,s.memoizedState=null,l}function Bu(r,s){return s=ol({mode:"visible",children:s},r.mode,0,null),s.return=r,r.child=s}function Ya(r,s,o,l){return l!==null&&lu(l),Xs(s,r.child,null,o),r=Bu(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function Px(r,s,o,l,d,h,y){if(o)return s.flags&256?(s.flags&=-257,l=Du(Error(t(422))),Ya(r,s,y,l)):s.memoizedState!==null?(s.child=r.child,s.flags|=128,null):(h=l.fallback,d=s.mode,l=ol({mode:"visible",children:l.children},d,0,null),h=Is(h,d,y,null),h.flags|=2,l.return=s,h.return=s,l.sibling=h,s.child=l,(s.mode&1)!==0&&Xs(s,r.child,null,y),s.child.memoizedState=Au(y),s.memoizedState=Tu,h);if((s.mode&1)===0)return Ya(r,s,y,null);if(d.data==="$!"){if(l=d.nextSibling&&d.nextSibling.dataset,l)var S=l.dgst;return l=S,h=Error(t(419)),l=Du(h,l,void 0),Ya(r,s,y,l)}if(S=(y&r.childLanes)!==0,Ut||S){if(l=bt,l!==null){switch(y&-y){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(l.suspendedLanes|y))!==0?0:d,d!==0&&d!==h.retryLane&&(h.retryLane=d,dr(r,d),Mn(l,r,d,-1))}return qu(),l=Du(Error(t(421))),Ya(r,s,y,l)}return d.data==="$?"?(s.flags|=128,s.child=r.child,s=Xx.bind(null,r),d._reactRetry=s,null):(r=h.treeContext,qt=zr(d.nextSibling),Jt=s,rt=!0,Nn=null,r!==null&&(on[an++]=cr,on[an++]=ur,on[an++]=vs,cr=r.id,ur=r.overflow,vs=s),s=Bu(s,l.children),s.flags|=4096,s)}function Mp(r,s,o){r.lanes|=s;var l=r.alternate;l!==null&&(l.lanes|=s),fu(r.return,s,o)}function Eu(r,s,o,l,d){var h=r.memoizedState;h===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:o,tailMode:d}:(h.isBackwards=s,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=o,h.tailMode=d)}function Dp(r,s,o){var l=s.pendingProps,d=l.revealOrder,h=l.tail;if(Ft(r,s,l.children,o),l=it.current,(l&2)!==0)l=l&1|2,s.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Mp(r,o,s);else if(r.tag===19)Mp(r,o,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}l&=1}if(qe(it,l),(s.mode&1)===0)s.memoizedState=null;else switch(d){case"forwards":for(o=s.child,d=null;o!==null;)r=o.alternate,r!==null&&Pa(r)===null&&(d=o),o=o.sibling;o=d,o===null?(d=s.child,s.child=null):(d=o.sibling,o.sibling=null),Eu(s,!1,d,o,h);break;case"backwards":for(o=null,d=s.child,s.child=null;d!==null;){if(r=d.alternate,r!==null&&Pa(r)===null){s.child=d;break}r=d.sibling,d.sibling=o,o=d,d=r}Eu(s,!0,o,null,h);break;case"together":Eu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Qa(r,s){(s.mode&1)===0&&r!==null&&(r.alternate=null,s.alternate=null,s.flags|=2)}function hr(r,s,o){if(r!==null&&(s.dependencies=r.dependencies),_s|=s.lanes,(o&s.childLanes)===0)return null;if(r!==null&&s.child!==r.child)throw Error(t(153));if(s.child!==null){for(r=s.child,o=Xr(r,r.pendingProps),s.child=o,o.return=s;r.sibling!==null;)r=r.sibling,o=o.sibling=Xr(r,r.pendingProps),o.return=s;o.sibling=null}return s.child}function $x(r,s,o){switch(s.tag){case 3:jp(s),Zs();break;case 5:Vh(s);break;case 1:Lt(s.type)&&Ca(s);break;case 4:mu(s,s.stateNode.containerInfo);break;case 10:var l=s.type._context,d=s.memoizedProps.value;qe(Ea,l._currentValue),l._currentValue=d;break;case 13:if(l=s.memoizedState,l!==null)return l.dehydrated!==null?(qe(it,it.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?Ip(r,s,o):(qe(it,it.current&1),r=hr(r,s,o),r!==null?r.sibling:null);qe(it,it.current&1);break;case 19:if(l=(o&s.childLanes)!==0,(r.flags&128)!==0){if(l)return Dp(r,s,o);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),qe(it,it.current),l)break;return null;case 22:case 23:return s.lanes=0,Sp(r,s,o)}return hr(r,s,o)}var Cp,Ru,Fp,Op;Cp=function(r,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)r.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Ru=function(){},Fp=function(r,s,o,l){var d=r.memoizedProps;if(d!==l){r=s.stateNode,ws(Vn.current);var h=null;switch(o){case"input":d=or(r,d),l=or(r,l),h=[];break;case"select":d=H({},d,{value:void 0}),l=H({},l,{value:void 0}),h=[];break;case"textarea":d=Ui(r,d),l=Ui(r,l),h=[];break;default:typeof d.onClick!="function"&&typeof l.onClick=="function"&&(r.onclick=Ia)}he(o,l);var y;o=null;for($ in d)if(!l.hasOwnProperty($)&&d.hasOwnProperty($)&&d[$]!=null)if($==="style"){var S=d[$];for(y in S)S.hasOwnProperty(y)&&(o||(o={}),o[y]="")}else $!=="dangerouslySetInnerHTML"&&$!=="children"&&$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(a.hasOwnProperty($)?h||(h=[]):(h=h||[]).push($,null));for($ in l){var j=l[$];if(S=d!=null?d[$]:void 0,l.hasOwnProperty($)&&j!==S&&(j!=null||S!=null))if($==="style")if(S){for(y in S)!S.hasOwnProperty(y)||j&&j.hasOwnProperty(y)||(o||(o={}),o[y]="");for(y in j)j.hasOwnProperty(y)&&S[y]!==j[y]&&(o||(o={}),o[y]=j[y])}else o||(h||(h=[]),h.push($,o)),o=j;else $==="dangerouslySetInnerHTML"?(j=j?j.__html:void 0,S=S?S.__html:void 0,j!=null&&S!==j&&(h=h||[]).push($,j)):$==="children"?typeof j!="string"&&typeof j!="number"||(h=h||[]).push($,""+j):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&(a.hasOwnProperty($)?(j!=null&&$==="onScroll"&&Xe("scroll",r),h||S===j||(h=[])):(h=h||[]).push($,j))}o&&(h=h||[]).push("style",o);var $=h;(s.updateQueue=$)&&(s.flags|=4)}},Op=function(r,s,o,l){o!==l&&(s.flags|=4)};function No(r,s){if(!rt)switch(r.tailMode){case"hidden":s=r.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var l=null;o!==null;)o.alternate!==null&&(l=o),o=o.sibling;l===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:l.sibling=null}}function Mt(r){var s=r.alternate!==null&&r.alternate.child===r.child,o=0,l=0;if(s)for(var d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags&14680064,l|=d.flags&14680064,d.return=r,d=d.sibling;else for(d=r.child;d!==null;)o|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=r,d=d.sibling;return r.subtreeFlags|=l,r.childLanes=o,s}function zx(r,s,o){var l=s.pendingProps;switch(iu(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mt(s),null;case 1:return Lt(s.type)&&Da(),Mt(s),null;case 3:return l=s.stateNode,ni(),et(Rt),et(kt),vu(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Aa(s)?s.flags|=4:r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Nn!==null&&(Qu(Nn),Nn=null))),Ru(r,s),Mt(s),null;case 5:yu(s);var d=ws(xo.current);if(o=s.type,r!==null&&s.stateNode!=null)Fp(r,s,o,l,d),r.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!l){if(s.stateNode===null)throw Error(t(166));return Mt(s),null}if(r=ws(Vn.current),Aa(s)){l=s.stateNode,o=s.type;var h=s.memoizedProps;switch(l[zn]=s,l[po]=h,r=(s.mode&1)!==0,o){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(d=0;d<\/script>",r=r.removeChild(r.firstChild)):typeof l.is=="string"?r=y.createElement(o,{is:l.is}):(r=y.createElement(o),o==="select"&&(y=r,l.multiple?y.multiple=!0:l.size&&(y.size=l.size))):r=y.createElementNS(r,o),r[zn]=s,r[po]=l,Cp(r,s,!1,!1),s.stateNode=r;e:{switch(y=mt(o,l),o){case"dialog":Xe("cancel",r),Xe("close",r),d=l;break;case"iframe":case"object":case"embed":Xe("load",r),d=l;break;case"video":case"audio":for(d=0;doi&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304)}else{if(!l)if(r=Pa(y),r!==null){if(s.flags|=128,l=!0,o=r.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),No(h,!0),h.tail===null&&h.tailMode==="hidden"&&!y.alternate&&!rt)return Mt(s),null}else 2*ct()-h.renderingStartTime>oi&&o!==1073741824&&(s.flags|=128,l=!0,No(h,!1),s.lanes=4194304);h.isBackwards?(y.sibling=s.child,s.child=y):(o=h.last,o!==null?o.sibling=y:s.child=y,h.last=y)}return h.tail!==null?(s=h.tail,h.rendering=s,h.tail=s.sibling,h.renderingStartTime=ct(),s.sibling=null,o=it.current,qe(it,l?o&1|2:o&1),s):(Mt(s),null);case 22:case 23:return Ju(),l=s.memoizedState!==null,r!==null&&r.memoizedState!==null!==l&&(s.flags|=8192),l&&(s.mode&1)!==0?(Zt&1073741824)!==0&&(Mt(s),s.subtreeFlags&6&&(s.flags|=8192)):Mt(s),null;case 24:return null;case 25:return null}throw Error(t(156,s.tag))}function Vx(r,s){switch(iu(s),s.tag){case 1:return Lt(s.type)&&Da(),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return ni(),et(Rt),et(kt),vu(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 5:return yu(s),null;case 13:if(et(it),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(t(340));Zs()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return et(it),null;case 4:return ni(),null;case 10:return du(s.type._context),null;case 22:case 23:return Ju(),null;case 24:return null;default:return null}}var Ka=!1,Dt=!1,Wx=typeof WeakSet=="function"?WeakSet:Set,ae=null;function si(r,s){var o=r.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(l){lt(r,s,l)}else o.current=null}function Lu(r,s,o){try{o()}catch(l){lt(r,s,l)}}var Tp=!1;function Hx(r,s){if(Jc=ma,r=dh(),zc(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var l=o.getSelection&&o.getSelection();if(l&&l.rangeCount!==0){o=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var y=0,S=-1,j=-1,$=0,J=0,Z=r,K=null;t:for(;;){for(var se;Z!==o||d!==0&&Z.nodeType!==3||(S=y+d),Z!==h||l!==0&&Z.nodeType!==3||(j=y+l),Z.nodeType===3&&(y+=Z.nodeValue.length),(se=Z.firstChild)!==null;)K=Z,Z=se;for(;;){if(Z===r)break t;if(K===o&&++$===d&&(S=y),K===h&&++J===l&&(j=y),(se=Z.nextSibling)!==null)break;Z=K,K=Z.parentNode}Z=se}o=S===-1||j===-1?null:{start:S,end:j}}else o=null}o=o||{start:0,end:0}}else o=null;for(qc={focusedElem:r,selectionRange:o},ma=!1,ae=s;ae!==null;)if(s=ae,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,ae=r;else for(;ae!==null;){s=ae;try{var ue=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(ue!==null){var fe=ue.memoizedProps,ut=ue.memoizedState,B=s.stateNode,I=B.getSnapshotBeforeUpdate(s.elementType===s.type?fe:jn(s.type,fe),ut);B.__reactInternalSnapshotBeforeUpdate=I}break;case 3:var L=s.stateNode.containerInfo;L.nodeType===1?L.textContent="":L.nodeType===9&&L.documentElement&&L.removeChild(L.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(ee){lt(s,s.return,ee)}if(r=s.sibling,r!==null){r.return=s.return,ae=r;break}ae=s.return}return ue=Tp,Tp=!1,ue}function jo(r,s,o){var l=s.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&r)===r){var h=d.destroy;d.destroy=void 0,h!==void 0&&Lu(s,o,h)}d=d.next}while(d!==l)}}function Ja(r,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&r)===r){var l=o.create;o.destroy=l()}o=o.next}while(o!==s)}}function Uu(r){var s=r.ref;if(s!==null){var o=r.stateNode;switch(r.tag){case 5:r=o;break;default:r=o}typeof s=="function"?s(r):s.current=r}}function Ap(r){var s=r.alternate;s!==null&&(r.alternate=null,Ap(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&(delete s[zn],delete s[po],delete s[tu],delete s[Ix],delete s[Mx])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Bp(r){return r.tag===5||r.tag===3||r.tag===4}function Ep(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bp(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Pu(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(r,s):o.insertBefore(r,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(r,o)):(s=o,s.appendChild(r)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Ia));else if(l!==4&&(r=r.child,r!==null))for(Pu(r,s,o),r=r.sibling;r!==null;)Pu(r,s,o),r=r.sibling}function $u(r,s,o){var l=r.tag;if(l===5||l===6)r=r.stateNode,s?o.insertBefore(r,s):o.appendChild(r);else if(l!==4&&(r=r.child,r!==null))for($u(r,s,o),r=r.sibling;r!==null;)$u(r,s,o),r=r.sibling}var Nt=null,kn=!1;function Qr(r,s,o){for(o=o.child;o!==null;)Rp(r,s,o),o=o.sibling}function Rp(r,s,o){if($n&&typeof $n.onCommitFiberUnmount=="function")try{$n.onCommitFiberUnmount(ca,o)}catch{}switch(o.tag){case 5:Dt||si(o,s);case 6:var l=Nt,d=kn;Nt=null,Qr(r,s,o),Nt=l,kn=d,Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?r.parentNode.removeChild(o):r.removeChild(o)):Nt.removeChild(o.stateNode));break;case 18:Nt!==null&&(kn?(r=Nt,o=o.stateNode,r.nodeType===8?eu(r.parentNode,o):r.nodeType===1&&eu(r,o),no(r)):eu(Nt,o.stateNode));break;case 4:l=Nt,d=kn,Nt=o.stateNode.containerInfo,kn=!0,Qr(r,s,o),Nt=l,kn=d;break;case 0:case 11:case 14:case 15:if(!Dt&&(l=o.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var h=d,y=h.destroy;h=h.tag,y!==void 0&&((h&2)!==0||(h&4)!==0)&&Lu(o,s,y),d=d.next}while(d!==l)}Qr(r,s,o);break;case 1:if(!Dt&&(si(o,s),l=o.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=o.memoizedProps,l.state=o.memoizedState,l.componentWillUnmount()}catch(S){lt(o,s,S)}Qr(r,s,o);break;case 21:Qr(r,s,o);break;case 22:o.mode&1?(Dt=(l=Dt)||o.memoizedState!==null,Qr(r,s,o),Dt=l):Qr(r,s,o);break;default:Qr(r,s,o)}}function Lp(r){var s=r.updateQueue;if(s!==null){r.updateQueue=null;var o=r.stateNode;o===null&&(o=r.stateNode=new Wx),s.forEach(function(l){var d=eb.bind(null,r,l);o.has(l)||(o.add(l),l.then(d,d))})}}function In(r,s){var o=s.deletions;if(o!==null)for(var l=0;ld&&(d=y),l&=~h}if(l=d,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Yx(l/1960))-l,10r?16:r,Jr===null)var l=!1;else{if(r=Jr,Jr=null,tl=0,($e&6)!==0)throw Error(t(331));var d=$e;for($e|=4,ae=r.current;ae!==null;){var h=ae,y=h.child;if((ae.flags&16)!==0){var S=h.deletions;if(S!==null){for(var j=0;jct()-Wu?js(r,0):Vu|=o),$t(r,s)}function qp(r,s){s===0&&((r.mode&1)===0?s=1:(s=da,da<<=1,(da&130023424)===0&&(da=4194304)));var o=Ot();r=dr(r,s),r!==null&&(qi(r,s,o),$t(r,o))}function Xx(r){var s=r.memoizedState,o=0;s!==null&&(o=s.retryLane),qp(r,o)}function eb(r,s){var o=0;switch(r.tag){case 13:var l=r.stateNode,d=r.memoizedState;d!==null&&(o=d.retryLane);break;case 19:l=r.stateNode;break;default:throw Error(t(314))}l!==null&&l.delete(s),qp(r,o)}var Zp;Zp=function(r,s,o){if(r!==null)if(r.memoizedProps!==s.pendingProps||Rt.current)Ut=!0;else{if((r.lanes&o)===0&&(s.flags&128)===0)return Ut=!1,$x(r,s,o);Ut=(r.flags&131072)!==0}else Ut=!1,rt&&(s.flags&1048576)!==0&&Fh(s,Ta,s.index);switch(s.lanes=0,s.tag){case 2:var l=s.type;Qa(r,s),r=s.pendingProps;var d=Ks(s,kt.current);ti(s,o),d=wu(null,s,l,r,d,o);var h=Su();return s.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Lt(l)?(h=!0,Ca(s)):h=!1,s.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,pu(s),d.updater=Ga,s.stateNode=d,d._reactInternals=s,Mu(s,l,r,o),s=Ou(null,s,l,!0,h,o)):(s.tag=0,rt&&h&&su(s),Ft(null,s,d,o),s=s.child),s;case 16:l=s.elementType;e:{switch(Qa(r,s),r=s.pendingProps,d=l._init,l=d(l._payload),s.type=l,d=s.tag=nb(l),r=jn(l,r),d){case 0:s=Fu(null,s,l,r,o);break e;case 1:s=Np(null,s,l,r,o);break e;case 11:s=xp(null,s,l,r,o);break e;case 14:s=bp(null,s,l,jn(l.type,r),o);break e}throw Error(t(306,l,""))}return s;case 0:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Fu(r,s,l,d,o);case 1:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Np(r,s,l,d,o);case 3:e:{if(jp(s),r===null)throw Error(t(387));l=s.pendingProps,h=s.memoizedState,d=h.element,Ph(r,s),Ua(s,l,null,o);var y=s.memoizedState;if(l=y.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:y.cache,pendingSuspenseBoundaries:y.pendingSuspenseBoundaries,transitions:y.transitions},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){d=ri(Error(t(423)),s),s=kp(r,s,l,o,d);break e}else if(l!==d){d=ri(Error(t(424)),s),s=kp(r,s,l,o,d);break e}else for(qt=zr(s.stateNode.containerInfo.firstChild),Jt=s,rt=!0,Nn=null,o=Lh(s,null,l,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Zs(),l===d){s=hr(r,s,o);break e}Ft(r,s,l,o)}s=s.child}return s;case 5:return Vh(s),r===null&&au(s),l=s.type,d=s.pendingProps,h=r!==null?r.memoizedProps:null,y=d.children,Zc(l,d)?y=null:h!==null&&Zc(l,h)&&(s.flags|=32),_p(r,s),Ft(r,s,y,o),s.child;case 6:return r===null&&au(s),null;case 13:return Ip(r,s,o);case 4:return mu(s,s.stateNode.containerInfo),l=s.pendingProps,r===null?s.child=Xs(s,null,l,o):Ft(r,s,l,o),s.child;case 11:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),xp(r,s,l,d,o);case 7:return Ft(r,s,s.pendingProps,o),s.child;case 8:return Ft(r,s,s.pendingProps.children,o),s.child;case 12:return Ft(r,s,s.pendingProps.children,o),s.child;case 10:e:{if(l=s.type._context,d=s.pendingProps,h=s.memoizedProps,y=d.value,qe(Ea,l._currentValue),l._currentValue=y,h!==null)if(_n(h.value,y)){if(h.children===d.children&&!Rt.current){s=hr(r,s,o);break e}}else for(h=s.child,h!==null&&(h.return=s);h!==null;){var S=h.dependencies;if(S!==null){y=h.child;for(var j=S.firstContext;j!==null;){if(j.context===l){if(h.tag===1){j=fr(-1,o&-o),j.tag=2;var $=h.updateQueue;if($!==null){$=$.shared;var J=$.pending;J===null?j.next=j:(j.next=J.next,J.next=j),$.pending=j}}h.lanes|=o,j=h.alternate,j!==null&&(j.lanes|=o),fu(h.return,o,s),S.lanes|=o;break}j=j.next}}else if(h.tag===10)y=h.type===s.type?null:h.child;else if(h.tag===18){if(y=h.return,y===null)throw Error(t(341));y.lanes|=o,S=y.alternate,S!==null&&(S.lanes|=o),fu(y,o,s),y=h.sibling}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===s){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}Ft(r,s,d.children,o),s=s.child}return s;case 9:return d=s.type,l=s.pendingProps.children,ti(s,o),d=ln(d),l=l(d),s.flags|=1,Ft(r,s,l,o),s.child;case 14:return l=s.type,d=jn(l,s.pendingProps),d=jn(l.type,d),bp(r,s,l,d,o);case 15:return wp(r,s,s.type,s.pendingProps,o);case 17:return l=s.type,d=s.pendingProps,d=s.elementType===l?d:jn(l,d),Qa(r,s),s.tag=1,Lt(l)?(r=!0,Ca(s)):r=!1,ti(s,o),fp(s,l,d),Mu(s,l,d,o),Ou(null,s,l,!0,r,o);case 19:return Dp(r,s,o);case 22:return Sp(r,s,o)}throw Error(t(156,s.tag))};function Xp(r,s){return Of(r,s)}function tb(r,s,o,l){this.tag=r,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(r,s,o,l){return new tb(r,s,o,l)}function Zu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function nb(r){if(typeof r=="function")return Zu(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ne)return 11;if(r===ie)return 14}return 2}function Xr(r,s){var o=r.alternate;return o===null?(o=dn(r.tag,s,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=s,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&14680064,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,s=r.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o}function il(r,s,o,l,d,h){var y=2;if(l=r,typeof r=="function")Zu(r)&&(y=1);else if(typeof r=="string")y=5;else e:switch(r){case R:return Is(o.children,d,h,s);case Y:y=8,d|=8;break;case z:return r=dn(12,o,s,d|2),r.elementType=z,r.lanes=h,r;case X:return r=dn(13,o,s,d),r.elementType=X,r.lanes=h,r;case le:return r=dn(19,o,s,d),r.elementType=le,r.lanes=h,r;case re:return ol(o,d,h,s);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case Q:y=10;break e;case W:y=9;break e;case ne:y=11;break e;case ie:y=14;break e;case ye:y=16,l=null;break e}throw Error(t(130,r==null?r:typeof r,""))}return s=dn(y,o,s,d),s.elementType=r,s.type=l,s.lanes=h,s}function Is(r,s,o,l){return r=dn(7,r,l,s),r.lanes=o,r}function ol(r,s,o,l){return r=dn(22,r,l,s),r.elementType=re,r.lanes=o,r.stateNode={isHidden:!1},r}function Xu(r,s,o){return r=dn(6,r,null,s),r.lanes=o,r}function ed(r,s,o){return s=dn(4,r.children!==null?r.children:[],r.key,s),s.lanes=o,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}function rb(r,s,o,l,d){this.tag=s,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ic(0),this.expirationTimes=Ic(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ic(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function td(r,s,o,l,d,h,y,S,j){return r=new rb(r,s,o,S,j),s===1?(s=1,h===!0&&(s|=8)):s=0,h=dn(3,null,null,s),r.current=h,h.stateNode=r,h.memoizedState={element:l,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},pu(h),r}function sb(r,s,o){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ad.exports=gb(),ad.exports}var hm;function vb(){if(hm)return hl;hm=1;var n=_y();return hl.createRoot=n.createRoot,hl.hydrateRoot=n.hydrateRoot,hl}var xb=vb();function Ho(n){return n.split(".").at(-1)||n}function Tt(n,e){const t=Ho(n);if(e.filter(a=>Ho(a)===t).length<2)return t;const i=n.indexOf(".");return i>0?`${n.slice(0,i)}_${t}`:t}const tr="\0__null__";function bb(n){return String(n||"").replaceAll("_"," ").replaceAll("."," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}function Ny(n,e={}){if(n==null||n==="")return"—";const t=typeof n=="number"?n:Number(n);if(!Number.isFinite(t))return String(n);const i=String(e.format||"").trim().toLowerCase(),a=e.style==="percent"||i.includes("%")||i.includes("percent")||i.includes("pct")||!i&&!e.style&&!e.currency&&e.type==="ratio",c=i.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),f=i.match(/^(?:decimal|percent|usd)_(\d+)$/),p=c?(c[1]||"").length:f?Number(f[1]):void 0,m=e.maximumFractionDigits??(p===void 0?a||e.compact?1:2:Math.min(p,20)),g=p===void 0?void 0:Math.min(c?(c[1]||"").replaceAll("#","").length:p,m);if(a)return(e.style==="percent"?t:Math.abs(t)<=1?t*100:t).toLocaleString(void 0,{maximumFractionDigits:m,minimumFractionDigits:g,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");const v=e.style==="currency"||e.currency||i.includes("$")||i.includes("usd")||i.includes("currency")||i.includes("dollar");return t.toLocaleString(void 0,{currency:v?e.currency||"USD":void 0,maximumFractionDigits:m,minimumFractionDigits:g,notation:e.compact?"compact":"standard",style:v?"currency":"decimal"})}function wb(n,e={}){return Ny(n,{...e,compact:!0})}function Sb(n,e,t){const i=t>0&&n.length>t,a=i?Math.ceil(n.length/t):1,c=Math.max(0,Math.min(e,a-1)),f=i?c*t:0;return{paginate:i,pageCount:a,safePage:c,start:f,visibleRows:i?n.slice(f,f+t):n}}function as(n){return n===tr||n===""?"—":n}function Re(n){return bb(n)}function pt(n,e={}){return Ny(n,e)}function Gt(n,e={}){return wb(n,e)}function jy(n){return!Number.isFinite(n)||n===0?"neutral":n>0?"positive":"negative"}function _b(n,e){return!Number.isFinite(n)||!Number.isFinite(e)||e<=0?{label:"—",tone:"neutral"}:{label:`${(n/e*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`,tone:"neutral"}}function Nb(n,e,t={}){if(e==null||!Number.isFinite(e)||!Number.isFinite(n))return{label:"—",tone:"neutral"};const i=n-e;return{label:`${i>0?"+":i<0?"−":""}${Gt(Math.abs(i),t)}`,tone:jy(i)}}function jb(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return{label:"—",tone:"neutral"};const t=(n-e)/Math.abs(e);return{label:`${(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"})}%`,tone:jy(t)}}function ky(n,e){if(e==null||!Number.isFinite(e)||e===0||!Number.isFinite(n))return null;const t=(n-e)/Math.abs(e),i=(t*100).toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),a=t>0?"positive":t<0?"negative":"neutral";return{label:`${i}%`,tone:a}}function Kn(n,e){return e==="clickhouse"&&(n=n.replaceAll("\\","\\\\")),`'${n.replaceAll("'","''")}'`}function kb(n){if(n.mode==="contains")return`contains ${Kn(n.pattern??"")}`;const{values:e}=n,t=n.mode==="exclude"?"is not":"is";return e.length===0?t:e.length===1?`${t} ${as(e[0])}`:e.length<=2?`${t} ${e.map(as).join(", ")}`:`${t} ${e.length} values`}const ud=n=>n.public!==!1,Iy=/(^|_)(date|time|day|month|week|year|quarter|created|updated|timestamp|_at|_on)($|_)/i;function My(n,e){if(e){const t=n.find(i=>i.name===e);if(t)return t}return n.find(t=>t.type==="time")??n.find(t=>Iy.test(t.name))}function Ib(n,e){var f;const t=new Set;if(!n)return t;const i=new Set(e.map(p=>p.name)),a=n.match(/[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*/g)??[];for(const p of a){const[m]=p.split(".");i.has(m)&&t.add(m)}if(t.size)return t;const c=(f=n.match(/^[A-Za-z_][A-Za-z0-9_]*$/))==null?void 0:f[0];if(!c)return t;for(const p of e)p.metrics.some(m=>m.name===c)&&t.add(p.name);return t}function Dy(n,e){const t=new Set;for(const i of[n.base_metric,n.numerator,n.denominator,n.sql])for(const a of Ib(i,e))t.add(a);return t.size===1?[...t][0]:void 0}function Mb(n){const e=(n.models??[]).map(i=>{const a=(i.dimensions??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,type:p.type||"categorical",granularity:p.granularity,supportedGranularities:p.supported_granularities,format:p.format??p.value_format_name})),c=(i.metrics??[]).filter(ud).map(p=>({ref:`${i.name}.${p.name}`,name:p.name,model:i.name,label:p.label||Re(p.name),description:p.description,agg:p.agg,type:p.type,format:p.format??p.value_format_name})),f=My(a,i.default_time_dimension);return{name:i.name,label:Re(i.name),description:i.description,table:i.table,dimensions:a,metrics:c,timeDimension:f,defaultGrain:i.default_grain||(f==null?void 0:f.granularity)||"day"}}),t=(n.metrics??[]).filter(ud).map(i=>({ref:i.name,name:i.name,ownerModel:Dy(i,e),baseMetric:i.base_metric,label:i.label||Re(i.name),description:i.description,type:i.type,format:i.format??i.value_format_name}));return{models:e,graphMetrics:t,dialect:n.dialect}}function Db(n){const e=n??{},t=(e.models??[]).map(a=>{const c=(a.dimensions??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m),type:Iy.test(m)?"time":"categorical"})),f=(a.metrics??[]).map(m=>({ref:`${a.name}.${m}`,name:m,model:a.name,label:Re(m)})),p=My(c);return{name:a.name,label:Re(a.name),table:a.table,dimensions:c,metrics:f,timeDimension:p,defaultGrain:(p==null?void 0:p.granularity)||"day"}}),i=(e.graph_metrics??[]).map(a=>({ref:a.name,name:a.name,ownerModel:Dy(a,t),baseMetric:a.base_metric,label:Re(a.name),type:a.type,description:a.description}));return{models:t,graphMetrics:i,joinablePairs:e.joinable_pairs??[]}}function Cb(n,e){return{...n,joinablePairs:(e??{}).joinable_pairs??n.joinablePairs??[]}}function ki(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.graphMetrics.filter(i=>i.ownerModel?i.ownerModel===e||t.has(i.ownerModel):!0)}function pc(n,e){const t=new Set;for(const i of n.joinablePairs??[])i.from===e&&t.add(i.to),i.to===e&&t.add(i.from);return n.models.filter(i=>i.name!==e&&t.has(i.name)).flatMap(i=>i.dimensions.map(a=>({...a,label:`${a.label} · ${i.label}`})))}function Te(n,e,t,i){function a(c){return c instanceof t?c:new t(function(f){f(c)})}return new(t||(t=Promise))(function(c,f){function p(v){try{g(i.next(v))}catch(x){f(x)}}function m(v){try{g(i.throw(v))}catch(x){f(x)}}function g(v){v.done?c(v.value):a(v.value).then(p,m)}g((i=i.apply(n,e||[])).next())})}function pm(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(n){return this instanceof Ae?(this.v=n,this):new Ae(n)}function Xn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),a,c=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",f),a[Symbol.asyncIterator]=function(){return this},a;function f(w){return function(_){return Promise.resolve(_).then(w,x)}}function p(w,_){i[w]&&(a[w]=function(C){return new Promise(function(T,P){c.push([w,C,T,P])>1||m(w,C)})},_&&(a[w]=_(a[w])))}function m(w,_){try{g(i[w](_))}catch(C){b(c[0][3],C)}}function g(w){w.value instanceof Ae?Promise.resolve(w.value.v).then(v,x):b(c[0][2],w)}function v(w){m("next",w)}function x(w){m("throw",w)}function b(w,_){w(_),c.shift(),c.length&&m(c[0][0],c[0][1])}}function jl(n){var e,t;return e={},i("next"),i("throw",function(a){throw a}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(a,c){e[a]=n[a]?function(f){return(t=!t)?{value:Ae(n[a](f)),done:!1}:c?c(f):f}:c}}function bi(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof pm=="function"?pm(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(c){t[c]=n[c]&&function(f){return new Promise(function(p,m){f=n[c](f),a(p,m,f.done,f.value)})}}function a(c,f,p,m){Promise.resolve(m).then(function(g){c({value:g,done:p})},f)}}const Fb=new TextDecoder("utf-8"),Md=n=>Fb.decode(n),Ob=new TextEncoder,Wd=n=>Ob.encode(n),Tb=n=>typeof n=="number",Ab=n=>typeof n=="boolean",At=n=>typeof n=="function",En=n=>n!=null&&Object(n)===n,Go=n=>En(n)&&At(n.then),mc=n=>En(n)&&At(n[Symbol.iterator]),Hd=n=>En(n)&&At(n[Symbol.asyncIterator]),Dd=n=>En(n)&&En(n.schema),Cy=n=>En(n)&&"done"in n&&"value"in n,Fy=n=>En(n)&&At(n.stat)&&Tb(n.fd),Oy=n=>En(n)&&Gd(n.body),Ty=n=>"_getDOMStream"in n&&"_getNodeStream"in n,Gd=n=>En(n)&&At(n.cancel)&&At(n.getReader)&&!Ty(n),Ay=n=>En(n)&&At(n.read)&&At(n.pipe)&&Ab(n.readable)&&!Ty(n),Bb=n=>En(n)&&At(n.clear)&&At(n.bytes)&&At(n.position)&&At(n.setPosition)&&At(n.capacity)&&At(n.getBufferIdentifier)&&At(n.createLong),Yd=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Eb(n){const e=n[0]?[n[0]]:[];let t,i,a,c;for(let f,p,m=0,g=0,v=n.length;++mv+x.byteLength,0);let a,c,f,p=0,m=-1;const g=Math.min(e||Number.POSITIVE_INFINITY,i);for(const v=t.length;++mKe(Int32Array,n),ym=n=>Ke(BigInt64Array,n),Pe=n=>Ke(Uint8Array,n),Cd=n=>(n.next(),n);function*Rb(n,e){const t=function*(a){yield a},i=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?t(e):mc(e)?e:t(e);return yield*Cd((function*(a){let c=null;do c=a.next(yield Ke(n,c));while(!c.done)})(i[Symbol.iterator]())),new n}const Lb=n=>Rb(Uint8Array,n);function By(n,e){return Xn(this,arguments,function*(){if(Go(e))return yield Ae(yield Ae(yield*jl(bi(By(n,yield Ae(e))))));const i=function(f){return Xn(this,arguments,function*(){yield yield Ae(yield Ae(f))})},a=function(f){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(Cd((function*(p){let m=null;do m=p.next(yield m==null?void 0:m.value);while(!m.done)})(f[Symbol.iterator]())))))})},c=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Yd?i(e):mc(e)?a(e):Hd(e)?e:i(e);return yield Ae(yield*jl(bi(Cd((function(f){return Xn(this,arguments,function*(){let p=null;do p=yield Ae(f.next(yield yield Ae(Ke(n,p))));while(!p.done)})})(c[Symbol.asyncIterator]()))))),yield Ae(new n)})}const Ub=n=>By(Uint8Array,n);function Pb(n,e){let t=0;const i=n.length;if(i!==e.length)return!1;if(i>0)do if(n[t]!==e[t])return!1;while(++t(n.next(),n);function*$b(n){let e,t=!1,i=[],a,c,f,p=0;function m(){return c==="peek"?nr(i,f)[0]:([a,i,p]=nr(i,f),a)}({cmd:c,size:f}=(yield null)||{cmd:"read",size:0});const g=Lb(n)[Symbol.iterator]();try{do if({done:e,value:a}=Number.isNaN(f-p)?g.next():g.next(f-p),!e&&a.byteLength>0&&(i.push(a),p+=a.byteLength),e||f<=p)do({cmd:c,size:f}=yield m());while(f0&&(a.push(c),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p0&&(a.push(Pe(c)),m+=c.byteLength),t||p<=m)do({cmd:f,size:p}=yield yield Ae(g()));while(p{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return Te(this,void 0,void 0,function*(){const{reader:t,source:i}=this;t&&(yield t.cancel(e).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(e){return Te(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const t=yield this.reader.read();return!t.done&&(t.value=Pe(t)),t})}}const dd=(n,e)=>{const t=a=>i([e,a]);let i;return[e,t,new Promise(a=>(i=a)&&n.once(e,t))]};function Hb(n){return Xn(this,arguments,function*(){const t=[];let i="error",a=!1,c=null,f,p,m=0,g=[],v;function x(){return f==="peek"?nr(g,p)[0]:([v,g,m]=nr(g,p),v)}if({cmd:f,size:p}=(yield yield Ae(null))||{cmd:"read",size:0},n.isTTY)return yield yield Ae(new Uint8Array(0)),yield Ae(null);try{t[0]=dd(n,"end"),t[1]=dd(n,"error");do{if(t[2]=dd(n,"readable"),[i,c]=yield Ae(Promise.race(t.map(w=>w[2]))),i==="error")break;if((a=i==="end")||(Number.isFinite(p-m)?(v=Pe(n.read(p-m)),v.byteLength0&&(g.push(v),m+=v.byteLength)),a||p<=m)do({cmd:f,size:p}=yield yield Ae(x()));while(p{for(const[P,U]of w)n.off(P,U);try{const P=n.destroy;P&&P.call(n,_),_=void 0}catch(P){_=P||_}finally{_!=null?T(_):C()}})}})}var ht;(function(n){n[n.V1=0]="V1",n[n.V2=1]="V2",n[n.V3=2]="V3",n[n.V4=3]="V4",n[n.V5=4]="V5"})(ht||(ht={}));var Yt;(function(n){n[n.Sparse=0]="Sparse",n[n.Dense=1]="Dense"})(Yt||(Yt={}));var Ct;(function(n){n[n.HALF=0]="HALF",n[n.SINGLE=1]="SINGLE",n[n.DOUBLE=2]="DOUBLE"})(Ct||(Ct={}));var bn;(function(n){n[n.DAY=0]="DAY",n[n.MILLISECOND=1]="MILLISECOND"})(bn||(bn={}));var _e;(function(n){n[n.SECOND=0]="SECOND",n[n.MILLISECOND=1]="MILLISECOND",n[n.MICROSECOND=2]="MICROSECOND",n[n.NANOSECOND=3]="NANOSECOND"})(_e||(_e={}));var rr;(function(n){n[n.YEAR_MONTH=0]="YEAR_MONTH",n[n.DAY_TIME=1]="DAY_TIME",n[n.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(rr||(rr={}));const fd=2,Jn=4,wr=4,He=4,ss=new Int32Array(2),gm=new Float32Array(ss.buffer),vm=new Float64Array(ss.buffer),ml=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Fd;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Fd||(Fd={}));let Ii=class Ey{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new Ey(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){gm[0]=t,this.writeInt32(e,ss[0])}writeFloat64(e,t){vm[0]=t,this.writeInt32(e,ss[ml?0:1]),this.writeInt32(e+4,ss[ml?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space=0&&this.vtable[t]==0;t--);const i=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const a=2;this.addInt16(e-this.object_start);const c=(i+a)*fd;this.addInt16(c);let f=0;const p=this.space;e:for(t=0;t=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,Jn+a),this.addOffset(e),a&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const i=this.bb.capacity()-e,a=i-this.bb.readInt32(i);if(!(t=0;i--)e.addInt32(t[i]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(e,t,i){return Ht.startUnion(e),Ht.addMode(e,t),Ht.addTypeIds(e,i),Ht.endUnion(e)}}let jm=class $o{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(e,t){return(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,t){return e.setPosition(e.position()+He),(t||new $o).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return $o.startUtf8(e),$o.endUtf8(e)}};var Ze;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.FloatingPoint=3]="FloatingPoint",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct_=13]="Struct_",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.LargeList=21]="LargeList",n[n.RunEndEncoded=22]="RunEndEncoded"})(Ze||(Ze={}));let pn=class Fl{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(e,t){return(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,t){return e.setPosition(e.position()+He),(t||new Fl).__init(e.readInt32(e.position())+e.position(),e)}name(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):Ze.NONE}type(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Sr).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(e,t){const i=this.bb.__offset(this.bb_pos,14);return i?(t||new Fl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,16);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,Ze.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},Yn=class yr{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(e,t){return(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,t){return e.setPosition(e.position()+He),(t||new yr).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Mi.Little}fields(e,t){const i=this.bb.__offset(this.bb_pos,6);return i?(t||new pn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Mi.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let i=t.length-1;i>=0;i--)e.addInt64(t[i]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(e,t,i,a,c){return yr.startSchema(e),yr.addEndianness(e,t),yr.addFields(e,i),yr.addCustomMetadata(e,a),yr.addFeatures(e,c),yr.endSchema(e)}};var Ve;(function(n){n[n.NONE=0]="NONE",n[n.Schema=1]="Schema",n[n.DictionaryBatch=2]="DictionaryBatch",n[n.RecordBatch=3]="RecordBatch",n[n.Tensor=4]="Tensor",n[n.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var D;(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Duration=18]="Duration",n[n.LargeBinary=19]="LargeBinary",n[n.LargeUtf8=20]="LargeUtf8",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth",n[n.DurationSecond=-27]="DurationSecond",n[n.DurationMillisecond=-28]="DurationMillisecond",n[n.DurationMicrosecond=-29]="DurationMicrosecond",n[n.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var vr;(function(n){n[n.OFFSET=0]="OFFSET",n[n.DATA=1]="DATA",n[n.VALIDITY=2]="VALIDITY",n[n.TYPE=3]="TYPE"})(vr||(vr={}));const Gb=void 0;function Yo(n){if(n===null)return"null";if(n===Gb)return"undefined";switch(typeof n){case"number":return`${n}`;case"bigint":return`${n}`;case"string":return`"${n}"`}return typeof n[Symbol.toPrimitive]=="function"?n[Symbol.toPrimitive]("string"):ArrayBuffer.isView(n)?n instanceof BigInt64Array||n instanceof BigUint64Array?`[${[...n].map(e=>Yo(e))}]`:`[${n}]`:ArrayBuffer.isView(n)?`[${n}]`:JSON.stringify(n,(e,t)=>typeof t=="bigint"?`${t}`:t)}function tt(n){if(typeof n=="bigint"&&(nNumber.MAX_SAFE_INTEGER))throw new TypeError(`${n} is not safe to convert to a number.`);return Number(n)}function $y(n,e){return tt(n/e)+tt(n%e)/tt(e)}const Yb=Symbol.for("isArrowBigNum");function Ln(n,...e){return e.length===0?Object.setPrototypeOf(Ke(this.TypedArray,n),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(n,...e),this.constructor.prototype)}Ln.prototype[Yb]=!0;Ln.prototype.toJSON=function(){return`"${Ko(this)}"`};Ln.prototype.valueOf=function(n){return zy(this,n)};Ln.prototype.toString=function(){return Ko(this)};Ln.prototype[Symbol.toPrimitive]=function(n="default"){switch(n){case"number":return zy(this);case"string":return Ko(this);case"default":return Jb(this)}return Ko(this)};function wi(...n){return Ln.apply(this,n)}function Si(...n){return Ln.apply(this,n)}function Qo(...n){return Ln.apply(this,n)}Object.setPrototypeOf(wi.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Si.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Qo.prototype,Object.create(Uint32Array.prototype));Object.assign(wi.prototype,Ln.prototype,{constructor:wi,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Si.prototype,Ln.prototype,{constructor:Si,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Qo.prototype,Ln.prototype,{constructor:Qo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Qb=BigInt(4294967296)*BigInt(4294967296),Kb=Qb-BigInt(1);function zy(n,e){const{buffer:t,byteOffset:i,byteLength:a,signed:c}=n,f=new BigUint64Array(t,i,a/8),p=c&&f.at(-1)&BigInt(1)<=0)return hd(n);e=e.slice();let i=1;for(let c=0;c(n.children=null,n.ArrayType=Array,n.OffsetArrayType=Int32Array,n[Symbol.toStringTag]="DataType"))(me.prototype);class ls extends me{constructor(){super(D.Null)}toString(){return"Null"}}Wy=Symbol.toStringTag;ls[Wy]=(n=>n[Symbol.toStringTag]="Null")(ls.prototype);class Os extends me{constructor(e,t){super(D.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Hy=Symbol.toStringTag;Os[Hy]=(n=>(n.isSigned=null,n.bitWidth=null,n[Symbol.toStringTag]="Int"))(Os.prototype);class Jo extends Os{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Jo.prototype,"ArrayType",{value:Int32Array});class Ll extends me{constructor(e){super(D.Float),this.precision=e}get ArrayType(){switch(this.precision){case Ct.HALF:return Uint16Array;case Ct.SINGLE:return Float32Array;case Ct.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Gy=Symbol.toStringTag;Ll[Gy]=(n=>(n.precision=null,n[Symbol.toStringTag]="Float"))(Ll.prototype);class Ul extends me{constructor(){super(D.Binary)}toString(){return"Binary"}}Yy=Symbol.toStringTag;Ul[Yy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Binary"))(Ul.prototype);class Pl extends me{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}Qy=Symbol.toStringTag;Pl[Qy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeBinary"))(Pl.prototype);class $l extends me{constructor(){super(D.Utf8)}toString(){return"Utf8"}}Ky=Symbol.toStringTag;$l[Ky]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Utf8"))($l.prototype);class zl extends me{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}Jy=Symbol.toStringTag;zl[Jy]=(n=>(n.ArrayType=Uint8Array,n.OffsetArrayType=BigInt64Array,n[Symbol.toStringTag]="LargeUtf8"))(zl.prototype);class Vl extends me{constructor(){super(D.Bool)}toString(){return"Bool"}}qy=Symbol.toStringTag;Vl[qy]=(n=>(n.ArrayType=Uint8Array,n[Symbol.toStringTag]="Bool"))(Vl.prototype);class Wl extends me{constructor(e,t,i=128){super(D.Decimal),this.scale=e,this.precision=t,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Zy=Symbol.toStringTag;Wl[Zy]=(n=>(n.scale=null,n.precision=null,n.ArrayType=Uint32Array,n[Symbol.toStringTag]="Decimal"))(Wl.prototype);class Hl extends me{constructor(e){super(D.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${bn[this.unit]}>`}get ArrayType(){return this.unit===bn.DAY?Int32Array:BigInt64Array}}Xy=Symbol.toStringTag;Hl[Xy]=(n=>(n.unit=null,n[Symbol.toStringTag]="Date"))(Hl.prototype);class Gl extends me{constructor(e,t){super(D.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${_e[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}eg=Symbol.toStringTag;Gl[eg]=(n=>(n.unit=null,n.bitWidth=null,n[Symbol.toStringTag]="Time"))(Gl.prototype);class Yl extends me{constructor(e,t){super(D.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${_e[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}tg=Symbol.toStringTag;Yl[tg]=(n=>(n.unit=null,n.timezone=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Timestamp"))(Yl.prototype);class Ql extends me{constructor(e){super(D.Interval),this.unit=e}toString(){return`Interval<${rr[this.unit]}>`}}ng=Symbol.toStringTag;Ql[ng]=(n=>(n.unit=null,n.ArrayType=Int32Array,n[Symbol.toStringTag]="Interval"))(Ql.prototype);class Kl extends me{constructor(e){super(D.Duration),this.unit=e}toString(){return`Duration<${_e[this.unit]}>`}}rg=Symbol.toStringTag;Kl[rg]=(n=>(n.unit=null,n.ArrayType=BigInt64Array,n[Symbol.toStringTag]="Duration"))(Kl.prototype);class Jl extends me{constructor(e){super(D.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}sg=Symbol.toStringTag;Jl[sg]=(n=>(n.children=null,n[Symbol.toStringTag]="List"))(Jl.prototype);class Bt extends me{constructor(e){super(D.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}ig=Symbol.toStringTag;Bt[ig]=(n=>(n.children=null,n[Symbol.toStringTag]="Struct"))(Bt.prototype);class ql extends me{constructor(e,t,i){super(D.Union),this.mode=e,this.children=i,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((a,c,f)=>(a[c]=f)&&a||a,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}og=Symbol.toStringTag;ql[og]=(n=>(n.mode=null,n.typeIds=null,n.children=null,n.typeIdToChildIndex=null,n.ArrayType=Int8Array,n[Symbol.toStringTag]="Union"))(ql.prototype);class Zl extends me{constructor(e){super(D.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}ag=Symbol.toStringTag;Zl[ag]=(n=>(n.byteWidth=null,n.ArrayType=Uint8Array,n[Symbol.toStringTag]="FixedSizeBinary"))(Zl.prototype);class Xl extends me{constructor(e,t){super(D.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}lg=Symbol.toStringTag;Xl[lg]=(n=>(n.children=null,n.listSize=null,n[Symbol.toStringTag]="FixedSizeList"))(Xl.prototype);class ec extends me{constructor(e,t=!1){var i,a,c;if(super(D.Map),this.children=[e],this.keysSorted=t,e&&(e.name="entries",!((i=e==null?void 0:e.type)===null||i===void 0)&&i.children)){const f=(a=e==null?void 0:e.type)===null||a===void 0?void 0:a.children[0];f&&(f.name="key");const p=(c=e==null?void 0:e.type)===null||c===void 0?void 0:c.children[1];p&&(p.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}cg=Symbol.toStringTag;ec[cg]=(n=>(n.children=null,n.keysSorted=null,n[Symbol.toStringTag]="Map_"))(ec.prototype);const qb=(n=>()=>++n)(-1);class Di extends me{constructor(e,t,i,a){super(D.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=a||!1,this.id=i==null?qb():tt(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}ug=Symbol.toStringTag;Di[ug]=(n=>(n.id=null,n.indices=null,n.isOrdered=null,n.dictionary=null,n[Symbol.toStringTag]="Dictionary"))(Di.prototype);function xr(n){const e=n;switch(n.typeId){case D.Decimal:return n.bitWidth/32;case D.Interval:return 1+e.unit;case D.FixedSizeList:return e.listSize;case D.FixedSizeBinary:return e.byteWidth;default:return 1}}class Le{visitMany(e,...t){return e.map((i,a)=>this.visit(i,...t.map(c=>c[a])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Zb(this,e,t)}getVisitFnByTypeId(e,t=!0){return yi(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}}function Zb(n,e,t=!0){return typeof e=="number"?yi(n,e,t):typeof e=="string"&&e in D?yi(n,D[e],t):e&&e instanceof me?yi(n,km(e),t):e!=null&&e.type&&e.type instanceof me?yi(n,km(e.type),t):yi(n,D.NONE,t)}function yi(n,e,t=!0){let i=null;switch(e){case D.Null:i=n.visitNull;break;case D.Bool:i=n.visitBool;break;case D.Int:i=n.visitInt;break;case D.Int8:i=n.visitInt8||n.visitInt;break;case D.Int16:i=n.visitInt16||n.visitInt;break;case D.Int32:i=n.visitInt32||n.visitInt;break;case D.Int64:i=n.visitInt64||n.visitInt;break;case D.Uint8:i=n.visitUint8||n.visitInt;break;case D.Uint16:i=n.visitUint16||n.visitInt;break;case D.Uint32:i=n.visitUint32||n.visitInt;break;case D.Uint64:i=n.visitUint64||n.visitInt;break;case D.Float:i=n.visitFloat;break;case D.Float16:i=n.visitFloat16||n.visitFloat;break;case D.Float32:i=n.visitFloat32||n.visitFloat;break;case D.Float64:i=n.visitFloat64||n.visitFloat;break;case D.Utf8:i=n.visitUtf8;break;case D.LargeUtf8:i=n.visitLargeUtf8;break;case D.Binary:i=n.visitBinary;break;case D.LargeBinary:i=n.visitLargeBinary;break;case D.FixedSizeBinary:i=n.visitFixedSizeBinary;break;case D.Date:i=n.visitDate;break;case D.DateDay:i=n.visitDateDay||n.visitDate;break;case D.DateMillisecond:i=n.visitDateMillisecond||n.visitDate;break;case D.Timestamp:i=n.visitTimestamp;break;case D.TimestampSecond:i=n.visitTimestampSecond||n.visitTimestamp;break;case D.TimestampMillisecond:i=n.visitTimestampMillisecond||n.visitTimestamp;break;case D.TimestampMicrosecond:i=n.visitTimestampMicrosecond||n.visitTimestamp;break;case D.TimestampNanosecond:i=n.visitTimestampNanosecond||n.visitTimestamp;break;case D.Time:i=n.visitTime;break;case D.TimeSecond:i=n.visitTimeSecond||n.visitTime;break;case D.TimeMillisecond:i=n.visitTimeMillisecond||n.visitTime;break;case D.TimeMicrosecond:i=n.visitTimeMicrosecond||n.visitTime;break;case D.TimeNanosecond:i=n.visitTimeNanosecond||n.visitTime;break;case D.Decimal:i=n.visitDecimal;break;case D.List:i=n.visitList;break;case D.Struct:i=n.visitStruct;break;case D.Union:i=n.visitUnion;break;case D.DenseUnion:i=n.visitDenseUnion||n.visitUnion;break;case D.SparseUnion:i=n.visitSparseUnion||n.visitUnion;break;case D.Dictionary:i=n.visitDictionary;break;case D.Interval:i=n.visitInterval;break;case D.IntervalDayTime:i=n.visitIntervalDayTime||n.visitInterval;break;case D.IntervalYearMonth:i=n.visitIntervalYearMonth||n.visitInterval;break;case D.Duration:i=n.visitDuration;break;case D.DurationSecond:i=n.visitDurationSecond||n.visitDuration;break;case D.DurationMillisecond:i=n.visitDurationMillisecond||n.visitDuration;break;case D.DurationMicrosecond:i=n.visitDurationMicrosecond||n.visitDuration;break;case D.DurationNanosecond:i=n.visitDurationNanosecond||n.visitDuration;break;case D.FixedSizeList:i=n.visitFixedSizeList;break;case D.Map:i=n.visitMap;break}if(typeof i=="function")return i;if(!t)return()=>null;throw new Error(`Unrecognized type '${D[e]}'`)}function km(n){switch(n.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:e,isSigned:t}=n;switch(e){case 8:return t?D.Int8:D.Uint8;case 16:return t?D.Int16:D.Uint16;case 32:return t?D.Int32:D.Uint32;case 64:return t?D.Int64:D.Uint64}return D.Int}case D.Float:switch(n.precision){case Ct.HALF:return D.Float16;case Ct.SINGLE:return D.Float32;case Ct.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(n.unit){case _e.SECOND:return D.TimeSecond;case _e.MILLISECOND:return D.TimeMillisecond;case _e.MICROSECOND:return D.TimeMicrosecond;case _e.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(n.unit){case _e.SECOND:return D.TimestampSecond;case _e.MILLISECOND:return D.TimestampMillisecond;case _e.MICROSECOND:return D.TimestampMicrosecond;case _e.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(n.unit){case bn.DAY:return D.DateDay;case bn.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(n.unit){case rr.DAY_TIME:return D.IntervalDayTime;case rr.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(n.unit){case _e.SECOND:return D.DurationSecond;case _e.MILLISECOND:return D.DurationMillisecond;case _e.MICROSECOND:return D.DurationMicrosecond;case _e.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(n.mode){case Yt.Dense:return D.DenseUnion;case Yt.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[n.typeId]}'`)}Le.prototype.visitInt8=null;Le.prototype.visitInt16=null;Le.prototype.visitInt32=null;Le.prototype.visitInt64=null;Le.prototype.visitUint8=null;Le.prototype.visitUint16=null;Le.prototype.visitUint32=null;Le.prototype.visitUint64=null;Le.prototype.visitFloat16=null;Le.prototype.visitFloat32=null;Le.prototype.visitFloat64=null;Le.prototype.visitDateDay=null;Le.prototype.visitDateMillisecond=null;Le.prototype.visitTimestampSecond=null;Le.prototype.visitTimestampMillisecond=null;Le.prototype.visitTimestampMicrosecond=null;Le.prototype.visitTimestampNanosecond=null;Le.prototype.visitTimeSecond=null;Le.prototype.visitTimeMillisecond=null;Le.prototype.visitTimeMicrosecond=null;Le.prototype.visitTimeNanosecond=null;Le.prototype.visitDenseUnion=null;Le.prototype.visitSparseUnion=null;Le.prototype.visitIntervalDayTime=null;Le.prototype.visitIntervalYearMonth=null;Le.prototype.visitDuration=null;Le.prototype.visitDurationSecond=null;Le.prototype.visitDurationMillisecond=null;Le.prototype.visitDurationMicrosecond=null;Le.prototype.visitDurationNanosecond=null;const dg=new Float64Array(1),li=new Uint32Array(dg.buffer);function fg(n){const e=(n&31744)>>10,t=(n&1023)/1024,i=Math.pow(-1,(n&32768)>>15);switch(e){case 31:return i*(t?Number.NaN:1/0);case 0:return i*(t?6103515625e-14*t:0)}return i*Math.pow(2,e-15)*(1+t)}function Xb(n){if(n!==n)return 32256;dg[0]=n;const e=(li[1]&2147483648)>>16&65535;let t=li[1]&2146435072,i=0;return t>=1089470464?li[0]>0?t=31744:(t=(t&2080374784)>>16,i=(li[1]&1048575)>>10):t<=1056964608?(i=1048576+(li[1]&1048575),i=1048576+(i<<(t>>20)-998)>>21,t=0):(t=t-1056964608>>10,i=(li[1]&1048575)+512>>10),e|t|i&65535}class Ne extends Le{}function De(n){return(e,t,i)=>{if(e.setValid(t,i!=null))return n(e,t,i)}}const ew=(n,e,t)=>{n[e]=Math.floor(t/864e5)},hg=(n,e,t,i)=>{if(t+1{const a=n+t;i?e[a>>3]|=1<>3]&=~(1<{n[e]=t},Kd=({values:n},e,t)=>{n[e]=t},pg=({values:n},e,t)=>{n[e]=Xb(t)},nw=(n,e,t)=>{switch(n.type.precision){case Ct.HALF:return pg(n,e,t);case Ct.SINGLE:case Ct.DOUBLE:return Kd(n,e,t)}},mg=({values:n},e,t)=>{ew(n,e,t.valueOf())},yg=({values:n},e,t)=>{n[e]=BigInt(t)},rw=({stride:n,values:e},t,i)=>{e.set(i.subarray(0,n),n*t)},gg=({values:n,valueOffsets:e},t,i)=>hg(n,e,t,i),vg=({values:n,valueOffsets:e},t,i)=>hg(n,e,t,Wd(i)),sw=(n,e,t)=>{n.type.unit===bn.DAY?mg(n,e,t):yg(n,e,t)},xg=({values:n},e,t)=>{n[e]=BigInt(t/1e3)},bg=({values:n},e,t)=>{n[e]=BigInt(t)},wg=({values:n},e,t)=>{n[e]=BigInt(t*1e3)},Sg=({values:n},e,t)=>{n[e]=BigInt(t*1e6)},iw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return xg(n,e,t);case _e.MILLISECOND:return bg(n,e,t);case _e.MICROSECOND:return wg(n,e,t);case _e.NANOSECOND:return Sg(n,e,t)}},_g=({values:n},e,t)=>{n[e]=t},Ng=({values:n},e,t)=>{n[e]=t},jg=({values:n},e,t)=>{n[e]=t},kg=({values:n},e,t)=>{n[e]=t},ow=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return _g(n,e,t);case _e.MILLISECOND:return Ng(n,e,t);case _e.MICROSECOND:return jg(n,e,t);case _e.NANOSECOND:return kg(n,e,t)}},aw=({values:n,stride:e},t,i)=>{n.set(i.subarray(0,e),e*t)},lw=(n,e,t)=>{const i=n.children[0],a=n.valueOffsets,c=wn.getVisitFn(i);if(Array.isArray(t))for(let f=-1,p=a[e],m=a[e+1];p{const i=n.children[0],{valueOffsets:a}=n,c=wn.getVisitFn(i);let{[e]:f,[e+1]:p}=a;const m=t instanceof Map?t.entries():Object.entries(t);for(const g of m)if(c(i,f,g),++f>=p)break},uw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[c]),dw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(c)),fw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e.get(a.name)),hw=(n,e)=>(t,i,a,c)=>i&&t(i,n,e[a.name]),pw=(n,e,t)=>{const i=n.type.children.map(c=>wn.getVisitFn(c.type)),a=t instanceof Map?fw(e,t):t instanceof Je?dw(e,t):Array.isArray(t)?uw(e,t):hw(e,t);n.type.children.forEach((c,f)=>a(i[f],n.children[f],c,f))},mw=(n,e,t)=>{n.type.mode===Yt.Dense?Ig(n,e,t):Mg(n,e,t)},Ig=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,n.valueOffsets[e],t)},Mg=(n,e,t)=>{const i=n.type.typeIdToChildIndex[n.typeIds[e]],a=n.children[i];wn.visit(a,e,t)},yw=(n,e,t)=>{var i;(i=n.dictionary)===null||i===void 0||i.set(n.values[e],t)},gw=(n,e,t)=>{n.type.unit===rr.DAY_TIME?Dg(n,e,t):Cg(n,e,t)},Dg=({values:n},e,t)=>{n.set(t.subarray(0,2),2*e)},Cg=({values:n},e,t)=>{n[e]=t[0]*12+t[1]%12},Fg=({values:n},e,t)=>{n[e]=t},Og=({values:n},e,t)=>{n[e]=t},Tg=({values:n},e,t)=>{n[e]=t},Ag=({values:n},e,t)=>{n[e]=t},vw=(n,e,t)=>{switch(n.type.unit){case _e.SECOND:return Fg(n,e,t);case _e.MILLISECOND:return Og(n,e,t);case _e.MICROSECOND:return Tg(n,e,t);case _e.NANOSECOND:return Ag(n,e,t)}},xw=(n,e,t)=>{const{stride:i}=n,a=n.children[0],c=wn.getVisitFn(a);if(Array.isArray(t))for(let f=-1,p=e*i;++f`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new bw(this[On],this[_i])}}class bw{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return et.name)}has(e,t){return e[On].type.children.findIndex(i=>i.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[On].type.children.findIndex(i=>i.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[On].type.children.findIndex(a=>a.name===t);if(i!==-1){const a=Qt.visit(e[On].children[i],e[_i]);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[On].type.children.findIndex(c=>c.name===t);return a!==-1?(wn.visit(e[On].children[a],e[_i],i),Reflect.set(e,t,i)):Reflect.has(e,t)||typeof t=="symbol"?Reflect.set(e,t,i):!1}}class xe extends Le{}function je(n){return(e,t)=>e.getValid(t)?n(e,t):null}const Sw=(n,e)=>864e5*n[e],_w=(n,e)=>null,Bg=(n,e,t)=>{if(t+1>=e.length)return null;const i=tt(e[t]),a=tt(e[t+1]);return n.subarray(i,a)},Nw=({offset:n,values:e},t)=>{const i=n+t;return(e[i>>3]&1<Sw(n,e),Rg=({values:n},e)=>tt(n[e]),ds=({stride:n,values:e},t)=>e[n*t],jw=({stride:n,values:e},t)=>fg(e[n*t]),Lg=({values:n},e)=>n[e],kw=({stride:n,values:e},t)=>e.subarray(n*t,n*(t+1)),Ug=({values:n,valueOffsets:e},t)=>Bg(n,e,t),Pg=({values:n,valueOffsets:e},t)=>{const i=Bg(n,e,t);return i!==null?Md(i):null},Iw=({values:n},e)=>n[e],Mw=({type:n,values:e},t)=>n.precision!==Ct.HALF?e[t]:fg(e[t]),Dw=(n,e)=>n.type.unit===bn.DAY?Eg(n,e):Rg(n,e),$g=({values:n},e)=>1e3*tt(n[e]),zg=({values:n},e)=>tt(n[e]),Vg=({values:n},e)=>$y(n[e],BigInt(1e3)),Wg=({values:n},e)=>$y(n[e],BigInt(1e6)),Cw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return $g(n,e);case _e.MILLISECOND:return zg(n,e);case _e.MICROSECOND:return Vg(n,e);case _e.NANOSECOND:return Wg(n,e)}},Hg=({values:n},e)=>n[e],Gg=({values:n},e)=>n[e],Yg=({values:n},e)=>n[e],Qg=({values:n},e)=>n[e],Fw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Hg(n,e);case _e.MILLISECOND:return Gg(n,e);case _e.MICROSECOND:return Yg(n,e);case _e.NANOSECOND:return Qg(n,e)}},Ow=({values:n,stride:e},t)=>Qd.decimal(n.subarray(e*t,e*(t+1))),Tw=(n,e)=>{const{valueOffsets:t,stride:i,children:a}=n,{[e*i]:c,[e*i+1]:f}=t,m=a[0].slice(c,f-c);return new Je([m])},Aw=(n,e)=>{const{valueOffsets:t,children:i}=n,{[e]:a,[e+1]:c}=t,f=i[0];return new qd(f.slice(a,c-a))},Bw=(n,e)=>new Jd(n,e),Ew=(n,e)=>n.type.mode===Yt.Dense?Kg(n,e):Jg(n,e),Kg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,n.valueOffsets[e])},Jg=(n,e)=>{const t=n.type.typeIdToChildIndex[n.typeIds[e]],i=n.children[t];return Qt.visit(i,e)},Rw=(n,e)=>{var t;return(t=n.dictionary)===null||t===void 0?void 0:t.get(n.values[e])},Lw=(n,e)=>n.type.unit===rr.DAY_TIME?qg(n,e):Zg(n,e),qg=({values:n},e)=>n.subarray(2*e,2*(e+1)),Zg=({values:n},e)=>{const t=n[e],i=new Int32Array(2);return i[0]=Math.trunc(t/12),i[1]=Math.trunc(t%12),i},Xg=({values:n},e)=>n[e],ev=({values:n},e)=>n[e],tv=({values:n},e)=>n[e],nv=({values:n},e)=>n[e],Uw=(n,e)=>{switch(n.type.unit){case _e.SECOND:return Xg(n,e);case _e.MILLISECOND:return ev(n,e);case _e.MICROSECOND:return tv(n,e);case _e.NANOSECOND:return nv(n,e)}},Pw=(n,e)=>{const{stride:t,children:i}=n,c=i[0].slice(e*t,t);return new Je([c])};xe.prototype.visitNull=je(_w);xe.prototype.visitBool=je(Nw);xe.prototype.visitInt=je(Iw);xe.prototype.visitInt8=je(ds);xe.prototype.visitInt16=je(ds);xe.prototype.visitInt32=je(ds);xe.prototype.visitInt64=je(Lg);xe.prototype.visitUint8=je(ds);xe.prototype.visitUint16=je(ds);xe.prototype.visitUint32=je(ds);xe.prototype.visitUint64=je(Lg);xe.prototype.visitFloat=je(Mw);xe.prototype.visitFloat16=je(jw);xe.prototype.visitFloat32=je(ds);xe.prototype.visitFloat64=je(ds);xe.prototype.visitUtf8=je(Pg);xe.prototype.visitLargeUtf8=je(Pg);xe.prototype.visitBinary=je(Ug);xe.prototype.visitLargeBinary=je(Ug);xe.prototype.visitFixedSizeBinary=je(kw);xe.prototype.visitDate=je(Dw);xe.prototype.visitDateDay=je(Eg);xe.prototype.visitDateMillisecond=je(Rg);xe.prototype.visitTimestamp=je(Cw);xe.prototype.visitTimestampSecond=je($g);xe.prototype.visitTimestampMillisecond=je(zg);xe.prototype.visitTimestampMicrosecond=je(Vg);xe.prototype.visitTimestampNanosecond=je(Wg);xe.prototype.visitTime=je(Fw);xe.prototype.visitTimeSecond=je(Hg);xe.prototype.visitTimeMillisecond=je(Gg);xe.prototype.visitTimeMicrosecond=je(Yg);xe.prototype.visitTimeNanosecond=je(Qg);xe.prototype.visitDecimal=je(Ow);xe.prototype.visitList=je(Tw);xe.prototype.visitStruct=je(Bw);xe.prototype.visitUnion=je(Ew);xe.prototype.visitDenseUnion=je(Kg);xe.prototype.visitSparseUnion=je(Jg);xe.prototype.visitDictionary=je(Rw);xe.prototype.visitInterval=je(Lw);xe.prototype.visitIntervalDayTime=je(qg);xe.prototype.visitIntervalYearMonth=je(Zg);xe.prototype.visitDuration=je(Uw);xe.prototype.visitDurationSecond=je(Xg);xe.prototype.visitDurationMillisecond=je(ev);xe.prototype.visitDurationMicrosecond=je(tv);xe.prototype.visitDurationNanosecond=je(nv);xe.prototype.visitFixedSizeList=je(Pw);xe.prototype.visitMap=je(Aw);const Qt=new xe,gi=Symbol.for("keys"),Ni=Symbol.for("vals"),vi=Symbol.for("kKeysAsStrings"),Ad=Symbol.for("_kKeysAsStrings");class qd{constructor(e){return this[gi]=new Je([e.children[0]]).memoize(),this[Ni]=e.children[1],new Proxy(this,new zw)}get[vi](){return this[Ad]||(this[Ad]=Array.from(this[gi].toArray(),String))}[Symbol.iterator](){return new $w(this[gi],this[Ni])}get size(){return this[gi].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[gi],t=this[Ni],i={};for(let a=-1,c=e.length;++a`${Yo(e)}: ${Yo(t)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class $w{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Qt.visit(this.vals,e)]})}}class zw{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[vi]}has(e,t){return e[vi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[vi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];const i=e[vi].indexOf(t);if(i!==-1){const a=Qt.visit(Reflect.get(e,Ni),i);return Reflect.set(e,t,a),a}}set(e,t,i){const a=e[vi].indexOf(t);return a!==-1?(wn.visit(Reflect.get(e,Ni),a,i),Reflect.set(e,t,i)):Reflect.has(e,t)?Reflect.set(e,t,i):!1}}Object.defineProperties(qd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ni]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ad]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Im;function rv(n,e,t,i){const{length:a=0}=n;let c=typeof e!="number"?0:e,f=typeof t!="number"?a:t;return c<0&&(c=(c%a+a)%a),f<0&&(f=(f%a+a)%a),fa&&(f=a),i?i(n,c,f):[c,f]}const Zd=(n,e)=>n<0?e+n:n,Mm=n=>n!==n;function Bi(n){if(typeof n!=="object"||n===null)return Mm(n)?Mm:t=>t===n;if(n instanceof Date){const t=n.valueOf();return i=>i instanceof Date?i.valueOf()===t:!1}return ArrayBuffer.isView(n)?t=>t?Pb(n,t):!1:n instanceof Map?Ww(n):Array.isArray(n)?Vw(n):n instanceof Je?Hw(n):Gw(n,!0)}function Vw(n){const e=[];for(let t=-1,i=n.length;++t!1;const i=[];for(let a=-1,c=t.length;++a{if(!t||typeof t!="object")return!1;switch(t.constructor){case Array:return Yw(n,t);case Map:return Dm(n,t,t.keys());case qd:case Jd:case Object:case void 0:return Dm(n,t,e||Object.keys(t))}return t instanceof Je?Qw(n,t):!1}}function Yw(n,e){const t=n.length;if(e.length!==t)return!1;for(let i=-1;++i>i}function Cm(n,e,t){const i=t.byteLength+7&-8;if(n>0||t.byteLength>3):Bd(new Xd(t,n,e,null,sv)).subarray(0,i)),a}return t}function Bd(n){const e=[];let t=0,i=0,a=0;for(const f of n)f&&(a|=1<0)&&(e[t++]=a);const c=new Uint8Array(e.length+7&-8);return c.set(e),c}class Xd{constructor(e,t,i,a,c){this.bytes=e,this.length=i,this.context=a,this.get=c,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,a=e+(e%8===0?0:8-e%8);return Ed(n,e,a)+Ed(n,i,t)+Jw(n,a>>3,i-a>>3)}function Jw(n,e,t){let i=0,a=Math.trunc(e);const c=new DataView(n.buffer,n.byteOffset,n.byteLength),f=t===void 0?n.byteLength:a+t;for(;f-a>=4;)i+=pd(c.getUint32(a)),a+=4;for(;f-a>=2;)i+=pd(c.getUint16(a)),a+=2;for(;f-a>=1;)i+=pd(c.getUint8(a)),a+=1;return i}function pd(n){let e=Math.trunc(n);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const qw=-1;class Ye{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:e}=this;return me.isSparseUnion(e)?this.children.some(t=>t.nullable):me.isDenseUnion(e)?this.children.some(t=>t.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0;const{valueOffsets:t,values:i,nullBitmap:a,typeIds:c}=this;return t&&(e+=t.byteLength),i&&(e+=i.byteLength),a&&(e+=a.byteLength),c&&(e+=c.byteLength),this.children.reduce((f,p)=>f+p.byteLength,e)}get nullCount(){if(me.isUnion(this.type))return this.children.reduce((i,a)=>i+a.nullCount,0);let e=this._nullCount,t;return e<=qw&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Ed(t,this.offset,this.offset+this.length)),e}constructor(e,t,i,a,c,f=[],p){this.type=e,this.children=f,this.dictionary=p,this.offset=Math.floor(Math.max(t||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(a||0,-1));let m;c instanceof Ye?(this.stride=c.stride,this.values=c.values,this.typeIds=c.typeIds,this.nullBitmap=c.nullBitmap,this.valueOffsets=c.valueOffsets):(this.stride=xr(e),c&&((m=c[0])&&(this.valueOffsets=m),(m=c[1])&&(this.values=m),(m=c[2])&&(this.nullBitmap=m),(m=c[3])&&(this.typeIds=m)))}getValid(e){const{type:t}=this;if(me.isUnion(t)){const i=t,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],c=i.mode===Yt.Dense?this.valueOffsets[e]:e;return a.getValid(c)}if(this.nullable&&this.nullCount>0){const i=this.offset+e;return(this.nullBitmap[i>>3]&1<>3;(!c||c.byteLength<=v)&&(c=new Uint8Array((f+p+63&-64)>>3).fill(255),this.nullCount>0?(c.set(Cm(f,p,this.nullBitmap),0),Object.assign(this,{nullBitmap:c})):Object.assign(this,{nullBitmap:c,_nullCount:0}));const x=c[v];i=(x&g)!==0,c[v]=t?x|g:x&~g}return i!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(e=this.type,t=this.offset,i=this.length,a=this._nullCount,c=this,f=this.children){return new Ye(e,t,i,a,c,f,this.dictionary)}slice(e,t){const{stride:i,typeId:a,children:c}=this,f=+(this._nullCount===0)-1,p=a===16?i:1,m=this._sliceBuffers(e,t,i,a);return this.clone(this.type,this.offset+e,t,f,m,c.length===0||this.valueOffsets?c:this._sliceChildren(c,p*e,p*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===D.Null)return this.clone(this.type,0,e,0);const{length:t,nullCount:i}=this,a=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);a[t>>3]=(1<0&&a.set(Cm(this.offset,t,this.nullBitmap),0);const c=this.buffers;return c[vr.VALIDITY]=a,this.clone(this.type,0,e,i+(e-t),c)}_sliceBuffers(e,t,i,a){let c;const{buffers:f}=this;return(c=f[vr.TYPE])&&(f[vr.TYPE]=c.subarray(e,e+t)),(c=f[vr.OFFSET])&&(f[vr.OFFSET]=c.subarray(e,e+t+1))||(c=f[vr.DATA])&&(f[vr.DATA]=a===6?c:c.subarray(i*e,i*(e+t))),f}_sliceChildren(e,t,i){return e.map(a=>a.slice(t,i))}}Ye.prototype.children=Object.freeze([]);class Vo extends Le{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:t,["offset"]:i=0,["length"]:a=0}=e;return new Ye(t,i,a,a)}visitBool(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length>>3,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitInt(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFloat(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeUtf8(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitLargeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.data),c=Pe(e.nullBitmap),f=ym(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,a,c])}visitFixedSizeBinary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDate(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTimestamp(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitTime(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDecimal(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitList(e){const{["type"]:t,["offset"]:i=0,["child"]:a}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}visitStruct(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Pe(e.nullBitmap),{length:f=a.reduce((m,{length:g})=>Math.max(m,g),0),nullCount:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],a)}visitUnion(e){const{["type"]:t,["offset"]:i=0,["children"]:a=[]}=e,c=Ke(t.ArrayType,e.typeIds),{["length"]:f=c.length,["nullCount"]:p=-1}=e;if(me.isSparseUnion(t))return new Ye(t,i,f,p,[void 0,void 0,void 0,c],a);const m=Fo(e.valueOffsets);return new Ye(t,i,f,p,[m,void 0,void 0,c],a)}visitDictionary(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.indices.ArrayType,e.data),{["dictionary"]:f=new Je([new Vo().visit({type:t.dictionary})])}=e,{["length"]:p=c.length,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[void 0,c,a],[],f)}visitInterval(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitDuration(e){const{["type"]:t,["offset"]:i=0}=e,a=Pe(e.nullBitmap),c=Ke(t.ArrayType,e.data),{["length"]:f=c.length,["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,c,a])}visitFixedSizeList(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.valueType})}=e,c=Pe(e.nullBitmap),{["length"]:f=a.length/xr(t),["nullCount"]:p=e.nullBitmap?-1:0}=e;return new Ye(t,i,f,p,[void 0,void 0,c],[a])}visitMap(e){const{["type"]:t,["offset"]:i=0,["child"]:a=new Vo().visit({type:t.childType})}=e,c=Pe(e.nullBitmap),f=Fo(e.valueOffsets),{["length"]:p=f.length-1,["nullCount"]:m=e.nullBitmap?-1:0}=e;return new Ye(t,i,p,m,[f,void 0,c],[a])}}const Zw=new Vo;function Ee(n){return Zw.visit(n)}class Fm{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function iv(n){return n.reduce((e,t)=>e+t.nullCount,0)}function ov(n){return n.reduce((e,t,i)=>(e[i+1]=e[i]+t.length,e),new Uint32Array(n.length+1))}function av(n,e,t,i){const a=[];for(let c=-1,f=n.length;++c=i)break;if(t>=m+g)continue;if(m>=t&&m+g<=i){a.push(p);continue}const v=Math.max(0,t-m),x=Math.min(i-m,g);a.push(p.slice(v,x-v))}return a.length===0&&a.push(n[0].slice(0,0)),a}function ef(n,e,t,i){let a=0,c=0,f=e.length-1;do{if(a>=f-1)return t0?0:-1}function t1(n,e){const{nullBitmap:t}=n;if(!t||n.nullCount<=0)return-1;let i=0;for(const a of new Xd(t,n.offset+(e||0),n.length,t,sv)){if(!a)return i;++i}return-1}function Fe(n,e,t){if(e===void 0)return-1;if(e===null)switch(n.typeId){case D.Union:break;case D.Dictionary:break;default:return t1(n,t)}const i=Qt.getVisitFn(n),a=Bi(e);for(let c=(t||0)-1,f=n.length;++c{const a=n.data[i];return a.values.subarray(0,a.length)[Symbol.iterator]()});let t=0;return new Fm(n.data.length,i=>{const c=n.data[i].length,f=n.slice(t,t+c);return t+=c,new n1(f)})}class n1{constructor(e){this.vector=e,this.index=0}next(){return this.indexp.data):e;if(c.length===0||c.some(p=>!(p instanceof Ye)))throw new TypeError("Vector constructor expects an Array of Data instances.");const f=(t=c[0])===null||t===void 0?void 0:t.type;switch(c.length){case 0:this._offsets=[0];break;case 1:{const{get:p,set:m,indexOf:g}=fv[f.typeId],v=c[0];this.isValid=x=>tf(v,x),this.get=x=>p(v,x),this.set=(x,b)=>m(v,x,b),this.indexOf=x=>g(v,x),this._offsets=[0,v.length];break}default:Object.setPrototypeOf(this,hv[f.typeId]),this._offsets=ov(c);break}this.data=c,this.type=f,this.stride=xr(f),this.numChildren=(a=(i=f.children)===null||i===void 0?void 0:i.length)!==null&&a!==void 0?a:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Xw(this.data)}get nullCount(){return iv(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return nf.visit(this)}concat(...e){return new Je(this.data.concat(e.flatMap(t=>t.data).flat(Number.POSITIVE_INFINITY)))}slice(e,t){return new Je(rv(this,e,t,({data:i,_offsets:a},c,f)=>av(i,a,c,f)))}toJSON(){return[...this]}toArray(){const{type:e,data:t,length:i,stride:a,ArrayType:c}=this;switch(e.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(t.length){case 0:return new c;case 1:return t[0].values.subarray(0,i*a);default:return t.reduce((f,{values:p,length:m})=>(f.array.set(p.subarray(0,m*a),f.offset),f.offset+=m*a,f),{array:new c(i*a),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&et[e])):null}get isMemoized(){return me.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(me.isDictionary(this.type)){const e=new rc(this.data[0].dictionary),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return new rc(this)}unmemoize(){if(me.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),t=this.data.map(i=>{const a=i.clone();return a.dictionary=e,a});return new Je(t)}return this}}dv=Symbol.toStringTag;Je[dv]=(n=>{n.type=me.prototype,n.data=[],n.length=0,n.stride=1,n.numChildren=0,n._offsets=new Uint32Array([0]),n[Symbol.isConcatSpreadable]=!0;const e=Object.keys(D).map(t=>D[t]).filter(t=>typeof t=="number"&&t!==D.NONE);for(const t of e){const i=Qt.getVisitFnByTypeId(t),a=wn.getVisitFnByTypeId(t),c=nc.getVisitFnByTypeId(t);fv[t]={get:i,set:a,indexOf:c},hv[t]=Object.create(n,{isValid:{value:tc(tf)},get:{value:tc(Qt.getVisitFnByTypeId(t))},set:{value:lv(wn.getVisitFnByTypeId(t))},indexOf:{value:cv(nc.getVisitFnByTypeId(t))}})}return"Vector"})(Je.prototype);class rc extends Je{constructor(e){super(e.data);const t=this.get,i=this.set,a=this.slice,c=new Array(this.length);Object.defineProperty(this,"get",{value(f){const p=c[f];if(p!==void 0)return p;const m=t.call(this,f);return c[f]=m,m}}),Object.defineProperty(this,"set",{value(f,p){i.call(this,f,p),c[f]=p}}),Object.defineProperty(this,"slice",{value:(f,p)=>new rc(a.call(this,f,p))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Je(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Rd{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,i,a){return e.prep(8,24),e.writeInt64(BigInt(a??0)),e.pad(4),e.writeInt32(i),e.writeInt64(BigInt(t??0)),e.offset()}}class tn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(e,t){return(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,t){return e.setPosition(e.position()+He),(t||new tn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}schema(e){const t=this.bb.__offset(this.bb_pos,6);return t?(e||new Yn).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){const i=this.bb.__offset(this.bb_pos,8);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){const i=this.bb.__offset(this.bb_pos,10);return i?(t||new Rd).__init(this.bb.__vector(this.bb_pos+i)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}}class We{constructor(e=[],t,i,a=ht.V5){this.fields=e||[],this.metadata=t||new Map,i||(i=Ld(this.fields)),this.dictionaries=i,this.metadataVersion=a}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(", ")} }>`}select(e){const t=new Set(e),i=this.fields.filter(a=>t.has(a.name));return new We(i,this.metadata)}selectAt(e){const t=e.map(i=>this.fields[i]).filter(Boolean);return new We(t,this.metadata)}assign(...e){const t=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),i=[...this.fields],a=yl(yl(new Map,this.metadata),t.metadata),c=t.fields.filter(p=>{const m=i.findIndex(g=>g.name===p.name);return~m?(i[m]=p.clone({metadata:yl(yl(new Map,i[m].metadata),p.metadata)}))&&!1:!0}),f=Ld(c,new Map);return new We([...i,...c],a,new Map([...this.dictionaries,...f]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class nt{static new(...e){let[t,i,a,c]=e;return e[0]&&typeof e[0]=="object"&&({name:t}=e[0],i===void 0&&(i=e[0].type),a===void 0&&(a=e[0].nullable),c===void 0&&(c=e[0].metadata)),new nt(`${t}`,i,a,c)}constructor(e,t,i=!1,a){this.name=e,this.type=t,this.nullable=i,this.metadata=a||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[t,i,a,c]=e;return!e[0]||typeof e[0]!="object"?[t=this.name,i=this.type,a=this.nullable,c=this.metadata]=e:{name:t=this.name,type:i=this.type,nullable:a=this.nullable,metadata:c=this.metadata}=e[0],nt.new(t,i,a,c)}}nt.prototype.type=null;nt.prototype.name=null;nt.prototype.nullable=null;nt.prototype.metadata=null;function yl(n,e){return new Map([...n||new Map,...e||new Map])}function Ld(n,e=new Map){for(let t=-1,i=n.length;++t0&&Ld(c.children,e)}return e}var r1=Ry,s1=Ii;class rf{static decode(e){e=new s1(Pe(e));const t=tn.getRootAsFooter(e),i=We.decode(t.schema(),new Map,t.version());return new i1(i,t)}static encode(e){const t=new r1,i=We.encode(t,e.schema);tn.startRecordBatchesVector(t,e.numRecordBatches);for(const f of[...e.recordBatches()].slice().reverse())Ci.encode(t,f);const a=t.endVector();tn.startDictionariesVector(t,e.numDictionaries);for(const f of[...e.dictionaryBatches()].slice().reverse())Ci.encode(t,f);const c=t.endVector();return tn.startFooter(t),tn.addSchema(t,i),tn.addVersion(t,ht.V5),tn.addRecordBatches(t,a),tn.addDictionaries(t,c),tn.finishFooterBuffer(t,tn.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=ht.V5,i,a){this.schema=e,this.version=t,i&&(this._recordBatches=i),a&&(this._dictionaryBatches=a)}*recordBatches(){for(let e,t=-1,i=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(at);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return mn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return mn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return Te(this,void 0,void 0,function*(){return yield this.abort(e),at})}return(e){return Te(this,void 0,void 0,function*(){return yield this.close(),at})}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((t,i)=>{this.resolvers.push({resolve:t,reject:i})}):Promise.resolve(at)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class a1 extends o1{write(e){if((e=Pe(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?Md(this.toUint8Array(!0)):this.toUint8Array(!1).then(Md)}toUint8Array(e=!1){return e?nr(this._values)[0]:Te(this,void 0,void 0,function*(){var t,i,a,c;const f=[];let p=0;try{for(var m=!0,g=bi(this),v;v=yield g.next(),t=v.done,!t;m=!0){c=v.value,m=!1;const x=c;f.push(x),p+=x.byteLength}}catch(x){i={error:x}}finally{try{!m&&!t&&(a=g.return)&&(yield a.call(g))}finally{if(i)throw i.error}}return nr(f,p)[0]})}}class sc{constructor(e){e&&(this.source=new l1(mn.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Fi{constructor(e){e instanceof Fi?this.source=e.source:e instanceof a1?this.source=new Ms(mn.fromAsyncIterable(e)):Ay(e)?this.source=new Ms(mn.fromNodeStream(e)):Gd(e)?this.source=new Ms(mn.fromDOMStream(e)):Oy(e)?this.source=new Ms(mn.fromDOMStream(e.body)):mc(e)?this.source=new Ms(mn.fromIterable(e)):Go(e)?this.source=new Ms(mn.fromAsyncIterable(e)):Hd(e)&&(this.source=new Ms(mn.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class l1{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,t="read"){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||at)}return(e){return Object.create(this.source.return&&this.source.return(e)||at)}}class Ms{constructor(e){this.source=e,this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}cancel(e){return Te(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return Te(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return Te(this,arguments,void 0,function*(t,i="read"){return yield this.source.next({cmd:i,size:t})})}throw(e){return Te(this,void 0,void 0,function*(){const t=this.source.throw&&(yield this.source.throw(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return Te(this,void 0,void 0,function*(){const t=this.source.return&&(yield this.source.return(e))||at;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}}class Tm extends sc{constructor(e,t){super(),this.position=0,this.buffer=Pe(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){const{buffer:t,byteOffset:i}=this.readAt(e,4);return new DataView(t,i).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let a=t[3]*i[3];this.buffer[0]=a&65535;let c=a>>>16;return a=t[2]*i[3],c+=a,a=t[3]*i[2]>>>0,c+=a,this.buffer[0]+=c<<16,this.buffer[1]=c>>>0>>16,this.buffer[1]+=t[1]*i[3]+t[2]*i[2]+t[3]*i[1],this.buffer[1]+=t[0]*i[3]+t[1]*i[2]+t[2]*i[1]+t[3]*i[0]<<16,this}_plus(e){const t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${xi(this.buffer[3])} ${xi(this.buffer[2])} ${xi(this.buffer[1])} ${xi(this.buffer[0])}`}static multiply(e,t){return new Qn(new Uint32Array(e.buffer)).times(t)}static add(e,t){return new Qn(new Uint32Array(e.buffer)).plus(t)}static from(e,t=new Uint32Array(4)){return Qn.fromString(typeof e=="string"?e:e.toString(),t)}static fromNumber(e,t=new Uint32Array(4)){return Qn.fromString(e.toString(),t)}static fromString(e,t=new Uint32Array(4)){const i=e.startsWith("-"),a=e.length,c=new Qn(t);for(let f=i?1:0;f0&&this.readData(e,i)||new Uint8Array(0)}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+t)}readDictionary(e){return this.dictionaries.get(e.id)}}class u1 extends yv{constructor(e,t,i,a,c){super(new Uint8Array(0),t,i,a,c),this.sources=e}readNullBitmap(e,t,{offset:i}=this.nextBufferRange()){return t<=0?new Uint8Array(0):Bd(this.sources[i])}readOffsets(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return Ke(Uint8Array,Ke(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){const{sources:i}=this;return me.isTimestamp(e)||(me.isInt(e)||me.isTime(e))&&e.bitWidth===64||me.isDuration(e)||me.isDate(e)&&e.unit===bn.MILLISECOND?Ke(Uint8Array,Wt.convertArray(i[t])):me.isDecimal(e)?Ke(Uint8Array,Qn.convertArray(i[t])):me.isBinary(e)||me.isLargeBinary(e)||me.isFixedSizeBinary(e)?d1(i[t]):me.isBool(e)?Bd(i[t]):me.isUtf8(e)||me.isLargeUtf8(e)?Wd(i[t].join("")):Ke(Uint8Array,Ke(e.ArrayType,i[t].map(a=>+a)))}}function d1(n){const e=n.join(""),t=new Uint8Array(e.length/2);for(let i=0;i>1]=Number.parseInt(e.slice(i,i+2),16);return t}class Se extends Le{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,a)=>this.compareFields(i,t[a]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}}function Et(n,e){return e instanceof n.constructor}function Rs(n,e){return n===e||Et(n,e)}function Mr(n,e){return n===e||Et(n,e)&&n.bitWidth===e.bitWidth&&n.isSigned===e.isSigned}function gc(n,e){return n===e||Et(n,e)&&n.precision===e.precision}function f1(n,e){return n===e||Et(n,e)&&n.byteWidth===e.byteWidth}function of(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function Xo(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.timezone===e.timezone}function ea(n,e){return n===e||Et(n,e)&&n.unit===e.unit&&n.bitWidth===e.bitWidth}function h1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function p1(n,e){return n===e||Et(n,e)&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function af(n,e){return n===e||Et(n,e)&&n.mode===e.mode&&n.typeIds.every((t,i)=>t===e.typeIds[i])&&cs.compareManyFields(n.children,e.children)}function m1(n,e){return n===e||Et(n,e)&&n.id===e.id&&n.isOrdered===e.isOrdered&&cs.visit(n.indices,e.indices)&&cs.visit(n.dictionary,e.dictionary)}function lf(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function ta(n,e){return n===e||Et(n,e)&&n.unit===e.unit}function y1(n,e){return n===e||Et(n,e)&&n.listSize===e.listSize&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}function g1(n,e){return n===e||Et(n,e)&&n.keysSorted===e.keysSorted&&n.children.length===e.children.length&&cs.compareManyFields(n.children,e.children)}Se.prototype.visitNull=Rs;Se.prototype.visitBool=Rs;Se.prototype.visitInt=Mr;Se.prototype.visitInt8=Mr;Se.prototype.visitInt16=Mr;Se.prototype.visitInt32=Mr;Se.prototype.visitInt64=Mr;Se.prototype.visitUint8=Mr;Se.prototype.visitUint16=Mr;Se.prototype.visitUint32=Mr;Se.prototype.visitUint64=Mr;Se.prototype.visitFloat=gc;Se.prototype.visitFloat16=gc;Se.prototype.visitFloat32=gc;Se.prototype.visitFloat64=gc;Se.prototype.visitUtf8=Rs;Se.prototype.visitLargeUtf8=Rs;Se.prototype.visitBinary=Rs;Se.prototype.visitLargeBinary=Rs;Se.prototype.visitFixedSizeBinary=f1;Se.prototype.visitDate=of;Se.prototype.visitDateDay=of;Se.prototype.visitDateMillisecond=of;Se.prototype.visitTimestamp=Xo;Se.prototype.visitTimestampSecond=Xo;Se.prototype.visitTimestampMillisecond=Xo;Se.prototype.visitTimestampMicrosecond=Xo;Se.prototype.visitTimestampNanosecond=Xo;Se.prototype.visitTime=ea;Se.prototype.visitTimeSecond=ea;Se.prototype.visitTimeMillisecond=ea;Se.prototype.visitTimeMicrosecond=ea;Se.prototype.visitTimeNanosecond=ea;Se.prototype.visitDecimal=Rs;Se.prototype.visitList=h1;Se.prototype.visitStruct=p1;Se.prototype.visitUnion=af;Se.prototype.visitDenseUnion=af;Se.prototype.visitSparseUnion=af;Se.prototype.visitDictionary=m1;Se.prototype.visitInterval=lf;Se.prototype.visitIntervalDayTime=lf;Se.prototype.visitIntervalYearMonth=lf;Se.prototype.visitDuration=ta;Se.prototype.visitDurationSecond=ta;Se.prototype.visitDurationMillisecond=ta;Se.prototype.visitDurationMicrosecond=ta;Se.prototype.visitDurationNanosecond=ta;Se.prototype.visitFixedSizeList=y1;Se.prototype.visitMap=g1;const cs=new Se;function v1(n,e){return cs.compareSchemas(n,e)}function md(n,e){return x1(n,e.map(t=>t.data.concat()))}function x1(n,e){const t=[...n.fields],i=[],a={numBatches:e.reduce((x,b)=>Math.max(x,b.length),0)};let c=0,f=0,p=-1;const m=e.length;let g,v=[];for(;a.numBatches-- >0;){for(f=Number.POSITIVE_INFINITY,p=-1;++p0&&(i[c++]=Ee({type:new Bt(t),length:f,nullCount:0,children:v.slice()})))}return[n=n.assign(t),i.map(x=>new Tn(n,x))]}function b1(n,e,t,i,a){var c;const f=(e+63&-64)>>3;for(let p=-1,m=i.length;++p=e)v===e?t[p]=g:(t[p]=g.slice(0,e),a.numBatches=Math.max(a.numBatches,i[p].unshift(g.slice(e,v-e))));else{const x=n[p];n[p]=x.clone({nullable:!0}),t[p]=(c=g==null?void 0:g._changeLengthAndBackfillNullBitmap(e))!==null&&c!==void 0?c:Ee({type:x.type,length:e,nullCount:e,nullBitmap:new Uint8Array(f)})}}return t}var gv;class vn{constructor(...e){var t,i;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let a,c;e[0]instanceof We&&(a=e.shift()),e.at(-1)instanceof Uint32Array&&(c=e.pop());const f=m=>{if(m){if(m instanceof Tn)return[m];if(m instanceof vn)return m.batches;if(m instanceof Ye){if(m.type instanceof Bt)return[new Tn(new We(m.type.children),m)]}else{if(Array.isArray(m))return m.flatMap(g=>f(g));if(typeof m[Symbol.iterator]=="function")return[...m].flatMap(g=>f(g));if(typeof m=="object"){const g=Object.keys(m),v=g.map(w=>new Je([m[w]])),x=a??new We(g.map((w,_)=>new nt(String(w),v[_].type,v[_].nullable))),[,b]=md(x,v);return b.length===0?[new Tn(m)]:b}}}return[]},p=e.flatMap(m=>f(m));if(a=(i=a??((t=p[0])===null||t===void 0?void 0:t.schema))!==null&&i!==void 0?i:new We([]),!(a instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const m of p){if(!(m instanceof Tn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!v1(a,m.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=a,this.batches=p,this._offsets=c??ov(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=iv(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Zd(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?nf.visit(new Je(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=nv({length:this.numRows},e,t);const a=ov(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Be({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}yv=Symbol.toStringTag;vn[yv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=av(wn.getVisitFn(D.Struct)),n.indexOf=lv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var gv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Be({nullCount:0,type:new Et(this.schema.fields),children:this.schema.fields.map(t=>Be({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Be({type:new Et(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=vv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Be({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Be({type:new Et(t.fields),length:this.numRows,children:i});return new zo(t,a)}};gv=Symbol.toStringTag;Tn[gv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Be({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Be({type:new Et(a),length:t,children:c})]}function vv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cBe({type:a.type})),i=Be({type:new Et(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class b1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new b1;function w1(n,e=new Map){return new We(_1(n,e),Ol(n.metadata),e)}function bv(n){return new Rn(n.count,wv(n.columns),Sv(n.columns))}function S1(n){return new kr(bv(n.data),n.id,n.isDelta)}function _1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Em(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function wv(n){return(n||[]).reduce((e,t)=>[...e,new Bi(t.count,N1(t.VALIDITY)),...wv(t.children)],[])}function Sv(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function j1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Em(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Bm(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Bm(i):new Jo,e.set(t,f=Rm(n,Em(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Bm(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Et(e||[]);case"struct_":return new Et(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var k1=By,I1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=M1(e,t),i}static decode(e){e=new I1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=D1(t,c),f}static encode(e){const t=new k1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Bi{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function M1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=P1;nt.decode=L1;nt.fromJSON=j1;We.encode=U1;We.decode=C1;We.fromJSON=w1;Rn.encode=$1;Rn.decode=F1;Rn.fromJSON=bv;kr.encode=z1;kr.decode=O1;kr.fromJSON=S1;Bi.encode=V1;Bi.decode=A1;_r.encode=W1;_r.decode=T1;function C1(n,e=new Map,t=ht.V5){const i=R1(n,e);return new We(i,Tl(n),e,t)}function F1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),B1(n,e))}function O1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function T1(n){return new _r(n.offset(),n.length())}function A1(n){return new Bi(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,H1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function P1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function $1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Bi.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function z1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function V1(n,e){return Uy.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function W1(n,e){return Ly.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const H1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,_v=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,Nv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class jv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?Z1(e):Cy(e)?tS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Fy(e)||Gd(e)||Ty(e)||Hd(e)?eS(new Fi(e)):X1(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Dy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Iv extends ac{constructor(e){super(e),this._impl=e}}class K1 extends lc{constructor(e){super(e),this._impl=e}}class Mv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Be({type:new Et(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new mv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Mv{constructor(e,t){super(t),this._reader=Dd(e)?new Y1(this._handle=e):new jv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Mv{constructor(e,t){super(t),this._reader=new G1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Cv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Dv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-kv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-kv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Iv(new Dv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function eS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Iv(new Dv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function tS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=Q1&&df(yield t.readAt(0,na+7&-8))?new K1(new J1(t)):new lc(new uc(t))})}function Fv(n){const e=jr.from(n);return Go(e)?e.then(t=>Fv(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function nS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function rS(n){const e=Fv(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const iS="application/vnd.apache.arrow.stream";class oS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function aS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class lS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new oS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return aS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Ib(await t.json());try{return Db(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Mb(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?sS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:iS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=rS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Ov({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),$=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",$),()=>T.removeEventListener("change",$)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,$=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var B,F;return(F=(B=w.current)==null?void 0:B.querySelector("button"))==null?void 0:F.focus()});function U(B){var L;if(B.key==="Escape"){B.preventDefault(),x(!1);return}if(B.key!=="Tab")return;const F=(L=w.current)==null?void 0:L.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];B.shiftKey&&document.activeElement===A?(B.preventDefault(),M.focus()):!B.shiftKey&&document.activeElement===M&&(B.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=$,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{className:"relative z-30 flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function cS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}const uS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function dS(n,e){const t=n.split("__").at(-1);return t&&uS.has(t)?t:e}function fS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function hS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,L,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(V=>V.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(V=>{var X;return(X=n.graphMetrics.find(ne=>ne.ref===V))==null?void 0:X.ownerModel}).find(V=>!!V),m=((F=f.find(V=>V.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(V=>V.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(V=>V.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(V=>V.metrics),...ki(n,g.name)],x=f.map(V=>v.find(X=>X.ref===V)).filter(V=>!!V),b=c.map(V=>vl(n,V)).filter((V,X,ne)=>!!V&&ne.findIndex(ae=>(ae==null?void 0:ae.ref)===(V==null?void 0:V.ref))===X),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(V=>x.some(X=>X.ref===V))??((L=x[0])==null?void 0:L.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,$=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(V=>{var X;return((X=vl(n,V))==null?void 0:X.type)==="time"}),U=g.defaultGrain??"month",B=$?vl(n,$):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:B,selectedMetric:C,grain:$?dS($,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:hS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??fS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function pS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function mS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function yS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=mS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function gS(n){return{from:Vm(n.from),to:Vm(n.to)}}function vS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Tv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function xS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function bS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function wS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Av(n,e,t){const i=Kn(`%${wS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function SS(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Ev(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Av(a,c.pattern??"",e.dialect));continue}const p=SS(a,c,f,e.dialect);p&&t.push(p)}return t}function Es(n,e={}){const t=Ev(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...xS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const _S={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:_S[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function NS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function jS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function kS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function IS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function MS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=IS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function DS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Bv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Rv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??DS(n),c=(i==null?void 0:i.selectedMetric)??Bv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function CS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const FS=["home","explore","pivot"],OS=new Set(Pd),TS=new Set(["none","pctTotal","delta","deltaPct"]),AS=new Set(["off","previous","year","custom"]),ES="none",BS="previous",RS="UTC";function LS(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const US=new Set(["include","exclude","contains"]);function PS(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!US.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function $S(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=PS(i);a&&(e[t]=a)}return e}function zS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function VS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==RS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==BS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(zS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function WS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&FS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&OS.has(m)&&(i.grain=m);const g=t.get("tz");LS(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Tv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&TS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&AS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),$=t.get("cto");i.comparison==="custom"&&wl(T)&&wl($)&&Date.parse(T)<=Date.parse($)&&(i.comparisonRange={from:T,to:$});const U=$S(bl(t.get("filters")));U&&(i.filters=U);const B=bl(t.get("jdims"));Wo(B)&&(i.joinedDims=[...new Set(B)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Lv=k.createContext(null);function Qm(n){const e=VS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=WS(n,i),c=Ts(e,t,a.dashboardTab);return c?CS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function HS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Rv(n,t),[n,t]),[p,m]=k.useReducer(MS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Lv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Lv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function Uv(){for(const n of Cs.listeners)n()}function GS(){Cs.active+=1,Uv()}function YS(){Cs.active=Math.max(0,Cs.active-1),Uv()}function Pv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const QS=80;function En(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{GS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>YS())},QS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function $v(n,e=!0){k.useLayoutEffect(()=>{const t=n.current,i=t==null?void 0:t.parentElement;if(!e||!t||!i)return;function a(){if(!t||!i)return;const f=i.getBoundingClientRect(),p=8,m=Math.max(p,Math.min(f.left,window.innerWidth-t.offsetWidth-p));t.style.left=`${m-f.left}px`,t.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-f.bottom-p-4)}px`)}a();const c=new ResizeObserver(a);return c.observe(t),c.observe(i),i.parentElement&&c.observe(i.parentElement),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{c.disconnect(),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}})}const KS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],JS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function zv({dim:n,model:e,onClose:t}){var N,W;const{state:i,dispatch:a,backend:c,catalog:f,dashboard:p}=Dr(),m=k.useMemo(()=>Ts(f,p,i.dashboardTab),[f,p,i.dashboardTab]),g=i.filters[n.ref],[v,x]=k.useState((g==null?void 0:g.mode)??"include"),b=k.useMemo(()=>new Set((g==null?void 0:g.mode)!=="contains"?(g==null?void 0:g.values)??[]:[]),[g]),w=k.useRef(null);$v(w);const _=k.useRef(null),C=k.useId(),[T,$]=k.useState(""),U=Zm(T,qm),B=(g==null?void 0:g.mode)==="contains"?g.pattern??"":"",[F,A]=k.useState(B),M=Zm(F,qm);k.useEffect(()=>{var oe;const J=document.activeElement;return(oe=_.current)==null||oe.focus(),()=>{var te;return(te=J==null?void 0:J.focus)==null?void 0:te.call(J)}},[]),k.useEffect(()=>{function J(te){te.key==="Escape"&&(te.stopPropagation(),t())}function oe(te){w.current&&!w.current.contains(te.target)&&t()}return document.addEventListener("keydown",J,!0),document.addEventListener("mousedown",oe,!0),()=>{document.removeEventListener("keydown",J,!0),document.removeEventListener("mousedown",oe,!0)}},[t]),k.useEffect(()=>{v==="contains"&&M!==B&&a({type:"setFilterPattern",dim:n.ref,pattern:M})},[M,v,n.ref,a]);const L=f.models.find(J=>J.name===i.model)??e,Y=((N=m==null?void 0:m.timeDimension)==null?void 0:N.ref)??((W=L.timeDimension)==null?void 0:W.ref),z=k.useMemo(()=>xc(f),[f]),Q=k.useMemo(()=>{const J=[...(m==null?void 0:m.filters)??[],...Es(i.filters,{timeRef:Y,range:i.dateRange,excludeDim:n.ref,types:z,dialect:f.dialect})];return U.trim()&&J.push(Av(n.ref,U.trim(),f.dialect)),J},[m,i.filters,Y,i.dateRange,n.ref,U,z,f.dialect]),V=v!=="contains",{result:X,loading:ne,error:ae}=En(c,V?NS(n.ref,Q,JS,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations):null),ie=Ho(n.ref),ye=k.useMemo(()=>X?X.rows.map(J=>{const oe=J[ie];return oe==null?tr:String(oe)}):[],[X,ie]),re=!!X&&X.rows.length>0&&!X.columns.includes(ie),O=V&&(ne||re);function G(J){x(J),g&&a({type:"setFilterMode",dim:n.ref,mode:J}),J==="contains"&&A(B)}function H(J){var Ie;if(J.key!=="Tab")return;const oe=(Ie=w.current)==null?void 0:Ie.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!oe||oe.length===0)return;const te=oe[0],he=oe[oe.length-1];J.shiftKey&&document.activeElement===te?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),te.focus())}return u.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":C,onKeyDown:H,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:C,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:t,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:KS.map(({mode:J,label:oe})=>u.jsx("button",{type:"button","aria-pressed":v===J,onClick:()=>G(J),className:`px-1.5 py-1 text-center ${v===J?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:oe},J))}),v==="contains"?u.jsx("input",{ref:_,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:F,onChange:J=>A(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:T,onChange:J=>$(J.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ae?u.jsx("p",{className:"px-1 py-2 text-danger",children:ae}):O?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(J=>u.jsx("div",{className:"skeleton h-4 w-full"},J))}):ye.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):ye.map(J=>{const oe=b.has(J);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:oe,onChange:()=>a({type:"toggleFilter",dim:n.ref,value:J,mode:v}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(J)})]},J)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>a({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:t,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}function qS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(v=>v.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null);$v(m,i&&!c),k.useEffect(()=>{if(!i)return;function v(b){b.key==="Escape"&&g()}function x(b){c||p.current&&!p.current.contains(b.target)&&g()}return document.addEventListener("keydown",v,!0),document.addEventListener("mousedown",x,!0),()=>{document.removeEventListener("keydown",v,!0),document.removeEventListener("mousedown",x,!0)}},[i,c]);function g(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?g():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"absolute left-0 top-full z-50 mt-1 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(v=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(v),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:v.label},v.ref))}):null,i&&c?u.jsx(zv,{dim:c,model:n,onClose:g}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function ZS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class XS extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const e_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Vv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function $(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",B=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Tv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${B?"opacity-50":""}`,children:e_.map(F=>u.jsx("button",{type:"button",disabled:B,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>$(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!B?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:i,model:a,filter:c,onRemove:f}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":c.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(p=>!p),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:i.label})," ",jb(c)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:f,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(zv,{dim:i,model:a,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const t_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function n_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function r_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function s_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(t_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();n_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=r_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function i_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const o_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(L=>n.some(Y=>String(L[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:$,safePage:U,start:B,visibleRows:F}=wb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const L=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${L?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${L?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:L?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,L)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},B+L))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const L=g==null?void 0:g[M.key];if(!L)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=i_(C,M.key,L),z=L==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":L,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:o_[L]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[B+1,"–",Math.min(B+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=$-1,onClick:()=>b(M=>Math.min($-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function a_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function l_(){var U,B;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=a_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((B=f==null?void 0:f.timeDimension)==null?void 0:B.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Es(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?kS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=En(a,w),$=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):$.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:$,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Wv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Wv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Hv(n){document.documentElement.dataset.theme=n}function c_(){Hv(yf())}function u_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Wv,n),Hv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(u_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Gv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Yv="dashboard_filters",Qv="dashboard_ranges",Kv="dashboard_filter_sources",Jv="dashboard_range_sources",qv="dashboard_chart_filters",Zv="dashboard_chart_ranges";function d_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function f_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function h_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function p_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=p_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function m_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function y_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function g_(n,e,t){return[e,...t].some(i=>gf(n,i))}const v_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return v_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function Xv(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function e0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function t0(n,e,t){const i=Fs(n);if(i){const a=e0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function x_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[t0(n,{from:e,to:e},i)]:Ev({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function b_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,$,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(Xv(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([B,F])=>x_(B,F,i,f)),...Object.entries(p.ranges).map(([B,F])=>t0(B,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=($=n.defaults)==null?void 0:$.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=e0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function w_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(L=>L.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?[{dimension:L,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([L,Y])=>{const z=Fs(L);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[L,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:L,value:Y})=>Y!==tr&&(!g||L.startsWith(`${g}.`))),T=Object.keys(v.ranges),$=[_,...T].find((L,Y,z)=>{if(!L||z.indexOf(L)!==Y||!v.ranges[L])return!1;const Q=Fs(L);return((i[L]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||L.startsWith(`${g}.`))}),U=$?v.ranges[$]:void 0,B=C?sy(C.dimension,{from:C.value,to:C.value}):$&&U?sy($,U):null;return B&&(w.set("from",B.from),w.set("to",B.to)),`/explore?${w}`}function S_(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function __(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function n0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function r0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function s0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function i0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function N_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Yv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Qv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(Kv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Jv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(qv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(Zv)??"{}")}catch{x={}}const b=s0(e),w=i0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:n0(v,w),chartRanges:r0(x,w)}}function j_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Yv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Qv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(Kv,JSON.stringify(i)),Object.keys(a).length&&t.set(Jv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(qv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(Zv,JSON.stringify(n.chartRanges)),t.toString()}function o0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function k_(n){try{const e=JSON.parse(localStorage.getItem(o0(n))??"[]");if(!Array.isArray(e))return[];const t=s0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=i0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:n0(c.chartFilters,p),chartRanges:r0(c.chartRanges,p)}}]})}catch{return[]}}function I_(n,e){try{return localStorage.setItem(o0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function M_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r -`)}function D_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function C_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Bv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const F_="600px";function O_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function T_(n,e,t=F_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:O_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const A_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function a0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),$=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,B=m!=="none",F=B?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,V;const M=A.metric<0?"negative":"positive",L=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/$*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":L||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":L,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),B?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${A_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((V=A.context)==null?void 0:V.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],B_=[],R_=[];function L_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=B_,baseSegments:m=R_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var oe;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),$=k.useRef(null),[U,B]=k.useState(!1);k.useEffect(()=>{if(!(U||!$.current))return T_($.current,()=>B(!0))},[U]);const F=t??((oe=e.timeDimension)==null?void 0:oe.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Es(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:L,loading:Y,error:z}=En(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],V=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,X=[i.ref,n.ref],ne=Tt(n.ref,X),ae=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!L||!L.columns.includes(ne))return null;const te=[];let he=!1;for(const Fe of L.rows){const Ue=Fe[ne];Ue==null?he=!0:te.push(String(Ue))}const Ie=[];return te.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${te.map(Fe=>Kn(Fe,T.dialect)).join(", ")})`),he&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[L,ne,n.ref,T.dialect]),ye=k.useMemo(()=>ae&&f&&F&&ie?[...p,...Es(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[ae,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=En(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,X),G=!!L&&L.rows.length>0&&!L.columns.includes(O),H=k.useMemo(()=>{const te=new Map;if(!re.result||!re.result.columns.includes(O))return te;for(const he of re.result.rows){const Ie=he[ne],Fe=Ie==null?tr:String(Ie);te.set(Fe,Number(he[O]))}return te},[re.result,ne,O]),N={format:i.format,type:i.type};function W(te,he){switch(a){case"pctTotal":return c===void 0?void 0:Sb(he,c);case"delta":return _b(he,H.get(te),N);case"deltaPct":return Nb(he,H.get(te));default:return}}const J=L&&!G?L.rows.map(te=>{const he=te[ne],Ie=he==null?tr:String(he),Fe=Number(te[O]??0);return{value:Ie,metric:Fe,context:W(Ie,Fe)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(a0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:J,containerRef:$,loading:!U||Y||G,selectedValues:V,formatMetric:te=>Gt(te,N),onToggle:te=>_({type:"toggleFilter",dim:n.ref,value:te}),contextColumn:a,contextOptions:E_,onContextColumn:te=>_({type:"setContextColumn",column:te}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function l0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[$,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(W=>{for(const J of W)b(Math.max(40,J.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const B=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(B.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...B.map(H=>H.value)),L=Math.max(...B.map(H=>H.value))-A||1,Y=B.map((H,N)=>({...H,x:F+N/(B.length-1)*(x-F*2),y:F+(1-(H.value-A)/L)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,V=Y.at(-1),X=i||`Trend of ${B.length} points, latest ${a(V.value)}`;function ne(H){var W;const N=(W=g.current)==null?void 0:W.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function ae(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=ne(H),W=ae(N),J=Y[W];_(W),U({content:`${e!=null&&e[J.index]?`${e[J.index]}: `:""}${a(J.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:J.index,label:e==null?void 0:e[J.index],value:J.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=ne(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=ne(H);if(Math.abs(N-v.current)>6){const W=Y[ae(Math.min(v.current,N))],J=Y[ae(Math.max(v.current,N))];f({from:e[W.index],to:e[J.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":X,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:V.x,cy:V.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:$})]})}const U_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},P_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${U_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:P_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),$="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(l0,{values:p,labels:m,onHover:B=>{C(B),b==null||b(B)},onBrush:w,formatValue:B=>pt(B,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:$,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,$]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const le=v.current;if(!le)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(le),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(le=>le.points),...i??[]].map(le=>le.y).filter(Number.isFinite),L=F<2||M.length===0,Y=L?0:Math.min(0,...M),z=L?1:Math.max(...M),Q=z-Y||1,V=_-Xt.left-Xt.right,X=_l-Xt.top-Xt.bottom,ne=le=>Xt.left+(F<=1?0:le/(F-1)*V),ae=le=>Xt.top+(1-(le-Y)/Q)*X,ie=le=>ay(Math.round((le-Xt.left)/V*(F-1)),0,F-1),ye=le=>{const Oe=[];let st=[];return le.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${ne(Un).toFixed(1)},${ae(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=L||n.some(le=>!Number.isFinite(le.y))?"":`M ${ne(0).toFixed(1)},${ae(Y).toFixed(1)} L ${n.map((le,Oe)=>`${ne(Oe).toFixed(1)},${ae(le.y).toFixed(1)}`).join(" L ")} L ${ne(F-1).toFixed(1)},${ae(Y).toFixed(1)} Z`;function O(le){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?le.clientX-Oe.left:0}function G(le){if(L)return;const Oe=O(le);$(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},B({...w.current}))}function H(le){if(L||!g)return;le.currentTarget.setPointerCapture(le.pointerId),b.current=!0;const Oe=O(le);w.current={a:Oe,b:Oe},B({...w.current})}function N(le){le.currentTarget.hasPointerCapture(le.pointerId)&&le.currentTarget.releasePointerCapture(le.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,B(null)}function W(){$(null),b.current=!1,w.current=null,B(null)}const J=Math.max(1,Math.ceil(F/8)),oe=[z,Y+Q*.66,Y+Q*.33,Y],te=T!=null&&T>=0&&T{const st=le.points[te];return st&&Number.isFinite(st.y)?[{...le,point:st,index:Oe}]:[]}),dt=te!=null?(i==null?void 0:i[te])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=te!=null?ay(ne(te),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(L?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((le,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",le.label]},`${le.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:L?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:W,onPointerCancel:W,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),oe.map((le,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:ae(le),y2:ae(le),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:ae(le)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(le)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((le,Oe)=>u.jsx("path",{d:ye(le.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${le.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:X,className:"fill-chart-primary",opacity:.12}):null,te!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:ne(te),x2:ne(te),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:ne(te),cy:ae(St.y),r:3,className:"fill-faint"}):null,Ue.map(le=>u.jsx("circle",{cx:ne(te),cy:ae(le.point.y),r:3.5,fill:wd(le.index)},`${le.label}-${le.index}`))]}):null,n.map((le,Oe)=>Oe%J===0||Oe===F-1?u.jsx("text",{x:ne(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(le.x)},le.x):null)]})}),Ue.length&&Fe?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Fe)}),Ue.map(le=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:le.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(le.point.y)})]},`${le.label}-${le.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const $_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function z_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?jy(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${$_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const V_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function W_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} +]`}concat(...e){const t=this.schema,i=this.data.concat(e.flatMap(({data:a})=>a));return new vn(t,i.map(a=>new Tn(t,a)))}slice(e,t){const i=this.schema;[e,t]=rv({length:this.numRows},e,t);const a=av(this.data,this._offsets,e,t);return new vn(i,a.map(c=>new Tn(i,c)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&ei.children[e]);if(t.length===0){const{type:i}=this.schema.fields[e],a=Ee({type:i,length:0,nullCount:0});t.push(a._changeLengthAndBackfillNullBitmap(this.numRows))}return new Je(t)}return null}setChild(e,t){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(a=>a.name===e),t)}setChildAt(e,t){let i=this.schema,a=[...this.batches];if(e>-1&&ethis.getChildAt(g));[c[e],p[e]]=[f,t],[i,a]=md(i,p)}return new vn(i,a)}select(e){const t=this.schema.fields.reduce((i,a,c)=>i.set(a.name,c),new Map);return this.selectAt(e.map(i=>t.get(i)).filter(i=>i>-1))}selectAt(e){const t=this.schema.selectAt(e),i=this.batches.map(a=>a.selectAt(e));return new vn(t,i)}assign(e){const t=this.schema.fields,[i,a]=e.schema.fields.reduce((p,m,g)=>{const[v,x]=p,b=t.findIndex(w=>w.name===m.name);return~b?x[b]=g:v.push(g),p},[[],[]]),c=this.schema.assign(e.schema),f=[...t.map((p,m)=>[m,a[m]]).map(([p,m])=>m===void 0?this.getChildAt(p):e.getChildAt(m)),...i.map(p=>e.getChildAt(p))].filter(Boolean);return new vn(...md(c,f))}}gv=Symbol.toStringTag;vn[gv]=(n=>(n.schema=null,n.batches=[],n._offsets=new Uint32Array([0]),n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,n.isValid=tc(tf),n.get=tc(Qt.getVisitFn(D.Struct)),n.set=lv(wn.getVisitFn(D.Struct)),n.indexOf=cv(nc.getVisitFn(D.Struct)),"Table"))(vn.prototype);var vv;let Tn=class zo{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ee({nullCount:0,type:new Bt(this.schema.fields),children:this.schema.fields.map(t=>Ee({type:t.type,nullCount:0}))})]=e,!(this.data instanceof Ye))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Am(this.schema,this.data.children);break}case 1:{const[t]=e,{fields:i,children:a,length:c}=Object.keys(t).reduce((m,g,v)=>(m.children[v]=t[g],m.length=Math.max(m.length,t[g].length),m.fields[v]=nt.new({name:g,type:t[g].type,nullable:!0}),m),{length:0,fields:new Array,children:new Array}),f=new We(i),p=Ee({type:new Bt(i),length:c,children:a,nullCount:0});[this.schema,this.data]=Am(f,p.children,c);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=xv(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Qt.visit(this.data,e)}at(e){return this.get(Zd(e,this.numRows))}set(e,t){return wn.visit(this.data,e,t)}indexOf(e,t){return nc.visit(this.data,e,t)}[Symbol.iterator](){return nf.visit(new Je([this.data]))}toArray(){return[...this]}concat(...e){return new vn(this.schema,[this,...e])}slice(e,t){const[i]=new Je([this.data]).slice(e,t).data;return new zo(this.schema,i)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)===null||t===void 0?void 0:t.findIndex(i=>i.name===e))}getChildAt(e){return e>-1&&ea.name===e),t)}setChildAt(e,t){let i=this.schema,a=this.data;if(e>-1&&ep.name===c);~f&&(a[f]=this.data.children[f])}return new zo(t,Ee({type:i,length:this.numRows,children:a}))}selectAt(e){const t=this.schema.selectAt(e),i=e.map(c=>this.data.children[c]).filter(Boolean),a=Ee({type:new Bt(t.fields),length:this.numRows,children:i});return new zo(t,a)}};vv=Symbol.toStringTag;Tn[vv]=(n=>(n._nullCount=-1,n[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Tn.prototype);function Am(n,e,t=e.reduce((i,a)=>Math.max(i,a.length),0)){var i;const a=[...n.fields],c=[...e],f=(t+63&-64)>>3;for(const[p,m]of n.fields.entries()){const g=e[p];(!g||g.length!==t)&&(a[p]=m.clone({nullable:!0}),c[p]=(i=g==null?void 0:g._changeLengthAndBackfillNullBitmap(t))!==null&&i!==void 0?i:Ee({type:m.type,length:t,nullCount:t,nullBitmap:new Uint8Array(f)}))}return[n.assign(a),Ee({type:new Bt(a),length:t,children:c})]}function xv(n,e,t=new Map){var i,a;if(((i=n==null?void 0:n.length)!==null&&i!==void 0?i:0)>0&&(n==null?void 0:n.length)===(e==null?void 0:e.length))for(let c=-1,f=n.length;++cEe({type:a.type})),i=Ee({type:new Bt(e.fields),nullCount:0,children:t});super(e,i)}}let ts=class Gn{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(e,t){return(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,t){return e.setPosition(e.position()+He),(t||new Gn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ht.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Ve.NONE}header(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,t){const i=this.bb.__offset(this.bb_pos,12);return i?(t||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,ht.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,Ve.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt("0"))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let i=t.length-1;i>=0;i--)e.addOffset(t[i]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(e,t,i,a,c,f){return Gn.startMessage(e),Gn.addVersion(e,t),Gn.addHeaderType(e,i),Gn.addHeader(e,a),Gn.addBodyLength(e,c),Gn.addCustomMetadata(e,f),Gn.endMessage(e)}};class w1 extends Le{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return Nm.startNull(t),Nm.endNull(t)}visitInt(e,t){return nn.startInt(t),nn.addBitWidth(t,e.bitWidth),nn.addIsSigned(t,e.isSigned),nn.endInt(t)}visitFloat(e,t){return qn.startFloatingPoint(t),qn.addPrecision(t,e.precision),qn.endFloatingPoint(t)}visitBinary(e,t){return xm.startBinary(t),xm.endBinary(t)}visitLargeBinary(e,t){return wm.startLargeBinary(t),wm.endLargeBinary(t)}visitBool(e,t){return bm.startBool(t),bm.endBool(t)}visitUtf8(e,t){return jm.startUtf8(t),jm.endUtf8(t)}visitLargeUtf8(e,t){return Sm.startLargeUtf8(t),Sm.endLargeUtf8(t)}visitDecimal(e,t){return di.startDecimal(t),di.addScale(t,e.scale),di.addPrecision(t,e.precision),di.addBitWidth(t,e.bitWidth),di.endDecimal(t)}visitDate(e,t){return kl.startDate(t),kl.addUnit(t,e.unit),kl.endDate(t)}visitTime(e,t){return yn.startTime(t),yn.addUnit(t,e.unit),yn.addBitWidth(t,e.bitWidth),yn.endTime(t)}visitTimestamp(e,t){const i=e.timezone&&t.createString(e.timezone)||void 0;return gn.startTimestamp(t),gn.addUnit(t,e.unit),i!==void 0&&gn.addTimezone(t,i),gn.endTimestamp(t)}visitInterval(e,t){return Zn.startInterval(t),Zn.addUnit(t,e.unit),Zn.endInterval(t)}visitDuration(e,t){return Il.startDuration(t),Il.addUnit(t,e.unit),Il.endDuration(t)}visitList(e,t){return _m.startList(t),_m.endList(t)}visitStruct(e,t){return Ds.startStruct_(t),Ds.endStruct_(t)}visitUnion(e,t){Ht.startTypeIdsVector(t,e.typeIds.length);const i=Ht.createTypeIdsVector(t,e.typeIds);return Ht.startUnion(t),Ht.addMode(t,e.mode),Ht.addTypeIds(t,i),Ht.endUnion(t)}visitDictionary(e,t){const i=this.visit(e.indices,t);return Sr.startDictionaryEncoding(t),Sr.addId(t,BigInt(e.id)),Sr.addIsOrdered(t,e.isOrdered),i!==void 0&&Sr.addIndexType(t,i),Sr.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return Ml.startFixedSizeBinary(t),Ml.addByteWidth(t,e.byteWidth),Ml.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return Dl.startFixedSizeList(t),Dl.addListSize(t,e.listSize),Dl.endFixedSizeList(t)}visitMap(e,t){return Cl.startMap(t),Cl.addKeysSorted(t,e.keysSorted),Cl.endMap(t)}}const yd=new w1;function S1(n,e=new Map){return new We(N1(n,e),Ol(n.metadata),e)}function wv(n){return new Rn(n.count,Sv(n.columns),_v(n.columns))}function _1(n){return new kr(wv(n.data),n.id,n.isDelta)}function N1(n,e){return(n.fields||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Bm(n,e){return(n.children||[]).filter(Boolean).map(t=>nt.fromJSON(t,e))}function Sv(n){return(n||[]).reduce((e,t)=>[...e,new Ei(t.count,j1(t.VALIDITY)),...Sv(t.children)],[])}function _v(n,e=[]){for(let t=-1,i=(n||[]).length;++te+ +(t===0),0)}function k1(n,e){let t,i,a,c,f,p;return!e||!(c=n.dictionary)?(f=Rm(n,Bm(n,e)),a=new nt(n.name,f,n.nullable,Ol(n.metadata))):e.has(t=c.id)?(i=(i=c.indexType)?Em(i):new Jo,p=new Di(e.get(t),i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))):(i=(i=c.indexType)?Em(i):new Jo,e.set(t,f=Rm(n,Bm(n,e))),p=new Di(f,i,t,c.isOrdered),a=new nt(n.name,p,n.nullable,Ol(n.metadata))),a||null}function Ol(n=[]){return new Map(n.map(({key:e,value:t})=>[e,t]))}function Em(n){return new Os(n.isSigned,n.bitWidth)}function Rm(n,e){const t=n.type.name;switch(t){case"NONE":return new ls;case"null":return new ls;case"binary":return new Ul;case"largebinary":return new Pl;case"utf8":return new $l;case"largeutf8":return new zl;case"bool":return new Vl;case"list":return new Jl((e||[])[0]);case"struct":return new Bt(e||[]);case"struct_":return new Bt(e||[])}switch(t){case"int":{const i=n.type;return new Os(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=n.type;return new Ll(Ct[i.precision])}case"decimal":{const i=n.type;return new Wl(i.scale,i.precision,i.bitWidth)}case"date":{const i=n.type;return new Hl(bn[i.unit])}case"time":{const i=n.type;return new Gl(_e[i.unit],i.bitWidth)}case"timestamp":{const i=n.type;return new Yl(_e[i.unit],i.timezone)}case"interval":{const i=n.type;return new Ql(rr[i.unit])}case"duration":{const i=n.type;return new Kl(_e[i.unit])}case"union":{const i=n.type,[a,...c]=(i.mode+"").toLowerCase(),f=a.toUpperCase()+c.join("");return new ql(Yt[f],i.typeIds||[],e||[])}case"fixedsizebinary":{const i=n.type;return new Zl(i.byteWidth)}case"fixedsizelist":{const i=n.type;return new Xl(i.listSize,(e||[])[0])}case"map":{const i=n.type;return new ec((e||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${t}"`)}var I1=Ry,M1=Ii;class An{static fromJSON(e,t){const i=new An(0,ht.V5,t);return i._createHeader=D1(e,t),i}static decode(e){e=new M1(Pe(e));const t=ts.getRootAsMessage(e),i=t.bodyLength(),a=t.version(),c=t.headerType(),f=new An(i,a,c);return f._createHeader=C1(t,c),f}static encode(e){const t=new I1;let i=-1;return e.isSchema()?i=We.encode(t,e.header()):e.isRecordBatch()?i=Rn.encode(t,e.header()):e.isDictionaryBatch()&&(i=kr.encode(t,e.header())),ts.startMessage(t),ts.addVersion(t,ht.V5),ts.addHeader(t,i),ts.addHeaderType(t,e.headerType),ts.addBodyLength(t,BigInt(e.bodyLength)),ts.finishMessageBuffer(t,ts.endMessage(t)),t.asUint8Array()}static from(e,t=0){if(e instanceof We)return new An(0,ht.V5,Ve.Schema,e);if(e instanceof Rn)return new An(t,ht.V5,Ve.RecordBatch,e);if(e instanceof kr)return new An(t,ht.V5,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}constructor(e,t,i,a){this._version=t,this._headerType=i,this.body=new Uint8Array(0),a&&(this._createHeader=()=>a),this._bodyLength=tt(e)}}class Rn{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,i){this._nodes=t,this._buffers=i,this._length=tt(e)}}class kr{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,i=!1){this._data=e,this._isDelta=i,this._id=tt(t)}}class _r{constructor(e,t){this.offset=tt(e),this.length=tt(t)}}class Ei{constructor(e,t){this.length=tt(e),this.nullCount=tt(t)}}function D1(n,e){return(()=>{switch(e){case Ve.Schema:return We.fromJSON(n);case Ve.RecordBatch:return Rn.fromJSON(n);case Ve.DictionaryBatch:return kr.fromJSON(n)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}function C1(n,e){return(()=>{switch(e){case Ve.Schema:return We.decode(n.header(new Yn),new Map,n.version());case Ve.RecordBatch:return Rn.decode(n.header(new gr),n.version());case Ve.DictionaryBatch:return kr.decode(n.header(new ci),n.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)})}nt.encode=$1;nt.decode=U1;nt.fromJSON=k1;We.encode=P1;We.decode=F1;We.fromJSON=S1;Rn.encode=z1;Rn.decode=O1;Rn.fromJSON=wv;kr.encode=V1;kr.decode=T1;kr.fromJSON=_1;Ei.encode=W1;Ei.decode=B1;_r.encode=H1;_r.decode=A1;function F1(n,e=new Map,t=ht.V5){const i=L1(n,e);return new We(i,Tl(n),e,t)}function O1(n,e=ht.V5){if(n.compression()!==null)throw new Error("Record batch compression not implemented");return new Rn(n.length(),E1(n),R1(n,e))}function T1(n,e=ht.V5){return new kr(Rn.decode(n.data(),e),n.id(),n.isDelta())}function A1(n){return new _r(n.offset(),n.length())}function B1(n){return new Ei(n.length(),n.nullCount())}function E1(n){const e=[];for(let t,i=-1,a=-1,c=n.nodesLength();++int.encode(n,c));Yn.startFieldsVector(n,t.length);const i=Yn.createFieldsVector(n,t),a=e.metadata&&e.metadata.size>0?Yn.createCustomMetadataVector(n,[...e.metadata].map(([c,f])=>{const p=n.createString(`${c}`),m=n.createString(`${f}`);return vt.startKeyValue(n),vt.addKey(n,p),vt.addValue(n,m),vt.endKeyValue(n)})):-1;return Yn.startSchema(n),Yn.addFields(n,i),Yn.addEndianness(n,G1?Mi.Little:Mi.Big),a!==-1&&Yn.addCustomMetadata(n,a),Yn.endSchema(n)}function $1(n,e){let t=-1,i=-1,a=-1;const c=e.type;let f=e.typeId;me.isDictionary(c)?(f=c.dictionary.typeId,a=yd.visit(c,n),i=yd.visit(c.dictionary,n)):i=yd.visit(c,n);const p=(c.children||[]).map(v=>nt.encode(n,v)),m=pn.createChildrenVector(n,p),g=e.metadata&&e.metadata.size>0?pn.createCustomMetadataVector(n,[...e.metadata].map(([v,x])=>{const b=n.createString(`${v}`),w=n.createString(`${x}`);return vt.startKeyValue(n),vt.addKey(n,b),vt.addValue(n,w),vt.endKeyValue(n)})):-1;return e.name&&(t=n.createString(e.name)),pn.startField(n),pn.addType(n,i),pn.addTypeType(n,f),pn.addChildren(n,m),pn.addNullable(n,!!e.nullable),t!==-1&&pn.addName(n,t),a!==-1&&pn.addDictionary(n,a),g!==-1&&pn.addCustomMetadata(n,g),pn.endField(n)}function z1(n,e){const t=e.nodes||[],i=e.buffers||[];gr.startNodesVector(n,t.length);for(const f of t.slice().reverse())Ei.encode(n,f);const a=n.endVector();gr.startBuffersVector(n,i.length);for(const f of i.slice().reverse())_r.encode(n,f);const c=n.endVector();return gr.startRecordBatch(n),gr.addLength(n,BigInt(e.length)),gr.addNodes(n,a),gr.addBuffers(n,c),gr.endRecordBatch(n)}function V1(n,e){const t=Rn.encode(n,e.data);return ci.startDictionaryBatch(n),ci.addId(n,BigInt(e.id)),ci.addIsDelta(n,e.isDelta),ci.addData(n,t),ci.endDictionaryBatch(n)}function W1(n,e){return Py.createFieldNode(n,BigInt(e.length),BigInt(e.nullCount))}function H1(n,e){return Uy.createBuffer(n,BigInt(e.offset),BigInt(e.length))}const G1=(()=>{const n=new ArrayBuffer(2);return new DataView(n).setInt16(0,256,!0),new Int16Array(n)[0]===256})(),cf=n=>`Expected ${Ve[n]} Message in stream, but was null or length 0.`,uf=n=>`Header pointer of flatbuffer-encoded ${Ve[n]} Message is null or length 0.`,Nv=(n,e)=>`Expected to read ${n} metadata bytes, but only read ${e}.`,jv=(n,e)=>`Expected to read ${n} bytes for message body, but only read ${e}.`;class kv{constructor(e){this.source=e instanceof sc?e:new sc(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?at:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const t=Pe(this.source.read(e));if(t.byteLength[...a,...c.VALIDITY&&[c.VALIDITY]||[],...c.TYPE_ID&&[c.TYPE_ID]||[],...c.OFFSET&&[c.OFFSET]||[],...c.DATA&&[c.DATA]||[],...t(c.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw new Error(cf(e));return t.value}readSchema(){const e=Ve.Schema,t=this.readMessage(e),i=t==null?void 0:t.header();if(!t||!i)throw new Error(uf(e));return i}}const vc=4,Ud="ARROW1",oc=new Uint8Array(Ud.length);for(let n=0;nthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return mn.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return mn.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,t){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof jr?e:Dd(e)?X1(e):Fy(e)?nS(e):Go(e)?Te(this,void 0,void 0,function*(){return yield jr.from(yield e)}):Oy(e)||Gd(e)||Ay(e)||Hd(e)?tS(new Fi(e)):eS(new sc(e))}static readAll(e){return e instanceof jr?e.isSync()?$m(e):zm(e):Dd(e)||ArrayBuffer.isView(e)||mc(e)||Cy(e)?$m(e):zm(e)}}class ac extends jr{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Xn(this,arguments,function*(){yield Ae(yield*jl(bi(this[Symbol.iterator]())))})}}class lc extends jr{constructor(e){super(e),this._impl=e}readAll(){return Te(this,void 0,void 0,function*(){var e,t,i,a;const c=new Array;try{for(var f=!0,p=bi(this),m;m=yield p.next(),e=m.done,!e;f=!0){a=m.value,f=!1;const g=a;c.push(g)}}catch(g){t={error:g}}finally{try{!f&&!e&&(i=p.return)&&(yield i.call(p))}finally{if(t)throw t.error}}return c})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Mv extends ac{constructor(e){super(e),this._impl=e}}class J1 extends lc{constructor(e){super(e),this._impl=e}}class Dv{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){const i=this._loadVectors(e,t,this.schema.fields),a=Ee({type:new Bt(this.schema.fields),length:e.length,children:i});return new Tn(this.schema,a)}_loadDictionaryBatch(e,t){const{id:i,isDelta:a}=e,{dictionaries:c,schema:f}=this,p=c.get(i),m=f.dictionaries.get(i),g=this._loadVectors(e.data,t,[m]);return(p&&a?p.concat(new Je(g)):new Je(g)).memoize()}_loadVectors(e,t,i){return new yv(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class cc extends Dv{constructor(e,t){super(t),this._reader=Dd(e)?new Q1(this._handle=e):new kv(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Fv(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):at}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):at}next(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bv(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class uc extends Dv{constructor(e,t){super(t),this._reader=new Y1(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Te(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return Te(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Fv(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):at})}return(e){return Te(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):at})}next(){return Te(this,void 0,void 0,function*(){if(this.closed)return at;let e;const{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(i,a)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const i=e.header(),a=yield t.readMessageBody(e.bodyLength),c=this._loadDictionaryBatch(i,a);this.dictionaries.set(i.id,c)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bv(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class Cv extends cc{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Tm?e:new Tm(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null}_readDictionaryBatch(e){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&this._handle.seek(i.offset)){const a=this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}}_readFooter(){const{_handle:e}=this,t=e.size-Iv,i=e.readInt32(t),a=e.readAt(t-i,i);return rf.decode(a)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Te(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return Te(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());const i=(t=this._footer)===null||t===void 0?void 0:t.getRecordBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.RecordBatch);if(a!=null&&a.isRecordBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength);return this._loadRecordBatch(c,f)}}return null})}_readDictionaryBatch(e){return Te(this,void 0,void 0,function*(){var t;const i=(t=this._footer)===null||t===void 0?void 0:t.getDictionaryBatch(e);if(i&&(yield this._handle.seek(i.offset))){const a=yield this._reader.readMessage(Ve.DictionaryBatch);if(a!=null&&a.isDictionaryBatch()){const c=a.header(),f=yield this._reader.readMessageBody(a.bodyLength),p=this._loadDictionaryBatch(c,f);this.dictionaries.set(c.id,p)}}})}_readFooter(){return Te(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const t=e.size-Iv,i=yield e.readInt32(t),a=yield e.readAt(t-i,i);return rf.decode(a)})}_readNextMessageAndValidate(e){return Te(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?df(e)?new Mv(new Cv(n.read())):new ac(new cc(n)):new ac(new cc((function*(){})()))}function tS(n){return Te(this,void 0,void 0,function*(){const e=yield n.peek(na+7&-8);return e&&e.byteLength>=4?df(e)?new Mv(new Cv(yield n.read())):new lc(new uc(n)):new lc(new uc((function(){return Xn(this,arguments,function*(){})})()))})}function nS(n){return Te(this,void 0,void 0,function*(){const{size:e}=yield n.stat(),t=new ic(n,e);return e>=K1&&df(yield t.readAt(0,na+7&-8))?new J1(new q1(t)):new lc(new uc(t))})}function Ov(n){const e=jr.from(n);return Go(e)?e.then(t=>Ov(t)):e.isAsync()?e.readAll().then(t=>new vn(t)):new vn(e.readAll())}function rS(n){if(n==null)return null;if(typeof n=="bigint"){const e=Number(n);return Number.isSafeInteger(e)?e:n.toString()}if(n instanceof Date){const e=n.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}return typeof n=="object"?String(n):n}function sS(n){const e=Ov(n),t=e.schema.fields.map(a=>a.name),i=new Array(e.numRows);for(let a=0;a({...e,charts:e.charts.map(t=>{var f,p;const i=t.query,a=(f=t.interactions)==null?void 0:f.brush,c=(p=t.interactions)==null?void 0:p.select;return{...t,query:{...i,metrics:ns(i.metrics)??[],dimensions:ns(i.dimensions),filters:ns(i.filters),segments:ns(i.segments),order_by:ns(i.order_by),orderBy:ns(i.orderBy)},interactions:t.interactions?{...t.interactions,brush:typeof a=="object"?{...a,fields:ns(a.fields)}:a,select:typeof c=="object"?{...c,fields:ns(c.fields)}:c}:void 0}})}))}}const oS="application/vnd.apache.arrow.stream";class aS{constructor(e){Dn(this,"active",0);Dn(this,"waiters",[]);this.max=e}async run(e){var t;this.active>=this.max&&await new Promise(i=>this.waiters.push(i)),this.active+=1;try{return await e()}finally{this.active-=1,(t=this.waiters.shift())==null||t()}}}function lS(n){var t,i,a,c,f;const e={};return(t=n.metrics)!=null&&t.length&&(e.metrics=n.metrics),(i=n.dimensions)!=null&&i.length&&(e.dimensions=n.dimensions),(a=n.filters)!=null&&a.length&&(e.filters=n.filters),(c=n.segments)!=null&&c.length&&(e.segments=n.segments),(f=n.orderBy)!=null&&f.length&&(e.order_by=n.orderBy),n.limit!=null&&(e.limit=n.limit),n.offset!=null&&(e.offset=n.offset),n.ungrouped&&(e.ungrouped=!0),n.parameters&&(e.parameters=n.parameters),n.usePreaggregations!=null&&(e.use_preaggregations=n.usePreaggregations),n.timezone&&n.timezone!=="UTC"&&(e.timezone=n.timezone),e}class cS{constructor(e={}){Dn(this,"baseUrl");Dn(this,"token");Dn(this,"sessionToken");Dn(this,"transport");Dn(this,"usePreaggregations");Dn(this,"gate");Dn(this,"onUnauthorized");this.baseUrl=(e.baseUrl??"").replace(/\/$/,""),this.token=e.token,this.transport=e.transport??"json",this.usePreaggregations=e.usePreaggregations??!0,this.gate=new aS(e.maxConcurrency??6),this.onUnauthorized=e.onUnauthorized}body(e){return lS({usePreaggregations:this.usePreaggregations,...e})}headers(e){const t={...e};return this.sessionToken?t.Authorization=`Sidemantic-Session ${this.sessionToken}`:this.token&&(t.Authorization=`Bearer ${this.token}`),t}isCrossOrigin(){return!this.baseUrl||typeof globalThis.location>"u"?!1:new URL(this.baseUrl,globalThis.location.href).origin!==globalThis.location.origin}url(e){return`${this.baseUrl}${e}`}async getJson(e){const t=await fetch(this.url(e),{headers:this.headers(),credentials:"include"});if(!t.ok)throw new Error(await this.errorText(t,e));return await t.json()}async errorText(e,t){var a;e.status===401&&((a=this.onUnauthorized)==null||a.call(this));let i="";try{const c=await e.json();i=c.error??c.detail??""}catch{}return`${t} failed (${e.status})${i?`: ${i}`:""}`}async health(){try{return(await fetch(this.url("/health"),{headers:this.headers(),credentials:"include"})).ok}catch{return!1}}async getCatalog(){try{const t=await fetch(this.url("/describe"),{headers:this.headers(),credentials:"include"});if(t.ok){const i=Mb(await t.json());try{return Cb(i,await this.getJson("/graph"))}catch{return i}}}catch{}const e=await this.getJson("/graph");return Db(e)}async getDashboard(){try{const e=await fetch(this.url("/dashboard"),{headers:this.headers()});if(e.status===404)return null;if(!e.ok)throw new Error(await this.errorText(e,"/dashboard"));if(!(e.headers.get("content-type")??"").includes("application/json"))return null;const t=await e.json();return typeof t.title=="string"&&Array.isArray(t.tabs)?iS(t):null}catch{return null}}async compile(e){const t=await fetch(this.url("/compile"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/compile"));return(await t.json()).sql}async runQuery(e){return this.gate.run(()=>this.transport==="arrow"?this.runQueryArrow(e):this.runQueryJson(e))}async runQueryJson(e){const t=await fetch(this.url("/query"),{method:"POST",headers:this.headers({"Content-Type":"application/json"}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=await t.json(),a=i.rows??[];return{columns:a.length?Object.keys(a[0]):[],rows:a,rowCount:i.row_count??a.length,sql:i.sql??""}}async runQueryArrow(e){const t=await fetch(this.url("/query?format=arrow"),{method:"POST",headers:this.headers({"Content-Type":"application/json",Accept:oS}),credentials:"include",body:JSON.stringify(this.body(e))});if(!t.ok)throw new Error(await this.errorText(t,"/query"));const i=new Uint8Array(await t.arrayBuffer()),{columns:a,rows:c}=sS(i),f=t.headers.get("X-Sidemantic-Sql")??"";return{columns:a,rows:c,rowCount:c.length,sql:f}}async createBrowserSession(e){var a;const t=this.isCrossOrigin(),i=await fetch(this.url("/auth/session"),{method:"POST",headers:{Authorization:`Bearer ${e}`,...t?{"X-Sidemantic-Session-Mode":"header"}:{}},credentials:"include"});if(i.status===404||i.ok&&!((a=i.headers.get("content-type"))!=null&&a.includes("application/json"))){this.token=e;return}if(!i.ok)throw new Error(await this.errorText(i,"/auth/session"));if(t){const c=await i.json();if(!c.session_token)throw new Error("/auth/session did not return a cross-origin session token");this.sessionToken=c.session_token}this.token=void 0}}function Tv({brand:n,toolbar:e,filters:t,rail:i,children:a,drawer:c,showRail:f=!0,openRailRequest:p}){const[m,g]=k.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches),[v,x]=k.useState(()=>typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches),b=k.useId(),w=k.useRef(null),_=k.useRef(null),C=f&&v;return k.useEffect(()=>{const T=window.matchMedia("(max-width: 767px)"),P=()=>{g(T.matches),x(!T.matches)};return T.addEventListener("change",P),()=>T.removeEventListener("change",P)},[]),k.useEffect(()=>{p&&!m&&x(!0)},[p,m]),k.useEffect(()=>{if(!m||!v)return;const T=_.current,P=document.body.style.overflow;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var E,F;return(F=(E=w.current)==null?void 0:E.querySelector("button"))==null?void 0:F.focus()});function U(E){var R;if(E.key==="Escape"){E.preventDefault(),x(!1);return}if(E.key!=="Tab")return;const F=(R=w.current)==null?void 0:R.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), [href], [tabindex]:not([tabindex="-1"])');if(!(F!=null&&F.length))return;const A=F[0],M=F[F.length-1];E.shiftKey&&document.activeElement===A?(E.preventDefault(),M.focus()):!E.shiftKey&&document.activeElement===M&&(E.preventDefault(),A.focus())}return document.addEventListener("keydown",U,!0),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",U,!0),T==null||T.focus()}},[m,v]),u.jsxs("div",{className:"flex h-[100dvh] min-w-0 flex-col overflow-hidden bg-bg text-ink",children:[u.jsxs("header",{className:"relative z-40 flex shrink-0 flex-col gap-2 border-b border-line bg-surface px-3 py-2 md:flex-row md:items-center md:justify-between md:gap-3",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f?u.jsx("button",{ref:_,type:"button","aria-label":m?"Open catalog":v?"Collapse sidebar":"Expand sidebar","aria-expanded":v,"aria-controls":b,onClick:()=>x(T=>!T),className:"grid size-7 shrink-0 place-items-center border border-line text-faint hover:border-faint hover:text-ink",children:v?"‹":"›"}):null,n]}),u.jsx("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-2 overflow-visible md:w-auto md:shrink-0 md:flex-nowrap",children:e})]}),t?u.jsx("div",{"data-filter-strip":!0,role:"region","aria-label":"Active filters",className:"relative z-30 flex max-h-[min(25dvh,8rem)] min-h-9 shrink-0 flex-wrap items-center gap-2 overflow-y-auto border-b border-line bg-surface px-3 py-1",children:t}):null,u.jsxs("div",{className:`grid min-h-0 min-w-0 flex-1 grid-cols-1 ${C?"md:grid-cols-[260px_minmax(0,1fr)]":"md:grid-cols-1"}`,children:[f&&C?u.jsxs(u.Fragment,{children:[m?u.jsx("button",{type:"button","aria-label":"Close catalog",className:"fixed inset-0 z-40 bg-black/35 backdrop-blur-[2px]",onClick:()=>x(!1)}):null,u.jsxs("aside",{id:b,ref:w,role:m?"dialog":void 0,"aria-modal":m?"true":void 0,"aria-label":m?"Data catalog":void 0,onClick:T=>{m&&T.target.closest("[data-catalog-metric], [data-catalog-dimension]")&&x(!1)},onChange:()=>m&&x(!1),className:"fixed inset-y-0 left-0 z-50 min-h-0 w-[min(88vw,320px)] overflow-y-auto bg-surface shadow-[var(--shadow)] md:static md:z-auto md:w-auto md:border-r md:border-line md:shadow-none",children:[m?u.jsxs("div",{"data-testid":"catalog-drawer-header",className:"sticky top-0 z-10 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold text-ink",children:"Catalog"}),u.jsx("p",{className:"text-xs text-muted",children:"Choose a model and fields"})]}),u.jsx("button",{type:"button","aria-label":"Close catalog",onClick:()=>x(!1),className:"grid size-10 place-items-center rounded-full bg-surface-soft text-muted hover:bg-line hover:text-ink",children:u.jsx("span",{"aria-hidden":"true",className:"text-xl leading-none",children:"×"})})]}):null,i]})]}):null,u.jsxs("main",{className:"relative z-0 min-h-0 min-w-0 overflow-hidden",children:[u.jsx("div",{className:`h-full overflow-y-auto ${c?"pb-8":""}`,children:a}),c]})]})]})}function uS({dashboardTitle:n,modelLabel:e,onHome:t}){const i=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-sm font-semibold text-ink",children:n??"Sidemantic"}),n===void 0&&e?u.jsx("span",{className:"truncate text-2xs text-faint",children:e}):null]});return n!==void 0?u.jsx("span",{className:"flex min-w-0 items-baseline gap-2",children:i}):u.jsx("button",{type:"button",onClick:t,"aria-label":"Home",className:"flex min-w-0 items-baseline gap-2",children:i})}var Av=_y();const dS=new Set(["second","minute","hour","day","week","month","quarter","year"]);function gl(n){return n===void 0?[]:Array.isArray(n)?n:[n]}function vl(n,e){return n.models.flatMap(t=>t.dimensions).find(t=>e===t.ref||e.startsWith(`${t.ref}__`))}function fS(n,e){const t=n.split("__").at(-1);return t&&dS.has(t)?t:e}function hS(n){var a;const e=(a=n.defaults)==null?void 0:a.query;if(!e||typeof e!="object")return;const t=e,i=t.use_preaggregations??t.usePreaggregations;return typeof i=="boolean"?i:void 0}function pS(n,e){var c;const t=(c=n.defaults)==null?void 0:c.query,i=t&&typeof t=="object"?t:{},a=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??i.interaction_preaggregations??i.interactionPreaggregations;return typeof a=="boolean"?a:void 0}function Ts(n,e,t){var F,A,M,R,Y,z,Q;if(!(e!=null&&e.tabs.length))return null;const i=e.tabs.find(W=>W.id===t)??e.tabs[0],a=i.charts[0];if(!a)return null;const c=gl(a.query.dimensions),f=gl(a.query.metrics),p=f.map(W=>{var ne;return(ne=n.graphMetrics.find(X=>X.ref===W))==null?void 0:ne.ownerModel}).find(W=>!!W),m=((F=f.find(W=>W.includes(".")))==null?void 0:F.split(".")[0])??p??((A=c.find(W=>W.includes(".")))==null?void 0:A.split(".")[0]),g=n.models.find(W=>W.name===m)??n.models[0];if(!g)return null;const v=[...n.models.flatMap(W=>W.metrics),...ki(n,g.name)],x=f.map(W=>v.find(ne=>ne.ref===W)).filter(W=>!!W),b=c.map(W=>vl(n,W)).filter((W,ne,X)=>!!W&&X.findIndex(le=>(le==null?void 0:le.ref)===(W==null?void 0:W.ref))===ne),w=(M=a.encoding)==null?void 0:M.y,C=(Array.isArray(w)?w:w?[w]:[]).find(W=>x.some(ne=>ne.ref===W))??((R=x[0])==null?void 0:R.ref)??((Y=g.metrics[0])==null?void 0:Y.ref)??"",T=(z=a.encoding)==null?void 0:z.x,P=(T&&((Q=vl(n,T))==null?void 0:Q.type)==="time"?T:void 0)??c.find(W=>{var ne;return((ne=vl(n,W))==null?void 0:ne.type)==="time"}),U=g.defaultGrain??"month",E=P?vl(n,P):g.timeDimension;return{id:i.id,label:i.label??i.id,title:a.title??e.title,model:g,metrics:x.length?x:g.metrics,dimensions:b.length?b:g.dimensions,timeDimension:E,selectedMetric:C,grain:P?fS(P,U):U,filters:gl(a.query.filters),segments:gl(a.query.segments),usePreaggregations:pS(e,a)??a.query.use_preaggregations??a.query.usePreaggregations??hS(e)}}const Pd=["second","minute","hour","day","week","month","quarter","year"];function mS(n,e){if(n!=null&&n.length){const i=new Set(n.map(c=>c.toLowerCase())),a=Pd.filter(c=>i.has(c));if(a.length)return a}const t=["day","week","month","quarter","year"];return e&&!t.includes(e)?Pd.filter(i=>i===e||t.includes(i)):t}function ji(n){return n.toISOString().slice(0,10)}function ff(n){return n.slice(0,10)}function Ti(n){const e=n.trim();return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?e:`${e.replace(" ","T")}Z`}function As(n){return new Date(`${ff(n)}T00:00:00Z`)}function qo(n,e){const t=As(n);return t.setUTCDate(t.getUTCDate()+e),ji(t)}function yS(n){return Math.round((As(n.to).getTime()-As(n.from).getTime())/864e5)+1}function gS(n){if(n.from.includes("T")||n.to.includes("T")){const a=Date.parse(Ti(n.from)),f=Date.parse(Ti(n.to))-a;return{from:new Date(a-f).toISOString().slice(0,19),to:new Date(a).toISOString().slice(0,19)}}const e=yS(n),t=qo(n.from,-1);return{from:qo(t,-(e-1)),to:t}}function Vm(n){if(n.includes("T")){const f=new Date(Ti(n)),p=f.getUTCFullYear()-1,m=f.getUTCMonth(),g=new Date(Date.UTC(p,m+1,0)).getUTCDate();return new Date(Date.UTC(p,m,Math.min(f.getUTCDate(),g),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds())).toISOString().slice(0,19)}const e=As(n),t=e.getUTCFullYear()-1,i=e.getUTCMonth(),a=e.getUTCDate(),c=new Date(Date.UTC(t,i+1,0)).getUTCDate();return ji(new Date(Date.UTC(t,i,Math.min(a,c))))}function vS(n){return{from:Vm(n.from),to:Vm(n.to)}}function xS(n,e){const t=n.trim(),i=t.slice(0,10);if(e!=="second"&&e!=="minute"&&e!=="hour")return i||n;const a=t.slice(10).match(/(\d{2}):(\d{2})(?::(\d{2}))?/);if(!a)return i||n;const c=e==="second"&&a[3]?`${a[1]}:${a[2]}:${a[3]}`:`${a[1]}:${a[2]}`;return`${i} ${c}`}const Bv=[{key:"7d",label:"Last 7 days",days:7},{key:"28d",label:"Last 28 days",days:28},{key:"90d",label:"Last 90 days",days:90},{key:"180d",label:"Last 180 days",days:180},{key:"365d",label:"Last 12 months",days:365}];function Ai(n,e=new Date){const t=ji(e);return{from:qo(t,-(n-1)),to:t}}function bS(n,e){return e.from.includes("T")||e.to.includes("T")?[`${n} >= cast('${e.from}' as timestamp)`,`${n} < cast('${e.to}' as timestamp)`]:[`${n} >= cast('${e.from}' as date)`,`${n} < cast('${qo(e.to,1)}' as date)`]}function Wm(n,e,t){if(t==="second"||t==="minute"||t==="hour"){const f=t==="second"?1e3:t==="minute"?6e4:36e5;return Math.round((Date.parse(Ti(e))-Date.parse(Ti(n)))/f)}const i=As(n),a=As(e),c=(a.getUTCFullYear()-i.getUTCFullYear())*12+(a.getUTCMonth()-i.getUTCMonth());switch(t){case"week":return Math.round((a.getTime()-i.getTime())/(7*864e5));case"month":return c;case"quarter":return Math.round(c/3);case"year":return a.getUTCFullYear()-i.getUTCFullYear();default:return Math.round((a.getTime()-i.getTime())/864e5)}}function gd(n,e){return new Date(Date.parse(Ti(n))+e).toISOString().slice(0,19)}function wS(n,e){const t=ff(n),i=As(t);switch(e){case"second":return gd(n,1e3);case"minute":return gd(n,6e4);case"hour":return gd(n,36e5);case"day":return t;case"week":return qo(n,6);case"month":return ji(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+1,0)));case"quarter":{const a=Math.floor(i.getUTCMonth()/3)*3+3;return ji(new Date(Date.UTC(i.getUTCFullYear(),a,0)))}case"year":return ji(new Date(Date.UTC(i.getUTCFullYear(),12,0)));default:return n}}function hf(n){return n.mode==="contains"?!n.pattern:n.values.length===0}function pf(n){return Object.fromEntries(n.map(e=>[e.ref,e.type]))}function xc(n){return pf(n.models.flatMap(e=>e.dimensions))}function Hm(n,e,t){if((e==="numeric"||e==="number")&&n.trim()!==""&&Number.isFinite(Number(n)))return n;if(e==="boolean"){const i=n.toLowerCase();if(i==="true"||i==="false")return i}return Kn(n,t)}function SS(n){return n.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function Ev(n,e,t){const i=Kn(`%${SS(e)}%`,t);return`CAST(${n} AS VARCHAR) ILIKE ${i}${t==="clickhouse"?"":" ESCAPE '\\'"}`}function _S(n,e,t,i){const a=e.mode==="exclude",c=e.values.includes(tr),f=e.values.filter(m=>m!==tr);let p=null;if(f.length===1)p=`${n} ${a?"!=":"="} ${Hm(f[0],t,i)}`;else if(f.length>1){const m=f.map(g=>Hm(g,t,i)).join(", ");p=`${n} ${a?"NOT IN":"IN"} (${m})`}if(!a){const m=[];return p&&m.push(p),c&&m.push(`${n} IS NULL`),m.length===0?null:m.length===1?m[0]:`(${m.join(" OR ")})`}if(c){const m=[];return p&&m.push(p),m.push(`${n} IS NOT NULL`),m.length===1?m[0]:`(${m.join(" AND ")})`}return p?`(${p} OR ${n} IS NULL)`:null}function Rv(n,e={}){var i;const t=[];for(const[a,c]of Object.entries(n)){if(a===e.excludeDim||hf(c))continue;const f=(i=e.types)==null?void 0:i[a];if(c.mode==="contains"){t.push(Ev(a,c.pattern??"",e.dialect));continue}const p=_S(a,c,f,e.dialect);p&&t.push(p)}return t}function Bs(n,e={}){const t=Rv(n,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&t.push(...bS(e.timeRef,e.range)),t}function vd(n,e,t,i){return{metrics:n,filters:e,...t!=null&&t.length?{segments:t}:{},...i!=null?{usePreaggregations:i}:{}}}const NS={second:2e3,minute:2e3,hour:9600,day:4e3,week:800,month:240,quarter:120,year:60};function Gm(n,e,t,i,a,c,f=!1){const p=`${e}__${t}`,m=t==="second"||t==="minute",g=m&&!f;return{metrics:n,dimensions:[p],filters:i,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${p} ${g?"DESC":"ASC"}`],...!m||g?{limit:NS[t]??2e3}:{}}}function Ym(n,e,t,i=6,a,c){return{metrics:[n],dimensions:[e],filters:t,...a!=null&&a.length?{segments:a}:{},...c!=null?{usePreaggregations:c}:{},orderBy:[`${n} DESC`],limit:i}}function jS(n,e,t=50,i,a){return{dimensions:[n],filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},orderBy:[`${n} ASC`],limit:t}}function kS(n,e,t,i,a=500){return{metrics:n,dimensions:e,filters:t,orderBy:i,limit:a}}function IS(n,e,t=50,i,a){return{dimensions:n.dimensions,metrics:n.metrics,filters:e,...i!=null&&i.length?{segments:i}:{},...a!=null?{usePreaggregations:a}:{},ungrouped:!0,limit:t}}function MS(n,e){const t=n??[];return t.includes(e)?t.filter(i=>i!==e):[...t,e]}function xl(n,e,t){const i={...n};return hf(t)?delete i[e]:i[e]=t,i}function DS(n,e){switch(e.type){case"hydrate":return e.state;case"setView":return{...n,view:e.view};case"setDashboardTab":return{...n,view:"explore",dashboardTab:e.tab,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},dateRange:void 0,datePreset:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setModel":return{...n,model:e.model,selectedMetric:e.metric,grain:e.grain,filters:{},joinedDims:[],pivotDims:[],pivotMetrics:[]};case"setMetric":return{...n,selectedMetric:e.metric};case"toggleFilter":{const t=n.filters[e.dim],i=e.mode??(t&&t.mode!=="contains"?t.mode:"include"),a=t&&t.mode===i?t.values:[],c=MS(a,e.value);return{...n,filters:xl(n.filters,e.dim,{mode:i,values:c})}}case"setFilterMode":{const t=n.filters[e.dim],i={mode:e.mode,values:(t==null?void 0:t.values)??[],pattern:t==null?void 0:t.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"setFilterPattern":{const t=n.filters[e.dim],i={mode:"contains",values:(t==null?void 0:t.values)??[],pattern:e.pattern};return{...n,filters:xl(n.filters,e.dim,i)}}case"removeFilterValue":{const t=n.filters[e.dim];if(!t)return n;const i=t.values.filter(a=>a!==e.value);return{...n,filters:xl(n.filters,e.dim,{...t,values:i})}}case"removeFilterDim":{const t={...n.filters};return delete t[e.dim],{...n,filters:t}}case"clearFilters":return{...n,filters:{}};case"setGrain":return{...n,grain:e.grain};case"setTimezone":return{...n,timezone:e.timezone};case"setDateRange":return{...n,dateRange:e.preset?Ai(e.preset):e.range,datePreset:e.preset??(e.range?void 0:"all")};case"setContextColumn":return{...n,contextColumn:e.column};case"setComparison":return{...n,comparison:e.comparison,comparisonRange:e.comparison==="custom"?e.range:void 0};case"setJoinedDims":return{...n,joinedDims:e.dims};case"setPivotDims":return{...n,pivotDims:e.dims};case"setPivotMetrics":return{...n,pivotMetrics:e.metrics};case"reset":return{...e.initial,view:n.view,dateRange:typeof e.initial.datePreset=="number"?Ai(e.initial.datePreset):e.initial.dateRange};default:return n}}function CS(n){return n.models.find(e=>e.timeDimension)??n.models[0]}function Lv(n,e){var t,i;return((t=n==null?void 0:n.metrics[0])==null?void 0:t.ref)??(n?(i=ki(e,n.name)[0])==null?void 0:i.ref:void 0)??""}function Uv(n,e,t){const i=Ts(n,e,t),a=(i==null?void 0:i.model)??CS(n),c=(i==null?void 0:i.selectedMetric)??Lv(a,n);return{view:i?"explore":"home",dashboardTab:i==null?void 0:i.id,model:(a==null?void 0:a.name)??"",selectedMetric:c,filters:{},grain:(i==null?void 0:i.grain)??(a==null?void 0:a.defaultGrain)??"month",timezone:"UTC",dateRange:i?void 0:Ai(28),datePreset:i?void 0:28,contextColumn:"none",comparison:"previous",comparisonRange:void 0,joinedDims:[],pivotDims:[],pivotMetrics:[]}}function FS(n,e,t){const i=new URLSearchParams(t),a=i.get("metric"),c=i.get("grain"),f=a===n.selectedMetric&&e.metrics.some(m=>m.ref===a),p=c===n.grain;return{...n,view:"explore",dashboardTab:e.id,model:e.model.name,selectedMetric:f?n.selectedMetric:e.selectedMetric,grain:p?n.grain:e.grain}}const OS=["home","explore","pivot"],TS=new Set(Pd),AS=new Set(["none","pctTotal","delta","deltaPct"]),BS=new Set(["off","previous","year","custom"]),ES="none",RS="previous",LS="UTC";function US(n){return n!=null&&/^[A-Za-z][A-Za-z0-9/_+-]{0,63}$/.test(n)}function bl(n){if(n)try{return JSON.parse(n)}catch{return}}function Wo(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function wl(n){return n!=null&&/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$/.test(n)&&!Number.isNaN(Date.parse(n))}const PS=new Set(["include","exclude","contains"]);function $S(n){if(Wo(n))return{mode:"include",values:n};if(typeof n!="object"||n===null||Array.isArray(n))return null;const e=n;if(!PS.has(e.mode))return null;const t=e.mode,i=Wo(e.values)?e.values:[],a=typeof e.pattern=="string"?e.pattern:void 0,c={mode:t,values:i,pattern:a};return hf(c)?null:c}function zS(n){if(typeof n!="object"||n===null||Array.isArray(n))return null;const e={};for(const[t,i]of Object.entries(n)){const a=$S(i);a&&(e[t]=a)}return e}function VS(n){const e={};for(const[t,i]of Object.entries(n))e[t]=i.mode==="include"?i.values:i;return e}function WS(n){const e=new URLSearchParams;return e.set("view",n.view),n.dashboardTab&&e.set("tab",n.dashboardTab),n.model&&e.set("model",n.model),n.selectedMetric&&e.set("metric",n.selectedMetric),n.grain&&e.set("grain",n.grain),n.timezone&&n.timezone!==LS&&e.set("tz",n.timezone),n.datePreset==="all"?e.set("range","all"):typeof n.datePreset=="number"?(n.datePreset!==28||n.dashboardTab)&&e.set("range",`${n.datePreset}d`):n.dateRange&&(e.set("from",n.dateRange.from),e.set("to",n.dateRange.to)),n.contextColumn!==ES&&e.set("ctx",n.contextColumn),n.comparison!==RS&&e.set("cmp",n.comparison),n.comparison==="custom"&&n.comparisonRange&&(e.set("cfrom",n.comparisonRange.from),e.set("cto",n.comparisonRange.to)),Object.keys(n.filters).length&&e.set("filters",JSON.stringify(VS(n.filters))),n.joinedDims.length&&e.set("jdims",JSON.stringify(n.joinedDims)),n.pivotDims.length&&e.set("pdims",JSON.stringify(n.pivotDims)),n.pivotMetrics.length&&e.set("pmetrics",JSON.stringify(n.pivotMetrics)),e.toString()}function HS(n,e){const t=new URLSearchParams(n),i={...e},a=t.get("view");a&&OS.includes(a)&&(i.view=a);const c=t.get("tab");c&&(i.dashboardTab=c);const f=t.get("model");f&&(i.model=f);const p=t.get("metric");p&&(i.selectedMetric=p);const m=t.get("grain");m&&TS.has(m)&&(i.grain=m);const g=t.get("tz");US(g)&&(i.timezone=g);const v=t.get("from"),x=t.get("to");typeof e.datePreset=="number"&&(i.dateRange=Ai(e.datePreset));const b=t.get("range"),w=Bv.find(M=>`${M.days}d`===b);wl(v)&&wl(x)&&Date.parse(v)<=Date.parse(x)?(i.dateRange={from:v,to:x},i.datePreset=void 0):b==="all"?(i.dateRange=void 0,i.datePreset="all"):w&&(i.dateRange=Ai(w.days),i.datePreset=w.days);const _=t.get("ctx");_&&AS.has(_)&&(i.contextColumn=_);const C=t.get("cmp");C&&BS.has(C)&&(i.comparison=C);const T=t.get("cfrom"),P=t.get("cto");i.comparison==="custom"&&wl(T)&&wl(P)&&Date.parse(T)<=Date.parse(P)&&(i.comparisonRange={from:T,to:P});const U=zS(bl(t.get("filters")));U&&(i.filters=U);const E=bl(t.get("jdims"));Wo(E)&&(i.joinedDims=[...new Set(E)]);const F=bl(t.get("pdims"));Wo(F)&&(i.pivotDims=F);const A=bl(t.get("pmetrics"));return Wo(A)&&(i.pivotMetrics=A),i}const Pv=k.createContext(null);function Qm(n){const e=WS(n);return e?`?${e}`:""}function Km(n,e,t,i){const a=HS(n,i),c=Ts(e,t,a.dashboardTab);return c?FS(a,c,n):a}const Jm=n=>n.startsWith("?")?n.slice(1):n;function GS({catalog:n,backend:e,dashboard:t,initialSearch:i,onSearchChange:a,children:c}){const f=k.useMemo(()=>Uv(n,t),[n,t]),[p,m]=k.useReducer(DS,void 0,()=>{const b=i??(typeof window>"u"?"":window.location.search);return Km(b,n,t,f)}),g=k.useRef(i);k.useEffect(()=>{i===void 0||i===g.current||(g.current=i,Jm(i)!==Jm(Qm(p))&&m({type:"hydrate",state:Km(i,n,t,f)}))},[i,p,n,t,f]);const v=k.useRef(a);v.current=a,k.useEffect(()=>{const b=Qm(p),w=v.current;if(w){w(b);return}typeof window>"u"||window.history.replaceState(null,"",`${window.location.pathname}${b}`)},[p]);const x=k.useMemo(()=>({state:p,dispatch:m,catalog:n,backend:e,initial:f,dashboard:t}),[p,n,e,f,t]);return u.jsx(Pv.Provider,{value:x,children:c})}function Dr(){const n=k.useContext(Pv);if(!n)throw new Error("useExplorer must be used within ExplorerProvider");return n}const Cs={active:0,listeners:new Set};function $v(){for(const n of Cs.listeners)n()}function YS(){Cs.active+=1,$v()}function QS(){Cs.active=Math.max(0,Cs.active-1),$v()}function zv(){return k.useSyncExternalStore(n=>(Cs.listeners.add(n),()=>Cs.listeners.delete(n)),()=>Cs.active>0,()=>!1)}const KS=80;function Bn(n,e){const[t,i]=k.useState({loading:!1}),a=k.useRef(0),c=e?JSON.stringify(e):null;return k.useEffect(()=>{if(!e){i({loading:!1});return}const f=++a.current;i(m=>({result:m.result,resultKey:m.resultKey,loading:!0}));const p=setTimeout(()=>{YS(),n.runQuery(e).then(m=>{f===a.current&&i({result:m,resultKey:c??void 0,loading:!1})}).catch(m=>{f===a.current&&i({loading:!1,error:m instanceof Error?m.message:String(m)})}).finally(()=>QS())},KS);return()=>clearTimeout(p)},[c,n]),{...t,queryKey:c??void 0}}function Vv(n,e,t=!0){k.useLayoutEffect(()=>{const i=n.current,a=e.current;if(!t||!i||!a)return;function c(){var _;if(!i||!a)return;const m=a.getBoundingClientRect(),g=(_=a.closest("[data-filter-strip]"))==null?void 0:_.getBoundingClientRect(),v=8,x=Math.max(v,Math.min(m.left,window.innerWidth-i.offsetWidth-v)),b=g?Math.max(g.top,Math.min(m.bottom,g.bottom)):m.bottom,w=Math.max(v,Math.min(b+4,window.innerHeight-v));i.style.left=`${x}px`,i.style.top=`${w}px`,i.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-w-v)}px`)}c();const f=new ResizeObserver(c);f.observe(i),f.observe(a);const p=a.closest("[data-filter-strip]");return p&&f.observe(p),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{f.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}})}const JS=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],qS=50,qm=200;function Zm(n,e){const[t,i]=k.useState(n);return k.useEffect(()=>{const a=setTimeout(()=>i(n),e);return()=>clearTimeout(a)},[n,e]),t}function Wv({dim:n,model:e,anchorRef:t,onClose:i}){var V,de;const{state:a,dispatch:c,backend:f,catalog:p,dashboard:m}=Dr(),g=k.useMemo(()=>Ts(p,m,a.dashboardTab),[p,m,a.dashboardTab]),v=a.filters[n.ref],[x,b]=k.useState((v==null?void 0:v.mode)??"include"),w=k.useMemo(()=>new Set((v==null?void 0:v.mode)!=="contains"?(v==null?void 0:v.values)??[]:[]),[v]),_=k.useRef(null);Vv(_,t);const C=k.useRef(null),T=k.useId(),[P,U]=k.useState(""),E=Zm(P,qm),F=(v==null?void 0:v.mode)==="contains"?v.pattern??"":"",[A,M]=k.useState(F),R=Zm(A,qm);k.useEffect(()=>{var q;const te=t.current;return(q=C.current)==null||q.focus(),()=>te==null?void 0:te.focus({preventScroll:!0})},[t]),k.useEffect(()=>{function te(ce){ce.key==="Escape"&&(ce.stopPropagation(),i())}function q(ce){_.current&&!_.current.contains(ce.target)&&i()}return document.addEventListener("keydown",te,!0),document.addEventListener("mousedown",q,!0),()=>{document.removeEventListener("keydown",te,!0),document.removeEventListener("mousedown",q,!0)}},[i]),k.useEffect(()=>{x==="contains"&&R!==F&&c({type:"setFilterPattern",dim:n.ref,pattern:R})},[R,x,n.ref,c]);const Y=p.models.find(te=>te.name===a.model)??e,z=((V=g==null?void 0:g.timeDimension)==null?void 0:V.ref)??((de=Y.timeDimension)==null?void 0:de.ref),Q=k.useMemo(()=>xc(p),[p]),W=k.useMemo(()=>{const te=[...(g==null?void 0:g.filters)??[],...Bs(a.filters,{timeRef:z,range:a.dateRange,excludeDim:n.ref,types:Q,dialect:p.dialect})];return E.trim()&&te.push(Ev(n.ref,E.trim(),p.dialect)),te},[g,a.filters,z,a.dateRange,n.ref,E,Q,p.dialect]),ne=x!=="contains",{result:X,loading:le,error:ie}=Bn(f,ne?jS(n.ref,W,qS,g==null?void 0:g.segments,g==null?void 0:g.usePreaggregations):null),ye=Ho(n.ref),re=k.useMemo(()=>X?X.rows.map(te=>{const q=te[ye];return q==null?tr:String(q)}):[],[X,ye]),O=!!X&&X.rows.length>0&&!X.columns.includes(ye),G=ne&&(le||O);function H(te){b(te),v&&c({type:"setFilterMode",dim:n.ref,mode:te}),te==="contains"&&M(F)}function N(te){var Me;if(te.key!=="Tab")return;const q=(Me=_.current)==null?void 0:Me.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!q||q.length===0)return;const ce=q[0],Ie=q[q.length-1];te.shiftKey&&document.activeElement===ce?(te.preventDefault(),Ie.focus()):!te.shiftKey&&document.activeElement===Ie&&(te.preventDefault(),ce.focus())}return Av.createPortal(u.jsxs("div",{ref:_,role:"dialog","aria-modal":"true","aria-labelledby":T,onKeyDown:N,className:"fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[u.jsxs("div",{id:T,className:"mb-2 flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:n.label}),u.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:i,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),u.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:JS.map(({mode:te,label:q})=>u.jsx("button",{type:"button","aria-pressed":x===te,onClick:()=>H(te),className:`px-1.5 py-1 text-center ${x===te?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:q},te))}),x==="contains"?u.jsx("input",{ref:C,type:"text","aria-label":`${n.label} contains`,placeholder:"Substring…",value:A,onChange:te=>M(te.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"text","aria-label":`Search ${n.label} values`,placeholder:"Search values…",value:P,onChange:te=>U(te.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),u.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${n.label} values`,children:ie?u.jsx("p",{className:"px-1 py-2 text-danger",children:ie}):G?u.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(te=>u.jsx("div",{className:"skeleton h-4 w-full"},te))}):re.length===0?u.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):re.map(te=>{const q=w.has(te);return u.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[u.jsx("input",{type:"checkbox",checked:q,onChange:()=>c({type:"toggleFilter",dim:n.ref,value:te,mode:x}),className:"size-3 shrink-0 accent-[var(--accent)]"}),u.jsx("span",{className:"min-w-0 break-words text-ink",children:as(te)})]},te)})})]}),u.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[u.jsx("button",{type:"button",onClick:()=>c({type:"removeFilterDim",dim:n.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),u.jsx("button",{type:"button",onClick:i,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]}),document.body)}function ZS({model:n}){const{catalog:e}=Dr(),t=[...n.dimensions,...pc(e,n.name)].filter(x=>x.type!=="time"),[i,a]=k.useState(!1),[c,f]=k.useState(null),p=k.useRef(null),m=k.useRef(null),g=k.useRef(null);Vv(m,g,i&&!c),k.useEffect(()=>{if(!i)return;function x(w){var _;w.key==="Escape"&&(v(),(_=g.current)==null||_.focus({preventScroll:!0}))}function b(w){var _,C;c||!((_=p.current)!=null&&_.contains(w.target))&&!((C=m.current)!=null&&C.contains(w.target))&&v()}return document.addEventListener("keydown",x,!0),document.addEventListener("mousedown",b,!0),()=>{document.removeEventListener("keydown",x,!0),document.removeEventListener("mousedown",b,!0)}},[i,c]);function v(){a(!1),f(null)}return t.length===0?null:u.jsxs("span",{ref:p,className:"relative inline-flex",children:[u.jsx("button",{ref:g,type:"button","aria-haspopup":"dialog","aria-expanded":i,onClick:()=>i?v():a(!0),className:"inline-flex h-7 shrink-0 items-center rounded-full border border-dashed border-line px-3 text-xs text-muted hover:border-faint hover:text-ink",children:"+ Filter"}),i&&!c?Av.createPortal(u.jsx("div",{ref:m,role:"menu","aria-label":"Add a filter for a dimension",className:"fixed z-30 max-h-[min(24rem,var(--filter-popover-height))] w-80 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl border border-line bg-surface p-1.5 text-2xs shadow-[var(--shadow)]",children:t.map(x=>u.jsx("button",{type:"button",role:"menuitem",onClick:()=>f(x),className:"block w-full break-words px-1.5 py-1 text-left text-muted hover:bg-surface-soft hover:text-ink",children:x.label},x.ref))}),document.body):null,i&&c?u.jsx(Wv,{dim:c,model:n,anchorRef:g,onClose:v}):null]})}function Oo(n,e){return n.includes(e)?n.filter(t=>t!==e):[...n,e]}function Xm({metric:n,selected:e,multiple:t,onSelect:i}){return u.jsxs("button",{type:"button","data-catalog-metric":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:i,className:"flex w-full items-center justify-between gap-2 border-l-2 px-3 py-1 text-left text-xs hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent border-l-transparent text-muted",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t?u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-accent",children:e?"✓":""}):null,u.jsx("span",{className:"truncate",children:n.label})]}),n.agg?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.agg}):null]})}function ey({dimension:n,selected:e,onSelect:t}){return u.jsxs("button",{type:"button","data-catalog-dimension":n.ref,"data-selected":e||void 0,"aria-pressed":e,title:n.description,onClick:t,className:"flex w-full items-center justify-between gap-2 border-l-2 border-l-transparent px-3 py-1 text-left text-xs text-muted hover:bg-surface-soft data-[selected=true]:border-l-accent data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:[u.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[u.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center",children:e?"✓":""}),u.jsx("span",{className:"truncate",children:n.label})]}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:n.type==="time"?"time":""})]})}function XS(){const{state:n,dispatch:e,catalog:t}=Dr(),i=t.models.find(m=>m.name===n.model),a=ki(t,n.model),c=pc(t,n.model),f=n.view==="pivot",p=n.pivotMetrics.length?n.pivotMetrics:n.selectedMetric?[n.selectedMetric]:[];return u.jsxs("nav",{"aria-label":"Semantic layer catalog",className:"flex flex-col gap-4 py-3 text-sm",children:[u.jsxs("section",{className:"px-3",children:[u.jsx("h2",{className:"mb-1 text-xs font-medium text-muted",children:"Model"}),u.jsx("select",{"aria-label":"Model",value:n.model,onChange:m=>{var x,b;const g=t.models.find(w=>w.name===m.target.value),v=((x=g==null?void 0:g.metrics[0])==null?void 0:x.ref)??((b=ki(t,m.target.value)[0])==null?void 0:b.ref)??"";e({type:"setModel",model:m.target.value,metric:v,grain:(g==null?void 0:g.defaultGrain)??"month"})},className:"w-full border border-line bg-surface px-2 py-1 text-xs text-ink",children:t.models.map(m=>u.jsx("option",{value:m.name,children:m.label},m.name))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Metrics"}),u.jsx("div",{children:((i==null?void 0:i.metrics)??[]).map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))}),a.length?u.jsxs(u.Fragment,{children:[u.jsx("h3",{className:"mb-1 mt-3 px-3 text-xs font-medium text-muted",children:"Shared metrics"}),u.jsx("div",{children:a.map(m=>u.jsx(Xm,{metric:m,selected:f?p.includes(m.ref):n.selectedMetric===m.ref,multiple:f,onSelect:()=>e(f?{type:"setPivotMetrics",metrics:Oo(p,m.ref)}:{type:"setMetric",metric:m.ref})},m.ref))})]}):null]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Dimensions"}),f?u.jsx("div",{children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsx(ey,{dimension:m,selected:n.pivotDims.includes(m.ref),onSelect:()=>e({type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)})},m.ref))}):u.jsx("ul",{className:"px-3 text-xs text-muted",children:((i==null?void 0:i.dimensions)??[]).map(m=>u.jsxs("li",{className:"flex items-center justify-between gap-2 py-0.5",title:m.description,children:[u.jsx("span",{className:"truncate",children:m.label}),u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:m.type==="time"?"time":""})]},m.ref))})]}),c.length?u.jsxs("section",{children:[u.jsx("h2",{className:"mb-1 px-3 text-xs font-medium text-muted",children:"Joined dimensions"}),c.filter(m=>f||m.type!=="time").map(m=>u.jsx(ey,{dimension:m,selected:(f?n.pivotDims:n.joinedDims).includes(m.ref),onSelect:()=>e(f?{type:"setPivotDims",dims:Oo(n.pivotDims,m.ref)}:{type:"setJoinedDims",dims:Oo(n.joinedDims,m.ref)})},m.ref))]}):null]})}class e_ extends k.Component{constructor(){super(...arguments);Dn(this,"state",{})}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?u.jsx("div",{className:"p-4",children:u.jsxs("div",{className:"border border-danger/40 bg-surface p-4",children:[u.jsx("p",{className:"text-sm font-semibold text-danger",children:"Something went wrong rendering this view."}),u.jsx("p",{className:"mt-1 break-words text-xs text-muted",children:this.state.error.message}),u.jsxs("div",{className:"mt-3 flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>this.setState({error:void 0}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Retry"}),u.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reload"})]})]})}):this.props.children}}const t_=[{key:"off",label:"Off"},{key:"previous",label:"Previous period"},{key:"year",label:"Previous year"},{key:"custom",label:"Custom range"}];function Hv({range:n,disabled:e,onChange:t,comparison:i,comparisonRange:a,onComparisonChange:c}){const f=k.useRef(null),[p,m]=k.useState((n==null?void 0:n.from)??""),[g,v]=k.useState((n==null?void 0:n.to)??""),[x,b]=k.useState((a==null?void 0:a.from)??""),[w,_]=k.useState((a==null?void 0:a.to)??"");function C(){f.current&&(f.current.open=!1)}function T(F,A){t(F,A),C()}function P(F){F==="custom"?c("custom",x&&w?{from:x,to:w}:void 0):c(F)}const U=n?`${n.from} → ${n.to}`:"All time",E=!n;return u.jsxs("details",{ref:f,className:"relative text-xs",onToggle:F=>{e&&(F.currentTarget.open=!1)},children:[u.jsxs("summary",{"aria-disabled":e||void 0,tabIndex:e?-1:void 0,onClick:F=>e&&F.preventDefault(),onKeyDown:F=>{e&&(F.key==="Enter"||F.key===" ")&&F.preventDefault()},className:`flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${e?"cursor-not-allowed opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:"Range"}),u.jsx("span",{className:"tnum",children:U}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-64 rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[u.jsx("button",{type:"button",onClick:()=>T(void 0),className:"w-full rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:"All time"}),u.jsx("div",{className:"grid grid-cols-2",children:Bv.map(F=>u.jsx("button",{type:"button",onClick:()=>T(Ai(F.days),F.days),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink",children:F.label},F.key))}),u.jsxs("div",{className:"mt-2 px-1 pb-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"From date",value:p,onChange:F=>m(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"To date",value:g,onChange:F=>v(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!p||!g,onClick:()=>T({from:p,to:g}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply custom range"})]}),u.jsxs("div",{className:"mt-1 px-1 pb-1","data-testid":"comparison-picker",children:[u.jsx("p",{className:"mb-1 px-1.5 text-2xs text-faint",children:"Compare to"}),u.jsx("div",{className:`grid grid-cols-2 ${E?"opacity-50":""}`,children:t_.map(F=>u.jsx("button",{type:"button",disabled:E,"data-comparison":F.key,"data-active":i===F.key||void 0,onClick:()=>P(F.key),className:"rounded-lg px-2.5 py-1.5 text-left text-xs text-muted hover:bg-surface-soft hover:text-ink data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:F.label},F.key))}),i==="custom"&&!E?u.jsxs("div",{className:"mt-1.5",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("input",{type:"date","aria-label":"Comparison from date",value:x,onChange:F=>b(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"}),u.jsx("span",{className:"text-faint",children:"→"}),u.jsx("input",{type:"date","aria-label":"Comparison to date",value:w,onChange:F=>_(F.target.value),className:"h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 text-xs text-ink"})]}),u.jsx("button",{type:"button",disabled:!x||!w,onClick:()=>c("custom",{from:x,to:w}),className:"mt-1.5 inline-flex h-7 w-full items-center justify-center rounded-full border border-accent bg-accent-soft text-xs font-medium text-accent hover:bg-accent hover:text-surface disabled:pointer-events-none disabled:opacity-50",children:"Apply comparison"})]}):null]})]})]})}function $d(n){const[e,t]=k.useState(!1),i=k.useRef(null);if(!("dim"in n))return u.jsxs("span",{"data-dimension":n.dimension,"data-value":n.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("span",{className:"truncate",children:[u.jsxs("span",{className:"text-faint",children:[n.dimensionLabel??n.dimension,":"]})," ",n.value]}),n.onRemove?u.jsx("button",{type:"button","aria-label":`Remove filter ${n.value}`,onClick:n.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"×"}):null]});const{dim:a,model:c,filter:f,onRemove:p}=n;return u.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":a.ref,"data-mode":f.mode,children:[u.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[u.jsxs("button",{ref:i,type:"button","aria-label":`Edit filter ${a.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>t(m=>!m),className:"min-w-0 truncate text-left hover:text-ink",children:[u.jsx("span",{className:"text-faint",children:a.label})," ",kb(f)]}),u.jsx("button",{type:"button","aria-label":`Remove filter ${a.label}`,onClick:p,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"×"})]}),e?u.jsx(Wv,{dim:a,model:c,anchorRef:i,onClose:()=>t(!1)}):null]})}function zd({grain:n,options:e,disabled:t,onChange:i}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Grain"}),u.jsx("select",{"aria-label":"Time grain",value:n,disabled:t,onChange:a=>i(a.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:e.map(a=>u.jsx("option",{value:a,children:Re(a)},a))})]})}const n_=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Moscow","Asia/Dubai","Asia/Kolkata","Asia/Singapore","Asia/Shanghai","Asia/Tokyo","Australia/Sydney"];let Sl=null;function ty(){if(Sl)return Sl;const n=typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[];return Sl=[...new Set(["UTC",...n])].sort(),Sl}function r_(n){if(!n)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}}function s_(n,e=new Date){var t;try{const c=(((t=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"shortOffset"}).formatToParts(e).find(g=>g.type==="timeZoneName"))==null?void 0:t.value)??"").match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(!c)return n==="UTC"?"+00:00":"";const f=c[1],p=c[2].padStart(2,"0"),m=c[3]??"00";return`${f}${p}:${m}`}catch{return""}}const ny="__search__";function i_({timezone:n,disabled:e,onChange:t}){const i=k.useId(),[a,c]=k.useState(!1),[f,p]=k.useState(""),m=k.useMemo(()=>{const b=new Set(n_);return n&&b.add(n),[...b]},[n]),g=k.useMemo(()=>a?ty():[],[a]);function v(b){const w=b.trim();r_(w)&&(t(w),c(!1),p(""))}if(a)return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsx("input",{type:"text",list:i,autoFocus:!0,"aria-label":"Search timezone",placeholder:"Region/City…",value:f,disabled:e,onChange:b=>{p(b.target.value),ty().includes(b.target.value)&&v(b.target.value)},onKeyDown:b=>{b.key==="Enter"?v(f):b.key==="Escape"&&(c(!1),p(""))},onBlur:()=>{c(!1),p("")},className:"h-7 w-36 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50"}),u.jsx("datalist",{id:i,children:g.map(b=>u.jsx("option",{value:b},b))})]});const x=s_(n);return u.jsxs("label",{className:"flex items-center gap-1.5 text-2xs text-faint",children:[u.jsx("span",{className:"hidden sm:inline",children:"Zone"}),u.jsxs("select",{"aria-label":"Timezone",value:n,disabled:e,onChange:b=>{b.target.value===ny?c(!0):t(b.target.value)},className:"h-7 max-w-[11rem] rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[m.map(b=>u.jsxs("option",{value:b,children:[b,b==="UTC"?"":x&&b===n?` (${x})`:""]},b)),u.jsx("option",{value:ny,children:"Search…"})]})]})}function o_(n,e,t){if(t==="count")return n.length;const i=n.map(c=>typeof c[e]=="number"?c[e]:Number(c[e])).filter(Number.isFinite);if(i.length===0)return Number.NaN;if(t==="min")return Math.min(...i);if(t==="max")return Math.max(...i);const a=i.reduce((c,f)=>c+f,0);return t==="avg"?a/i.length:a}const a_={sum:"Σ",avg:"avg",min:"min",max:"max",count:"n"};function Ri({columns:n,rows:e,loading:t,sortKey:i,sortDir:a,onSort:c,renderCell:f,pageSize:p=50,searchable:m,totals:g,stickyHeader:v=!0}){const[x,b]=k.useState(0),[w,_]=k.useState(""),C=k.useMemo(()=>{const M=w.trim().toLowerCase();return!m||!M?e:e.filter(R=>n.some(Y=>String(R[Y.key]??"").toLowerCase().includes(M)))},[e,n,w,m]),{paginate:T,pageCount:P,safePage:U,start:E,visibleRows:F}=Sb(C,x,p);k.useEffect(()=>{b(0)},[e,p,i,a,w]);const A=g&&n.some(M=>g[M.key]);return u.jsxs("div",{children:[m?u.jsxs("div",{className:"mb-2 flex items-center justify-end gap-2",children:[w?u.jsxs("span",{className:"whitespace-nowrap text-2xs text-faint tnum",children:[C.length.toLocaleString()," of ",e.length.toLocaleString()]}):null,u.jsx("input",{type:"search","aria-label":"Search rows",placeholder:"Search…",value:w,onChange:M=>_(M.target.value),className:"h-7 w-full max-w-64 rounded-full border border-line bg-surface px-2.5 text-xs text-ink placeholder:text-faint"})]}):null,u.jsx("div",{className:"overflow-auto border border-line bg-surface",children:u.jsxs("table",{className:"w-max min-w-full border-collapse text-xs","data-testid":"pivot-table",children:[u.jsx("thead",{children:u.jsx("tr",{className:"bg-surface-soft",children:n.map(M=>{const R=i===M.key;return u.jsx("th",{className:`max-w-80 whitespace-nowrap border-b border-line bg-surface-soft px-3 py-1.5 font-semibold text-faint ${M.numeric?"min-w-32 text-right":"min-w-40 text-left"} ${v?"sticky top-0 z-10":""}`,children:M.sortable&&c?u.jsxs("button",{type:"button",onClick:()=>c(M.key),"aria-label":`Sort by ${M.label}${R?`, currently ${a==="asc"?"ascending":"descending"}`:""}`,className:`table-sort inline-flex max-w-full items-center gap-1 whitespace-nowrap hover:text-ink ${R?"text-ink":""}`,children:[u.jsx("span",{className:"truncate",children:M.label}),u.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:R?a==="asc"?"▲":"▼":"↕"})]}):u.jsx("span",{className:"block truncate",title:M.label,children:M.label})},M.key)})})}),u.jsx("tbody",{children:t&&C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:"Loading…"})}):C.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:n.length,className:"px-3 py-6 text-center text-faint",children:w?"No matching rows":"No rows"})}):F.map((M,R)=>u.jsx("tr",{className:"hover:bg-surface-soft",children:n.map(Y=>{const z=f(Y,M[Y.key]);return u.jsx("td",{className:`max-w-80 whitespace-nowrap border-b border-line px-3 py-1.5 text-muted ${Y.numeric?"min-w-32 text-right font-mono tnum text-ink":"min-w-40"}`,children:u.jsx("span",{className:"block max-w-80 truncate",title:z,children:z})},Y.key)})},E+R))}),A&&C.length>0?u.jsx("tfoot",{children:u.jsx("tr",{className:"bg-surface-soft","data-testid":"table-totals",children:n.map(M=>{const R=g==null?void 0:g[M.key];if(!R)return u.jsx("td",{className:"border-t border-line px-3 py-1.5"},M.key);const Y=o_(C,M.key,R),z=R==="count"?Y.toLocaleString():Number.isFinite(Y)?f(M,Y):"—";return u.jsxs("td",{"data-total":R,className:`whitespace-nowrap border-t border-line px-3 py-1.5 font-mono tnum font-medium text-ink ${M.numeric?"text-right":"text-left"}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-1 text-2xs text-faint",children:a_[R]}),z]},M.key)})})}):null]})}),T?u.jsxs("div",{"data-testid":"pivot-table-pager",className:"mt-1.5 flex items-center justify-between gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"tnum",children:[E+1,"–",Math.min(E+p,C.length)," of ",C.length.toLocaleString(),t?" · Updating…":""]}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("button",{type:"button",disabled:U===0,onClick:()=>b(M=>Math.max(0,M-1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),u.jsx("button",{type:"button",disabled:U>=P-1,onClick:()=>b(M=>Math.min(P-1,M+1)),className:"table-pager-button px-2 py-1 text-muted hover:text-ink disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})]}):null]})}function l_(n,e){const t=e.filter(i=>n.some(a=>a.ref===i));return t.length?t:n.slice(0,6).map(i=>i.ref)}function c_(){var U,E;const[n,e]=k.useState(!1),{state:t,catalog:i,backend:a,dashboard:c}=Dr(),f=i.models.find(F=>F.name===t.model),p=k.useMemo(()=>Ts(i,c,t.dashboardTab),[i,c,t.dashboardTab]),m=(p==null?void 0:p.dimensions)??(f==null?void 0:f.dimensions)??[],g=l_(m,t.pivotDims),v=((U=p==null?void 0:p.timeDimension)==null?void 0:U.ref)??((E=f==null?void 0:f.timeDimension)==null?void 0:E.ref),x=k.useMemo(()=>xc(i),[i]),b=k.useMemo(()=>[...(p==null?void 0:p.filters)??[],...Bs(t.filters,{timeRef:v,range:t.dateRange,types:x,dialect:i.dialect})],[p,t.filters,v,t.dateRange,x,i.dialect]),w=n&&f?IS({dimensions:g,metrics:[]},b,50,p==null?void 0:p.segments,p==null?void 0:p.usePreaggregations):null,{result:_,loading:C,error:T}=Bn(a,w),P=[...g.map(F=>{var A;return{key:Ho(F),label:((A=m.find(M=>M.ref===F))==null?void 0:A.label)??Re(F)}})];return u.jsxs("section",{"data-testid":"row-preview-drawer","data-open":n||void 0,className:"absolute inset-x-0 bottom-0 z-30 border-t border-line bg-surface shadow-[0_-8px_24px_rgba(0,0,0,0.16)]",children:[u.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>e(F=>!F),className:"flex h-8 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink",children:[u.jsx("span",{children:"Rows preview"}),u.jsx("span",{"aria-hidden":"true",children:n?"▼":"▲"})]}),n?u.jsx("div",{className:"max-h-[45vh] overflow-auto border-t border-line",children:T?u.jsx("p",{role:"alert",className:"p-3 text-xs text-danger",children:T}):P.length===0?u.jsx("p",{className:"p-3 text-xs text-faint",children:"No preview fields are available."}):u.jsx(Ri,{columns:P,rows:(_==null?void 0:_.rows)??[],loading:C,pageSize:10,renderCell:(F,A)=>A==null||A===""?"—":String(A)})}):null]})}function mf({tone:n,title:e,message:t}){const i=n==="danger";return u.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${i?"border-danger/40":"border-line"}`,"data-state":n,role:i?"alert":"status","aria-live":i?"assertive":"polite",children:u.jsxs("div",{className:"max-w-md",children:[n==="loading"?u.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?u.jsx("h3",{className:`text-sm font-semibold ${i?"text-danger":"text-ink"}`,children:e}):null,u.jsx("p",{className:`mt-1 text-xs ${i?"text-danger":"text-muted"}`,children:t})]})})}function bc({title:n="Loading",message:e="Loading metrics…"}){return u.jsx(mf,{tone:"loading",title:n,message:e})}function er({title:n="No results",message:e}){return u.jsx(mf,{tone:"muted",title:n,message:e})}function Li({title:n="Query failed",message:e}){return u.jsx(mf,{tone:"danger",title:n,message:e})}function xd({status:n}){const e=n==="ok"?"bg-success":n==="loading"?"bg-faint animate-pulse":"bg-line";return u.jsx("span",{"aria-hidden":"true",className:`inline-block size-2 rounded-full ${e}`})}const Gv="sidemantic-theme";function yf(){var e;const n=localStorage.getItem(Gv);return n==="light"||n==="dark"?n:(e=window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function Yv(n){document.documentElement.dataset.theme=n}function u_(){Yv(yf())}function d_(){const n=yf()==="dark"?"light":"dark";return localStorage.setItem(Gv,n),Yv(n),n}function Zo(){const[n,e]=k.useState(yf());return u.jsx("button",{type:"button","aria-label":n==="dark"?"Switch to light theme":"Switch to dark theme",title:n==="dark"?"Light theme":"Dark theme",onClick:()=>e(d_()),className:"grid size-7 place-items-center border border-line bg-surface text-faint hover:border-faint hover:text-ink",children:n==="dark"?u.jsxs("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u.jsx("circle",{cx:"12",cy:"12",r:"4"}),u.jsx("path",{d:"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}):u.jsx("svg",{viewBox:"0 0 24 24",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u.jsx("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"})})})}const To=[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"}];function Qv({view:n,onChange:e}){const t=k.useRef(null);function i(a){const c=Math.max(0,To.findIndex(p=>p.key===n)),f=To[(c+a+To.length)%To.length];e(f.key),window.requestAnimationFrame(()=>{var p,m;return(m=(p=t.current)==null?void 0:p.querySelector(`[data-view="${f.key}"]`))==null?void 0:m.focus()})}return u.jsx("div",{ref:t,role:"tablist","aria-label":"View",className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:To.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":n===a.key,tabIndex:n===a.key?0:-1,"data-view":a.key,"data-selected":n===a.key||void 0,onClick:()=>e(a.key),onKeyDown:c=>{c.key==="ArrowLeft"?(c.preventDefault(),i(-1)):c.key==="ArrowRight"&&(c.preventDefault(),i(1))},className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}const Kv="dashboard_filters",Jv="dashboard_ranges",qv="dashboard_filter_sources",Zv="dashboard_range_sources",Xv="dashboard_chart_filters",e0="dashboard_chart_ranges";function f_(n,e){if(n==="/explore")return!0;const t=new URLSearchParams(e).get("view");return t==="explore"||t==="pivot"}function gf(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.select;return t===!0?!0:t?!((a=t.fields)!=null&&a.length)||t.fields.includes(e):!1}function h_(n){return(n.query.dimensions??[]).find(e=>gf(n,e))}function p_(n,e){var i,a;if(!e||!(n.query.dimensions??[]).includes(e))return!1;const t=(i=n.interactions)==null?void 0:i.brush;return t===!0?!0:!t||t.channel&&t.channel!=="x"?!1:!((a=t.fields)!=null&&a.length)||t.fields.includes(e)}function dc(n){return n==null?tr:String(n)}function m_(n){let e=n.trim().replaceAll(/[^A-Za-z0-9_]/g,"_").replaceAll(/^_+|_+$/g,"")||"field";return/^\d/.test(e)&&(e=`field_${e}`),e}function br(n,e){const t=Ho(n),i=m_(n);return i!==t&&e.includes(i)?i:e.includes(t)?t:e.find(a=>a.endsWith(t))??t}function y_(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return Array.isArray(e)&&e.length?e:typeof e=="string"?[e]:n.query.metrics.slice(0,1)}function g_(n,e,t,i,a){return Object.fromEntries([[e,t],...i.map((c,f)=>[c,a[f]])].filter(c=>typeof c[1]=="string"&&gf(n,c[0])))}function v_(n,e,t){return[e,...t].some(i=>gf(n,i))}const x_=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Fs(n){const e=n.lastIndexOf("__");if(e<0)return null;const t=n.slice(e+2);return x_.has(t)?{baseDimension:n.slice(0,e),grain:t}:null}function t0(n,e){var c,f;if(n.type&&n.type!=="auto")return n.type;const t=((c=n.encoding)==null?void 0:c.x)??((f=n.query.dimensions)==null?void 0:f[0])??"",i=Fs(t);return(e[t]??(i?e[i.baseDimension]:void 0))==="time"?"line":"bar"}function n0(n,e){const t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/.test(n)?`${n}Z`:n,i=new Date(t);return Number.isFinite(i.getTime())?(e==="second"?i.setUTCSeconds(i.getUTCSeconds()+1):e==="minute"?i.setUTCMinutes(i.getUTCMinutes()+1):e==="hour"?i.setUTCHours(i.getUTCHours()+1):e==="day"?i.setUTCDate(i.getUTCDate()+1):e==="week"?i.setUTCDate(i.getUTCDate()+7):e==="month"?i.setUTCMonth(i.getUTCMonth()+1):e==="quarter"?i.setUTCMonth(i.getUTCMonth()+3):e==="year"&&i.setUTCFullYear(i.getUTCFullYear()+1),/^\d{4}-\d{2}-\d{2}$/.test(n)?i.toISOString().slice(0,10):i.toISOString()):null}function r0(n,e,t){const i=Fs(n);if(i){const a=n0(e.to,i.grain);return a?`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} < ${Kn(a,t)}`:`${i.baseDimension} >= ${Kn(e.from,t)} AND ${i.baseDimension} <= ${Kn(e.to,t)}`}return`${n} >= ${Kn(e.from,t)} AND ${n} <= ${Kn(e.to,t)}`}function b_(n,e,t,i){const a=Fs(n);return a?e===tr?[`${a.baseDimension} IS NULL`]:[r0(n,{from:e,to:e},i)]:Rv({[n]:{mode:"include",values:[e]}},{types:t,dialect:i})}function fc(n,e){const t=n.tabs.find(i=>i.charts.includes(e));return`${(t==null?void 0:t.id)??"dashboard"}:${e.id}`}function vf(n,e,t){var f,p,m,g,v;const i=((p=(f=n.defaults)==null?void 0:f.interactions)==null?void 0:p.scope)??"dashboard";if(i==="dashboard")return t;if(i==="chart"){const x=fc(n,e);return{filters:{...Object.fromEntries(Object.entries(t.filters).filter(([b])=>t.filterSources[b]===x)),...((m=t.chartFilters)==null?void 0:m[x])??{}},ranges:{...Object.fromEntries(Object.entries(t.ranges).filter(([b])=>t.rangeSources[b]===x)),...((g=t.chartRanges)==null?void 0:g[x])??{}}}}const a=((v=n.tabs.find(x=>x.charts.includes(e)))==null?void 0:v.charts)??[e],c=new Set(a.flatMap(x=>x.query.dimensions??[]));return{filters:Object.fromEntries(Object.entries(t.filters).filter(([x])=>c.has(x))),ranges:Object.fromEntries(Object.entries(t.ranges).filter(([x])=>c.has(x)))}}function w_(n,e,t,i,a={},c={filterSources:{},rangeSources:{}},f){var w,_,C,T,P,U;const p=vf(n,e,{filters:t,ranges:a,...c}),m=((w=e.encoding)==null?void 0:w.x)??((_=e.query.dimensions)==null?void 0:_[0])??"",g=e.query.order_by??e.query.orderBy,v=m&&["line","area"].includes(t0(e,i))?[`${m} ASC`]:void 0,x={metrics:e.query.metrics,dimensions:e.query.dimensions,filters:[...e.query.filters??[],...Object.entries(p.filters).flatMap(([E,F])=>b_(E,F,i,f)),...Object.entries(p.ranges).map(([E,F])=>r0(E,F,f))],segments:e.query.segments,orderBy:g??v,limit:e.query.limit??500},b=e.query.use_preaggregations??e.query.usePreaggregations??((T=(C=n.defaults)==null?void 0:C.query)==null?void 0:T.use_preaggregations)??((U=(P=n.defaults)==null?void 0:P.query)==null?void 0:U.usePreaggregations);return b!==void 0&&(x.usePreaggregations=b),x}function ry(n){const e=/^(\d{4}-\d{2}-\d{2})/.exec(n);return(e==null?void 0:e[1])??null}function sy(n,e){const t=ry(e.from);if(!t)return null;const i=Fs(n);if(!i){const f=ry(e.to);return f?{from:t,to:f}:null}const a=n0(e.to,i.grain);if(!a)return null;const c=new Date(a);return c.setUTCMilliseconds(c.getUTCMilliseconds()-1),{from:t,to:c.toISOString().slice(0,10)}}function S_(n,e,t,i={},a){var F,A,M;const c=(F=e.encoding)==null?void 0:F.y,f=(Array.isArray(c)?c[0]:c)??e.query.metrics[0]??"",p=e.query.dimensions??[],m=a==null?void 0:a.graphMetrics.find(R=>R.ref===f),g=f.includes(".")?f.split(".")[0]:((A=p[0])==null?void 0:A.split(".")[0])??(m==null?void 0:m.ownerModel)??(m==null?void 0:m.model)??"",v=vf(n,e,t),x=Object.entries(v.filters).flatMap(([R,Y])=>{const z=Fs(R);return z?[{dimension:R,value:Y,baseDimension:z.baseDimension}]:[]}),b=Object.fromEntries(Object.entries(v.filters).flatMap(([R,Y])=>{const z=Fs(R);return z?Y===tr?[[z.baseDimension,[Y]]]:[]:[[R,[Y]]]})),w=new URLSearchParams({view:"explore",model:g,metric:f});Object.keys(b).length&&w.set("filters",JSON.stringify(b));const _=((M=e.encoding)==null?void 0:M.x)??p[0],C=x.find(({baseDimension:R,value:Y})=>Y!==tr&&(!g||R.startsWith(`${g}.`))),T=Object.keys(v.ranges),P=[_,...T].find((R,Y,z)=>{if(!R||z.indexOf(R)!==Y||!v.ranges[R])return!1;const Q=Fs(R);return((i[R]??(Q?i[Q.baseDimension]:void 0))==="time"||!!Q)&&(!g||R.startsWith(`${g}.`))}),U=P?v.ranges[P]:void 0,E=C?sy(C.dimension,{from:C.value,to:C.value}):P&&U?sy(P,U):null;return E&&(w.set("from",E.from),w.set("to",E.to)),`/explore?${w}`}function __(n,e,t,i){const a=new Map;for(const c of n){const f=Number(c[t]);if(!Number.isFinite(f))continue;const p=i.map(b=>dc(c[b])),m=JSON.stringify(p),g=p.length?p.map(as).join(" · "):"Current",v=a.get(m)??{label:g,filterValues:p,data:[]},x=dc(c[e]);v.data.push({label:as(x),filterValue:x,value:f}),a.set(m,v)}return[...a.values()]}function N_(n,e,t,i){const a=[],c=new Set,f=new Map;for(const p of n){if(p[e]==null)continue;const m=String(p[e]),g=Number(p[t]);if(!Number.isFinite(g))continue;c.has(m)||(c.add(m),a.push(m));const v=i.map(_=>dc(p[_])),x=JSON.stringify(v),b=v.length?v.map(as).join(" · "):"Current",w=f.get(x)??{label:b,values:new Map};w.values.set(m,g),f.set(x,w)}return[...f.values()].map(p=>({label:p.label,points:a.map(m=>({x:m,y:p.values.get(m)??Number.NaN}))}))}function xf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n))e.has(i)&&typeof a=="string"&&(t[i]=a);return t}function bf(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return{};const t={};for(const[i,a]of Object.entries(n)){if(!e.has(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const c=a;typeof c.from=="string"&&typeof c.to=="string"&&(t[i]={from:c.from,to:c.to})}return t}function hc(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(t=>e.has(t[0])&&typeof t[1]=="string"))}function s0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=xf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function i0(n,e){return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).flatMap(([t,i])=>{const a=e.get(t);if(!a)return[];const c=bf(i,a);return Object.keys(c).length?[[t,c]]:[]}))}function o0(n){return new Set(n.tabs.flatMap(e=>e.charts.flatMap(t=>t.query.dimensions??[])))}function a0(n){return new Map(n.tabs.flatMap(e=>e.charts.map(t=>[fc(n,t),new Set(t.query.dimensions??[])])))}function j_(n,e){var _;const t=new URLSearchParams(n),i=((_=e.tabs[0])==null?void 0:_.id)??"",a=t.get("tab"),c=e.tabs.some(C=>C.id===a)?a??i:i;let f,p,m,g,v,x;try{f=JSON.parse(t.get(Kv)??"{}")}catch{f={}}try{p=JSON.parse(t.get(Jv)??"{}")}catch{p={}}try{m=JSON.parse(t.get(qv)??"{}")}catch{m={}}try{g=JSON.parse(t.get(Zv)??"{}")}catch{g={}}try{v=JSON.parse(t.get(Xv)??"{}")}catch{v={}}try{x=JSON.parse(t.get(e0)??"{}")}catch{x={}}const b=o0(e),w=a0(e);return{tab:c,filters:xf(f,b),ranges:bf(p,b),filterSources:hc(m,b),rangeSources:hc(g,b),chartFilters:s0(v,w),chartRanges:i0(x,w)}}function k_(n,e){var c;const t=new URLSearchParams;n.tab&&n.tab!==((c=e.tabs[0])==null?void 0:c.id)&&t.set("tab",n.tab),Object.keys(n.filters).length&&t.set(Kv,JSON.stringify(n.filters)),Object.keys(n.ranges).length&&t.set(Jv,JSON.stringify(n.ranges));const i=Object.fromEntries(Object.entries(n.filterSources).filter(([f])=>f in n.filters)),a=Object.fromEntries(Object.entries(n.rangeSources).filter(([f])=>f in n.ranges));return Object.keys(i).length&&t.set(qv,JSON.stringify(i)),Object.keys(a).length&&t.set(Zv,JSON.stringify(a)),Object.keys(n.chartFilters??{}).length&&t.set(Xv,JSON.stringify(n.chartFilters)),Object.keys(n.chartRanges??{}).length&&t.set(e0,JSON.stringify(n.chartRanges)),t.toString()}function l0(n){return`sidemantic-dashboard-views:${`${n.schema??"sidemantic.dashboard.v1"}:${n.title}`}`}function I_(n){try{const e=JSON.parse(localStorage.getItem(l0(n))??"[]");if(!Array.isArray(e))return[];const t=o0(n);return e.flatMap(i=>{var m;if(typeof i!="object"||i===null||Array.isArray(i))return[];const a=i;if(typeof a.name!="string"||!a.name.trim())return[];if(typeof a.state!="object"||a.state===null||Array.isArray(a.state))return[];const c=a.state,f=n.tabs.some(g=>g.id===c.tab)?String(c.tab):((m=n.tabs[0])==null?void 0:m.id)??"",p=a0(n);return[{name:a.name,state:{tab:f,filters:xf(c.filters,t),ranges:bf(c.ranges,t),filterSources:hc(c.filterSources,t),rangeSources:hc(c.rangeSources,t),chartFilters:s0(c.chartFilters,p),chartRanges:i0(c.chartRanges,p)}}]})}catch{return[]}}function M_(n,e){try{return localStorage.setItem(l0(n),JSON.stringify(e)),!0}catch{return!1}}function iy(n){if(n==null)return"";let e=String(n);return typeof n!="number"&&typeof n!="bigint"&&/^[\s\u0000-\u001f]*[=+@-]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function D_(n,e){return[n.map(iy).join(","),...e.map(t=>n.map(i=>iy(t[i])).join(","))].join(`\r +`)}function C_(n){var e;return((e=n.label)==null?void 0:e.trim())||n.id}function bd(n,e){return`${n} ${e}${n===1?"":"s"}`}function F_(){const{catalog:n,dispatch:e}=Dr(),t=i=>{const a=n.models.find(p=>p.name===i),c=Lv(a,n),f=(a==null?void 0:a.defaultGrain)??"month";e({type:"setModel",model:i,metric:c,grain:f}),e({type:"setView",view:"explore"})};return u.jsxs("div",{className:"mx-auto w-full max-w-5xl p-6",children:[u.jsxs("div",{className:"mb-4",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Explore"}),u.jsxs("p",{className:"text-2xs text-muted",children:[bd(n.models.length,"model")," · pick one to explore"]})]}),u.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.models.map(i=>u.jsxs("button",{type:"button","data-testid":"explore-card","data-model":i.name,onClick:()=>t(i.name),className:"flex min-h-32 flex-col gap-2 rounded-xl border border-line bg-surface p-4 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-sm font-medium text-ink",children:i.label}),i.timeDimension?u.jsx("span",{className:"shrink-0 text-2xs text-faint",children:"time series"}):null]}),i.description?u.jsx("p",{className:"line-clamp-2 text-2xs text-muted",children:i.description}):null,u.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:i.metrics.slice(0,3).map(a=>u.jsx("span",{className:"rounded-full bg-surface-soft px-2 py-0.5 text-2xs text-muted",children:a.label},a.ref))}),u.jsxs("div",{className:"text-2xs text-faint",children:[bd(i.metrics.length,"metric")," · ",bd(i.dimensions.length,"dimension")]})]},i.name))})]})}const O_="600px";function T_(n){for(let e=n.parentElement;e;e=e.parentElement){const t=getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")return e}return null}function A_(n,e,t=O_){if(typeof IntersectionObserver>"u")return e(),()=>{};const i=new IntersectionObserver(a=>{a.some(c=>c.isIntersecting)&&(i.disconnect(),e())},{root:T_(n),rootMargin:t});return i.observe(n),()=>i.disconnect()}const B_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function c0({dimension:n,title:e,metricLabel:t,rows:i,selectedValues:a=[],loading:c,formatMetric:f,onToggle:p,contextColumn:m="none",contextOptions:g,onContextColumn:v,collapsedLimit:x=6,expanded:b=!1,onExpandedChange:w,containerRef:_}){const C=new Set(a),T=b?i:i.slice(0,x),P=Math.max(1,...T.map(A=>Math.abs(A.metric))),U=b||i.length>x,E=m!=="none",F=E?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return u.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":n,"data-expanded":b||void 0,"aria-label":`${e}, ranked by ${t}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[u.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[u.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[u.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),u.jsxs("p",{className:"sr-only",children:["Ranked by ",t]})]}),g&&v?u.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:g.map(A=>u.jsx("button",{type:"button",title:A.title,"aria-pressed":m===A.key,"data-context":A.key,"data-active":m===A.key||void 0,onClick:()=>v(A.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:A.label},A.key))}):null]}),u.jsx("div",{"data-testid":"leaderboard-rows",children:c&&i.length===0?u.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(A=>u.jsx("div",{className:"skeleton h-5 w-full"},A))}):i.length===0?u.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):T.map(A=>{var z,Q,W;const M=A.metric<0?"negative":"positive",R=C.has(A.value),Y=`${Math.round(Math.abs(A.metric)/P*100)}%`;return u.jsxs("button",{type:"button","data-dimension":n,"data-value":A.value,"data-selected":R||void 0,"data-tone":M,onClick:()=>p==null?void 0:p(A.value),"aria-pressed":R,className:`leaderboard-row relative grid w-full ${F} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[u.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${M==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:Y}}),u.jsx("span",{className:"relative min-w-0 truncate text-muted",children:as(A.value)}),u.jsx("strong",{className:"relative tnum font-semibold text-ink",children:f(A.metric)}),E?u.jsx("span",{"data-testid":"leaderboard-context","data-tone":((z=A.context)==null?void 0:z.tone)??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${B_[((Q=A.context)==null?void 0:Q.tone)??"neutral"]}`,children:((W=A.context)==null?void 0:W.label)??"—"}):null]},`${n}:${A.value}`)})}),U&&!c?u.jsx("button",{type:"button","data-action":b?"leaderboard-back":"leaderboard-expand","aria-expanded":b,onClick:()=>w==null?void 0:w(!b),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:b?"← All dimensions":`Expand table (${i.length})`}):null]})}const E_=[{key:"none",label:"—",title:"No context column"},{key:"pctTotal",label:"%",title:"Share of total"},{key:"delta",label:"Δ",title:"Absolute change vs comparison period"},{key:"deltaPct",label:"Δ%",title:"Percent change vs comparison period"}],R_=[],L_=[];function U_({dim:n,model:e,timeDimensionRef:t,rankMetric:i,contextColumn:a,metricTotal:c,comparisonRange:f,baseFilters:p=R_,baseSegments:m=L_,usePreaggregations:g,limit:v=6,expanded:x=!1,onExpandedChange:b}){var te;const{state:w,dispatch:_,backend:C,catalog:T}=Dr(),P=k.useRef(null),[U,E]=k.useState(!1);k.useEffect(()=>{if(!(U||!P.current))return A_(P.current,()=>E(!0))},[U]);const F=t??((te=e.timeDimension)==null?void 0:te.ref),A=k.useMemo(()=>xc(T),[T]),M=k.useMemo(()=>[...p,...Bs(w.filters,{timeRef:F,range:w.dateRange,excludeDim:n.ref,types:A,dialect:T.dialect})],[p,w.filters,F,w.dateRange,n.ref,A,T.dialect]),{result:R,loading:Y,error:z}=Bn(C,U?Ym(i.ref,n.ref,M,v,m,g):null),Q=w.filters[n.ref],W=(Q==null?void 0:Q.mode)==="include"?Q.values:void 0,ne=[i.ref,n.ref],X=Tt(n.ref,ne),le=a==="delta"||a==="deltaPct",ie=k.useMemo(()=>{if(!R||!R.columns.includes(X))return null;const q=[];let ce=!1;for(const Me of R.rows){const Ue=Me[X];Ue==null?ce=!0:q.push(String(Ue))}const Ie=[];return q.length&&Ie.push(`CAST(${n.ref} AS VARCHAR) IN (${q.map(Me=>Kn(Me,T.dialect)).join(", ")})`),ce&&Ie.push(`${n.ref} IS NULL`),Ie.length?Ie.length===1?Ie[0]:`(${Ie.join(" OR ")})`:null},[R,X,n.ref,T.dialect]),ye=k.useMemo(()=>le&&f&&F&&ie?[...p,...Bs(w.filters,{timeRef:F,range:f,excludeDim:n.ref,types:A,dialect:T.dialect}),ie]:null,[le,f,F,w.filters,n.ref,A,T.dialect,ie,p]),re=Bn(C,ye?Ym(i.ref,n.ref,ye,v,m,g):null),O=Tt(i.ref,ne),G=!!R&&R.rows.length>0&&!R.columns.includes(O),H=k.useMemo(()=>{const q=new Map;if(!re.result||!re.result.columns.includes(O))return q;for(const ce of re.result.rows){const Ie=ce[X],Me=Ie==null?tr:String(Ie);q.set(Me,Number(ce[O]))}return q},[re.result,X,O]),N={format:i.format,type:i.type};function V(q,ce){switch(a){case"pctTotal":return c===void 0?void 0:_b(ce,c);case"delta":return Nb(ce,H.get(q),N);case"deltaPct":return jb(ce,H.get(q));default:return}}const de=R&&!G?R.rows.map(q=>{const ce=q[X],Ie=ce==null?tr:String(ce),Me=Number(q[O]??0);return{value:Ie,metric:Me,context:V(Ie,Me)}}):[];return z?u.jsx(Li,{title:n.label,message:z}):u.jsx(c0,{dimension:n.ref,title:n.label,metricLabel:i.label,rows:de,containerRef:P,loading:!U||Y||G,selectedValues:W,formatMetric:q=>Gt(q,N),onToggle:q=>_({type:"toggleFilter",dim:n.ref,value:q}),contextColumn:a,contextOptions:E_,onContextColumn:q=>_({type:"setContextColumn",column:q}),collapsedLimit:v,expanded:x,onExpandedChange:b})}function Cr(){const[n,e]=k.useState(null);return{tip:n,handlers:i=>({onMouseEnter:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseMove:a=>e({content:i,x:a.clientX,y:a.clientY}),onMouseLeave:()=>e(null)})}}function sr({tip:n,position:e="fixed",offset:t=12,className:i,style:a}){return n?u.jsx("div",{role:"tooltip",style:{position:e,left:n.x+t,top:n.y+t,pointerEvents:"none",zIndex:50,...a},className:i||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:n.content}):null}function us({title:n,rows:e}){return u.jsxs("div",{className:"min-w-28",children:[n?u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:n}):null,e.map((t,i)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[t.swatch?u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-sm",style:{background:t.swatch}}):null,t.label]}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:t.value})]},i))]})}function u0({values:n,labels:e,height:t=44,ariaLabel:i,formatValue:a=p=>p.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:c,onBrush:f}){const p=k.useRef(null),m=k.useId(),g=k.useRef(null),v=k.useRef(null),[x,b]=k.useState(200),[w,_]=k.useState(null),[C,T]=k.useState(null),[P,U]=k.useState(null);k.useEffect(()=>{const H=p.current;if(!H||typeof ResizeObserver>"u")return;const N=new ResizeObserver(V=>{for(const de of V)b(Math.max(40,de.contentRect.width))});return N.observe(H),()=>N.disconnect()},[]);const E=n.map((H,N)=>({index:N,value:H})).filter(H=>Number.isFinite(H.value));if(E.length<2)return u.jsx("svg",{ref:g,role:"img","aria-label":i||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${x} ${t}`});const F=3,A=Math.min(...E.map(H=>H.value)),R=Math.max(...E.map(H=>H.value))-A||1,Y=E.map((H,N)=>({...H,x:F+N/(E.length-1)*(x-F*2),y:F+(1-(H.value-A)/R)*(t-F*2)})),z=Y.map(({x:H,y:N})=>`${H.toFixed(1)},${N.toFixed(1)}`).join(" L "),Q=`M ${Y[0].x.toFixed(1)},${t-F} L ${z} L ${Y.at(-1).x.toFixed(1)},${t-F} Z`,W=Y.at(-1),ne=i||`Trend of ${E.length} points, latest ${a(W.value)}`;function X(H){var V;const N=(V=g.current)==null?void 0:V.getBoundingClientRect();return N?Math.max(F,Math.min(x-F,(H.clientX-N.left)/N.width*x)):F}function le(H){return Math.max(0,Math.min(Y.length-1,Math.round((H-F)/(x-F*2)*(Y.length-1))))}function ie(H){const N=X(H),V=le(N),de=Y[V];_(V),U({content:`${e!=null&&e[de.index]?`${e[de.index]}: `:""}${a(de.value)}`,x:H.clientX,y:H.clientY}),c==null||c({index:de.index,label:e==null?void 0:e[de.index],value:de.value}),v.current!==null&&T({a:v.current,b:N})}function ye(H){if(!f||!(e!=null&&e.length))return;H.currentTarget.setPointerCapture(H.pointerId);const N=X(H);v.current=N,T({a:N,b:N})}function re(H){if(v.current===null||!f||!(e!=null&&e.length))return;H.currentTarget.hasPointerCapture(H.pointerId)&&H.currentTarget.releasePointerCapture(H.pointerId);const N=X(H);if(Math.abs(N-v.current)>6){const V=Y[le(Math.min(v.current,N))],de=Y[le(Math.max(v.current,N))];f({from:e[V.index],to:e[de.index]})}v.current=null,T(null)}function O(){_(null),U(null),c==null||c(null),v.current===null&&T(null)}const G=w===null?null:Y[w];return u.jsxs("span",{ref:p,className:"relative block w-full",children:[u.jsxs("svg",{ref:g,role:"img","aria-label":ne,className:`h-11 w-full overflow-hidden text-chart-primary ${f?"touch-none select-none":""}`,viewBox:`0 0 ${x} ${t}`,preserveAspectRatio:"none",onPointerMove:ie,onPointerDown:ye,onPointerUp:re,onPointerCancel:O,onPointerLeave:O,onDoubleClick:()=>f==null?void 0:f(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),u.jsx("path",{d:Q,fill:`url(#${m})`}),u.jsx("path",{d:`M ${z}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),C?u.jsx("rect",{x:Math.min(C.a,C.b),y:0,width:Math.abs(C.b-C.a),height:t,fill:"currentColor",opacity:.12}):null,G?u.jsxs(u.Fragment,{children:[u.jsx("line",{x1:G.x,x2:G.x,y1:0,y2:t,stroke:"currentColor",strokeWidth:1,opacity:.45}),u.jsx("circle",{cx:G.x,cy:G.y,r:2.5,fill:"currentColor"})]}):u.jsx("circle",{cx:W.x,cy:W.y,r:2.25,fill:"currentColor"})]}),u.jsx(sr,{tip:P})]})}const P_={positive:"text-success",negative:"text-danger",neutral:"text-faint"},$_={positive:"▲",negative:"▼",neutral:"·"};function Nr({metric:n,label:e,value:t,valueText:i,format:a,delta:c,comparison:f,sparkValues:p=[],sparkLabels:m,selected:g,loading:v,onSelect:x,onSparkHover:b,onSparkBrush:w}){const[_,C]=k.useState(null),T=u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_!=null&&_.label?u.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),u.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:v?u.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?pt(_.value,a):i??pt(t,a)}),c||f?u.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[c?u.jsxs("span",{"data-tone":c.tone,className:`font-mono tnum font-medium ${P_[c.tone]}`,children:[u.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:$_[c.tone]}),c.label]}):null,f?u.jsx("span",{className:"truncate text-faint",children:f}):null]}):null]}),P="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",U=u.jsx("div",{className:"-mx-3.5 mt-auto",children:u.jsx(u0,{values:p,labels:m,onHover:E=>{C(E),b==null||b(E)},onBrush:w,formatValue:E=>pt(E,a)})});return x?u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:P,children:[u.jsx("button",{type:"button","data-metric":n,"aria-pressed":!!g,onClick:()=>x(n),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:T}),U]}):u.jsxs("article",{"data-metric":n,"data-selected":g||void 0,className:P,children:[T,U]})}const _l=280,Xt={top:14,right:18,bottom:26,left:60},oy=["var(--accent)","var(--danger)","#0f9f8f","#d98921","#a66dd4","#3b82c4"];function wd(n){return oy[n%oy.length]}function ay(n,e,t){return Math.min(Math.max(n,e),t)}function ra({points:n,seriesLabel:e="Current",additionalSeries:t=[],comparison:i,formatValue:a,formatAxis:c=a,formatLabel:f=v=>v,comparisonLabel:p="Previous",ariaLabel:m,onBrush:g}){var hs;const v=k.useRef(null),x=k.useRef(null),b=k.useRef(!1),w=k.useRef(null),[_,C]=k.useState(820),[T,P]=k.useState(null),[U,E]=k.useState(null);k.useEffect(()=>{const oe=v.current;if(!oe)return;const Oe=new ResizeObserver(st=>{for(const _t of st)C(Math.max(320,_t.contentRect.width))});return Oe.observe(oe),()=>Oe.disconnect()},[]);const F=n.length,A=[{label:e,points:n},...t],M=[...A.flatMap(oe=>oe.points),...i??[]].map(oe=>oe.y).filter(Number.isFinite),R=F<2||M.length===0,Y=R?0:Math.min(0,...M),z=R?1:Math.max(...M),Q=z-Y||1,W=_-Xt.left-Xt.right,ne=_l-Xt.top-Xt.bottom,X=oe=>Xt.left+(F<=1?0:oe/(F-1)*W),le=oe=>Xt.top+(1-(oe-Y)/Q)*ne,ie=oe=>ay(Math.round((oe-Xt.left)/W*(F-1)),0,F-1),ye=oe=>{const Oe=[];let st=[];return oe.forEach((_t,Un)=>{Number.isFinite(_t.y)?st.push(`${X(Un).toFixed(1)},${le(_t.y).toFixed(1)}`):st.length&&(Oe.push(st.join(" L ")),st=[])}),st.length&&Oe.push(st.join(" L ")),Oe.map(_t=>`M ${_t}`).join(" ")},re=R||n.some(oe=>!Number.isFinite(oe.y))?"":`M ${X(0).toFixed(1)},${le(Y).toFixed(1)} L ${n.map((oe,Oe)=>`${X(Oe).toFixed(1)},${le(oe.y).toFixed(1)}`).join(" L ")} L ${X(F-1).toFixed(1)},${le(Y).toFixed(1)} Z`;function O(oe){var st;const Oe=(st=x.current)==null?void 0:st.getBoundingClientRect();return Oe?oe.clientX-Oe.left:0}function G(oe){if(R)return;const Oe=O(oe);P(ie(Oe)),b.current&&w.current&&(w.current={a:w.current.a,b:Oe},E({...w.current}))}function H(oe){if(R||!g)return;oe.currentTarget.setPointerCapture(oe.pointerId),b.current=!0;const Oe=O(oe);w.current={a:Oe,b:Oe},E({...w.current})}function N(oe){oe.currentTarget.hasPointerCapture(oe.pointerId)&&oe.currentTarget.releasePointerCapture(oe.pointerId);const Oe=w.current;if(b.current&&Oe&&g){const st=ie(Math.min(Oe.a,Oe.b)),_t=ie(Math.max(Oe.a,Oe.b));_t>st&&g({from:n[st].x,to:n[_t].x})}b.current=!1,w.current=null,E(null)}function V(){P(null),b.current=!1,w.current=null,E(null)}const de=Math.max(1,Math.ceil(F/8)),te=[z,Y+Q*.66,Y+Q*.33,Y],q=T!=null&&T>=0&&T{const st=oe.points[q];return st&&Number.isFinite(st.y)?[{...oe,point:st,index:Oe}]:[]}),dt=q!=null?(i==null?void 0:i[q])??null:null,St=dt&&Number.isFinite(dt.y)?dt:null,ir=q!=null?ay(X(q),80,_-80):0,rn=Ie&&St&&St.y!==0?(Ie.y-St.y)/Math.abs(St.y)*100:null,or=m??(R?"Time series chart: not enough data to plot.":`Time series chart, ${F} points from ${f(n[0].x)} to ${f(n[F-1].x)}.`);return u.jsxs("div",{className:"relative text-chart-primary",children:[u.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-0.5 px-3 pt-2 text-2xs text-faint",children:[A.map((oe,Oe)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0.5 w-3",style:{backgroundColor:wd(Oe)}})," ",oe.label]},`${oe.label}-${Oe}`)),i!=null&&i.length?u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"inline-block h-0 w-3 border-t border-dashed border-faint"})," ",p]}):null]}),u.jsx("div",{ref:v,className:"w-full",children:R?u.jsx("div",{className:"grid h-[280px] place-items-center text-xs text-faint",children:"Not enough data to chart."}):u.jsxs("svg",{ref:x,width:_,height:_l,role:"img","aria-label":or,className:"block touch-none select-none",onPointerMove:G,onPointerDown:H,onPointerUp:N,onPointerLeave:V,onPointerCancel:V,onDoubleClick:()=>g==null?void 0:g(null),children:[u.jsx("defs",{children:u.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[u.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.18}),u.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),te.map((oe,Oe)=>u.jsxs("g",{children:[u.jsx("line",{x1:Xt.left,x2:_-Xt.right,y1:le(oe),y2:le(oe),className:"stroke-line"}),u.jsx("text",{x:Xt.left-8,y:le(oe)+3,textAnchor:"end",className:"fill-faint font-mono text-[10px]",children:c(oe)})]},Oe)),i&&i.length>=2?u.jsx("path",{d:ye(i),fill:"none",className:"stroke-faint",strokeWidth:1.25,strokeDasharray:"4 3"}):null,re?u.jsx("path",{d:re,fill:"url(#ts-fill)"}):null,A.map((oe,Oe)=>u.jsx("path",{d:ye(oe.points),fill:"none",stroke:wd(Oe),strokeWidth:1.75},`${oe.label}-${Oe}`)),U?u.jsx("rect",{x:Math.min(U.a,U.b),y:Xt.top,width:Math.abs(U.b-U.a),height:ne,className:"fill-chart-primary",opacity:.12}):null,q!=null&&Ue.length?u.jsxs("g",{children:[u.jsx("line",{x1:X(q),x2:X(q),y1:Xt.top,y2:_l-Xt.bottom,className:"stroke-faint",strokeDasharray:"3 3"}),St?u.jsx("circle",{cx:X(q),cy:le(St.y),r:3,className:"fill-faint"}):null,Ue.map(oe=>u.jsx("circle",{cx:X(q),cy:le(oe.point.y),r:3.5,fill:wd(oe.index)},`${oe.label}-${oe.index}`))]}):null,n.map((oe,Oe)=>Oe%de===0||Oe===F-1?u.jsx("text",{x:X(Oe),y:_l-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:f(oe.x)},oe.x):null)]})}),Ue.length&&Me?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:ir},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:f(Me)}),Ue.map(oe=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:oe.label}),u.jsx("span",{className:"font-mono tnum font-medium text-ink",children:a(oe.point.y)})]},`${oe.label}-${oe.index}`)),St?u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsx("span",{className:"text-muted",children:p}),u.jsx("span",{className:"font-mono tnum text-muted",children:a(St.y)})]}):null,rn!=null?u.jsxs("div",{className:`mt-0.5 text-right font-mono ${rn>0?"text-success":rn<0?"text-danger":"text-faint"}`,children:[rn.toLocaleString(void 0,{maximumFractionDigits:1,signDisplay:"exceptZero"}),"%"]}):null]}):null]})}const z_={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function V_({metric:n,points:e,comparisonPoints:t,total:i,prevTotal:a,hasTime:c,loading:f,activeRange:p,comparisonLabel:m="Prev period",formatLabel:g,onBrush:v}){const x={format:n.format,type:n.type},b=a!==void 0?ky(i,a):null,w=`${n.label} over time. Total ${pt(i,x)}${b?`, ${b.label} versus the ${m.toLowerCase()}`:""}.`;return u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5 px-0.5",children:[u.jsx("h2",{className:"text-xs font-medium text-muted",children:n.label}),u.jsx("span",{className:"font-mono tnum text-xl font-semibold text-ink",children:pt(i,x)}),b?u.jsxs("span",{className:`text-xs ${z_[b.tone]}`,children:[b.label," vs ",m.toLowerCase()]}):null,c?null:u.jsx("span",{className:"text-2xs text-faint",children:"No time dimension"}),p?u.jsx("button",{type:"button",onClick:()=>v(null),className:"ml-auto inline-flex h-7 items-center rounded-full border border-line bg-surface px-3 text-xs text-muted hover:border-line-strong hover:text-ink",children:"Reset zoom"}):null]}),c?f&&e.length<2?u.jsx("div",{className:"skeleton h-[280px] w-full"}):u.jsx(ra,{points:e,comparison:t,formatValue:_=>pt(_,x),formatAxis:_=>Gt(_,x),formatLabel:g,comparisonLabel:m,ariaLabel:w,onBrush:v}):null]})}const W_=new Set(["and","as","asc","by","case","cast","count","date_trunc","desc","else","end","from","group","in","is","join","left","limit","not","null","on","or","order","over","partition","select","sum","then","when","where","with"]);function H_(n){const e=[];let t=0;for(;ta).map(([a,c])=>`-- ${a} ${c}`).join(` -`),i=W_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function H_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const G_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!G_.has(n.type)}function Y_(n,e){return!!(n&&n===e)}function Q_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function K_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:bS(n.to,e)}}function J_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(fe=>fe.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(fe=>fe.ref)),b=ki(t,n.model).filter(fe=>!m||x.has(fe.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(fe=>fe.ref===n.selectedMetric)??b.find(fe=>fe.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(fe=>fe.ref===_.ref),$=k.useMemo(()=>{const fe=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...fe,_.ref]:fe},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),B=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?gS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:yS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Es(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,L=fe=>fe?{...fe,timezone:M}:null,Y=En(i,!C&&$.length?L(vd($,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=En(i,!C&&$.length&&w?L(Gm($,w,n.grain,B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=En(i,!C&&$.length&&A?L(vd($,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),V=En(i,C?L(vd([C.ref],B,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),X=En(i,!C&&_&&w&&A?L(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),ne=Y.error??z.error??Q.error??X.error??V.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const ae=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(ae.map(fe=>fe.ref)),ye=pc(t,p.name).filter(fe=>n.joinedDims.includes(fe.ref)&&!ie.has(fe.ref)),re=[...ae,...ye].filter(fe=>fe.type!=="time"),O=Q_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...$,H]:$,W=_&&H?[_.ref,H]:[],J=v[0]?Tt(v[0].ref,$):_?Tt(_.ref,$):null,oe=fe=>!fe||!J||fe.columns.includes(J),te=oe(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,he=oe(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=oe(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Fe=_?Tt(_.ref,$):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,W):"",St=H?Tt(H,N):"",ir=H?Tt(H,W):"",rn=St?cy(Ie,St):Ie,or=te&&Fe?Number(te[Fe]):NaN,hs=he&&Fe?Number(he[Fe]):void 0,le=Ue?rn.map(fe=>({x:String(fe[St]??""),y:Number(fe[Ue])})):[],Oe=ir?cy(((ps=X.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&le.length>0&&Oe.length>0?(()=>{const fe=String(Oe[0][ir]??""),mt=le[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(fe,String(sn[ir]??""),n.grain),Number(sn[dt]));return le.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Y_(V.resultKey,V.queryKey),Un=_t?((Wi=V.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=V.result)==null?void 0:Or.columns)??[]:[]).map(fe=>({key:fe,label:Re(fe),numeric:Un.some(mt=>typeof mt[fe]=="number")}));function Ui(fe){e(fe?{type:"setDateRange",range:K_(fe,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[ne?u.jsx(Li,{message:ne}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(fe=>{const mt=Tt(fe.ref,$),Ar=Tt(fe.ref,N),sn=te?Number(te[mt]):NaN,Us=he?Number(he[mt]):void 0,Er=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:fe.ref,label:fe.label,valueText:pt(sn,H_(fe)),delta:Us!==void 0?jy(sn,Us):null,sparkValues:Er,selected:n.selectedMetric===fe.ref,loading:Y.loading&&!te,onSelect:Pn=>e({type:"setMetric",metric:Pn})},fe.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),V.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(fe,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(z_,{metric:_,points:le,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:fe=>vS(fe,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(fe=>O===null||O===fe.ref).map(fe=>u.jsx(L_,{dim:fe,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===fe.ref,onExpandedChange:mt=>f(mt?fe.ref:null)},fe.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=X.result)==null?void 0:Gi.sql,"Focused metric":(ia=V.result)==null?void 0:ia.sql}})]})}function q_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),$=k.useMemo(()=>Es(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),B=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?jS(w,v,$,B,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:L,error:Y}=En(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),V=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),X=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function ne(re){const O=V.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function ae(re,O){if(re.numeric){const G=Q.get(V.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):X.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:X,rows:(M==null?void 0:M.rows)??[],loading:L,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:ne,renderCell:ae}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function Z_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function c0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const L=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return L.observe(M),()=>L.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,$=T(0),U=_/Math.max(n.length,1),B=Math.max(8,Math.min(48,U*.62)),F=Z_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,L)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},L)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:$,y2:$,className:"stroke-line"}),n.map((M,L)=>{const Y=M.filterValue??M.label,z=v[L]??0,Q=T(z),V=Math.abs(Q-$),X=Cn.left+U*L+(U-B)/2,ne=Math.min(Q,$);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?ae=>{(ae.key==="Enter"||ae.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:X,y:ne,width:B,height:V,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:X+B/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${L}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Bs(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function u0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(V=>Number.isFinite(V.x)&&Number.isFinite(V.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(V=>V.series??""))],_=b.map(V=>V.x),C=b.map(V=>V.y),T=Math.min(..._),$=Math.max(..._),U=Math.min(...C),B=Math.max(...C),F=$-T||1,A=B-U||1,M=m-Vt.left-Vt.right,L=e-Vt.top-Vt.bottom,Y=V=>Vt.left+(V-T)/F*M,z=V=>Vt.top+(1-(V-U)/A)*L,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((V,X)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(X)}}),V||"(default)"]},V||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Bs(U,B,4).map((V,X)=>{const ne=z(V);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:ne,y2:ne,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:ne+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(V)})]},`y${X}`)}),Bs(T,$,5).map((V,X)=>{const ne=Y(V);return u.jsxs("g",{children:[u.jsx("line",{x1:ne,x2:ne,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:ne,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(V)})]},`x${X}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+L/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+L/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((V,X)=>u.jsx("circle",{cx:Y(V.x),cy:z(V.y),r:3.5,fill:xn(w.indexOf(V.series??"")),fillOpacity:.75,"data-x":V.x,"data-y":V.y,"data-label":V.label,...x(u.jsx(us,{title:V.label??V.series,rows:[{label:t??"x",value:a(V.x)},{label:i??"y",value:c(V.y)}]}))},X))]}),u.jsx(sr,{tip:v})]})}function X_(){const n=Pv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function e2(n){return pf(n.models.flatMap(e=>e.dimensions))}function t2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function n2({chart:n,columns:e,rows:t}){const i=M_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function r2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=f_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function s2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var V,X,ne,ae,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>e2(t),[t]),v=k.useMemo(()=>b_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=En(i,v),b=((V=x.result)==null?void 0:V.rows)??[],w=((X=x.result)==null?void 0:X.columns)??[],_=e.query.dimensions??[],C=((ne=e.encoding)==null?void 0:ne.x)??_[0]??"",T=m_(e),$=T[0]??t2(e),U=br(C,w),B=vf(n,e,a),F=Xv(e,g),A=h_(e,C),M=((ae=e.title)==null?void 0:ae.trim())||Re(e.id),L=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=g_(e,C,L),z=L.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(W=>({x:Number(W[U]),y:Number(W[H]),label:String(W[U]??""),series:O?String(W[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(u0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:W=>pt(W,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=__(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:W=>pt(W,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?W=>f(C,W):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=S_(b,U,G,z);return H.map((N,W)=>{const J=N.data.slice(0,30),oe=T.length>1||H.length>1,te=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[oe?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:te}):null,u.jsx(c0,{data:J,ariaLabel:`${M}, ${te||Re(O)}, ${J.length} categories`,selectedLabel:B.filters[C],onSelect:Y?he=>{c(y_(e,C,he,L,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${W}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re($),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:w_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(n2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(r2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function i2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>k_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!I_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function o2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function a2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>N_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=j_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a($=>{var U;return{...$,chartFilters:{...$.chartFilters??{},[_]:{...((U=$.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a($=>({...$,filters:{...$.filters,...w},filterSources:{...$.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,$;const C=fc(n,b);if(((($=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:$.scope)??"dashboard")==="chart"){a(U=>{const B={...U.chartRanges??{}},F={...B[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?B[C]=F:delete B[C],{...U,chartRanges:B}});return}a(U=>{const B={...U.ranges},F={...U.rangeSources};return _?(B[w]=_,F[w]=C):(delete B[w],delete F[w]),{...U,ranges:B,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(i2,{document:n,state:i,onLoad:a}),u.jsx(o2,{}),u.jsx(Zo,{}),u.jsx(X_,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},$={...T[b]??{}};return delete $[w],Object.keys($).length?T[b]=$:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Ov,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:D_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(s2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=Pv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function l2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function c2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function u2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(B=>B.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Rv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=pS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const B=new Map;for(const F of t.models)for(const A of F.dimensions)B.set(A.ref,{dim:A,model:F});return B},[t]),C=Object.entries(n.filters).flatMap(([B,F])=>{const A=_.get(B);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:B})},B)]:[]}),T=u.jsx(cS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),$=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(B=>{const F=B.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,B.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:B.label??B.id},B.id)})}):u.jsx(Gv,{view:n.view,onChange:B=>e({type:"setView",view:B})}),u.jsx(Vv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(B,F)=>e({type:"setDateRange",range:B,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(B,F)=>e({type:"setComparison",comparison:B,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:B=>e({type:"setGrain",grain:B})}),u.jsx(s_,{timezone:n.timezone,disabled:!b,onChange:B=>e({type:"setTimezone",timezone:B})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(l2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(qS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Ov,{brand:T,toolbar:$,filters:f?void 0:U,rail:u.jsx(ZS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(l_,{}),children:u.jsxs(XS,{children:[n.view==="home"?u.jsx(C_,{}):null,n.view==="explore"?u.jsx(J_,{}):null,n.view==="pivot"?u.jsx(q_,{}):null]},n.view)})}function d2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new lS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=d_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(c2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(a2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(HS,{catalog:i.catalog,backend:t,children:u.jsx(u2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function f2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,$=Math.min(...w),U=Math.max(...w),B=U-$||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,L=ie=>en.top+(1-(ie-$)/B)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,V=M(0),X=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${L(w[ye]).toFixed(1)}`).join(" L "),ne=xn(1),ae=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:ne}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":ae,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Bs(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Bs($,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:L(ie)+3,textAnchor:"start",className:"text-[10px]",fill:ne,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:V,y2:V,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,V),width:z,height:Math.abs(O-V),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${X}`,fill:"none",stroke:ne,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:L(w[ye]),r:3,fill:ne,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:ne}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const h2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${h2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function p2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>p2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),$=M=>{var L;return((L=e.find(Y=>Y.value===M))==null?void 0:L.label)??M};k.useEffect(()=>{if(!m)return;function M(L){p.current&&!p.current.contains(L.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const L=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(L);return}n.onChange(M.value),x(""),g(!1)}}function B(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(L=>Math.min(L+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(L=>Math.max(L-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?$(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:$(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${$(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(L=>L!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:B,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,L)=>u.jsxs("li",{id:`${f}-${L}`,role:"option","aria-selected":T.has(M.value),"data-active":L===b||void 0,onMouseEnter:()=>w(L),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function m2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const y2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function d0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function g2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:d0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return d0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,L]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:L}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const $=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:y2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:g2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(L=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(L.iso),"data-date":L.iso,onClick:()=>_(L.iso),className:`py-1 text-center tnum ${T(L.iso)?"bg-accent text-surface":C(L.iso)?"bg-accent-soft text-accent":L.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${L.iso===$?"underline underline-offset-2":""}`,children:L.day},L.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const B=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:B}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function v2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function x2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const f0=Math.PI*2;function b2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*f0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function w2(n,e,t,i,a,c){const f=Math.min(c-a,f0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function S2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=b2(n),x=v.reduce((U,B)=>U+B.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),$=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":$,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:w2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function _2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,$=i-mr.top-mr.bottom,U=T/x.length,B=$/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,L)=>u.jsx("text",{x:mr.left-6,y:mr.top+L*B+B/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,L)=>L%F===0?u.jsx("text",{x:mr.left+L*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,L)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),V=Q!=null&&Number.isFinite(Q),X=V?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+L*B+.5,width:Math.max(1,U-1),height:Math.max(1,B-1),"data-x":Y,"data-y":M,"data-value":V?Q:void 0,className:V&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:V?X:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:V?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function N2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function j2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=N2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(B=>B.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=B=>Fn.top+(1-B/x)*w,C=b/v.length,T=Bs(0,x,4),$=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((B,F)=>{const A=_(B);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(B)})]},F)}),v.map((B,F)=>{const A=Fn.left+C*F,M=_(B.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":B.x0,"data-x1":B.x1,"data-count":B.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(B.x0)} – ${i(B.x1)}`,rows:[{label:"Count",value:B.count.toLocaleString()}]}))},F)}),v.map((B,F)=>F%$===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(B.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function k2(n){let e=2166136261;for(let t=0;t>>0}function I2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function M2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=I2(k2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:$+(p[z]-U)/M*(t-$*2),y:$+(m[z]-F)/L*(i-$*2),degree:x[z]}))}function D2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>M2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),$=v.get(_.target);return!T||!$?null:u.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function C2(n,e,t){return Math.min(Math.max(n,e),t)}function F2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,V)=>{const X=z.values[V];return Number.isFinite(X)&&X>0?X:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((V,X)=>_[X]+V);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,$=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,B=z=>fn.top+(1-z/C)*$,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],V=z===0?n.map(()=>0):w[z-1],X=Q.map((ae,ie)=>`${U(ie).toFixed(1)},${B(ae).toFixed(1)}`).join(" L "),ne=[...V.keys()].reverse().map(ae=>`${U(ae).toFixed(1)},${B(V[ae]).toFixed(1)}`).join(" L ");return`M ${X} L ${ne} Z`}function L(z){const Q=z.currentTarget.getBoundingClientRect(),V=(z.clientX-Q.left)/Q.width*p,X=Math.round((V-fn.left)/T*(x-1));v(X>=0&&Xu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:L,onMouseLeave:()=>v(null),children:[Bs(0,C,4).map((z,Q)=>{const V=B(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:V,y2:V,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:V+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function O2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function T2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function A2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function B2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,$=_/g.length,U=Math.max(10,Math.min(56,$*.62)),B=Bs(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[B.map((A,M)=>{const L=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:L,y2:L,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:L+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const L=hn.left+$*M+($-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",V=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",X=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:L,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:V,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),X?u.jsx("line",{x1:L+U,x2:hn.left+$*(M+1)+($-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:L+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function R2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function L2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,R2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const U2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],P2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],$2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),z2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),V2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),W2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function H2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,$]=k.useState("orders.revenue"),[U,B]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,L]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,V]=k.useState("2025-06-15"),[X,ne]=k.useState({from:"2025-06-01",to:"2025-06-21"}),ae=k.useMemo(()=>L2($2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],W=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?W:-W}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:U2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(a0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(W=>W!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(W=>W!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Vv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Gv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(l0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(c0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(x2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(S2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(F2,{labels:ae.labels,series:ae.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(f2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(j2,{values:V2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(u0,{points:z2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(_2,{cells:W2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(B2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(D2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(O2,{checked:M,onChange:L,label:"Compact rows"}),u.jsx(T2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(A2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:$,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:B,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:V,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:X,onChange:ne,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:P2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(v2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue +`),i=H_(t||"No queries yet.");return u.jsxs("details",{className:"border border-line bg-surface",children:[u.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs font-medium text-muted",children:"Generated SQL"}),Object.keys(e).length>0?u.jsx("div",{"data-testid":"query-inputs",className:"grid gap-px border-t border-line bg-line sm:grid-cols-2",children:Object.entries(e).map(([a,c])=>c?u.jsxs("section",{className:"min-w-0 bg-surface px-3 py-2 text-2xs",children:[u.jsx("h3",{className:"mb-1 font-semibold text-ink",children:a}),[["Metrics",c.metrics],["Dimensions",c.dimensions],["Filters",c.filters]].map(([f,p])=>p!=null&&p.length?u.jsxs("p",{className:"truncate text-muted",title:p.join(", "),children:[u.jsxs("strong",{className:"font-medium text-faint",children:[f,":"]})," ",p.join(", ")]},f):null)]},a):null)}):null,u.jsx("pre",{"data-testid":"query-debug",className:"max-h-72 overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-2xs text-muted",children:i.map((a,c)=>ly[a.kind]?u.jsx("span",{className:ly[a.kind],"data-token":a.kind,children:a.value},c):a.value)})]})}function G_(n){return{format:n==null?void 0:n.format,type:n==null?void 0:n.type}}const Y_=new Set(["cohort","conversion","retention"]);function Sd(n){return!n.type||!Y_.has(n.type)}function Q_(n,e){return!!(n&&n===e)}function K_(n,e){return n&&e.some(t=>t.ref===n)?n:null}function cy(n,e){return[...n].sort((t,i)=>String(t[e]??"").localeCompare(String(i[e]??"")))}function J_(n,e){return{from:e==="second"||e==="minute"||e==="hour"?n.from.replace(" ","T"):ff(n.from),to:wS(n.to,e)}}function q_(){var Pi,$i,zi,Vi,Ls,ps,Wi,Or,Tr,sa,Hi,Gi,ia;const{state:n,dispatch:e,catalog:t,backend:i,dashboard:a}=Dr(),[c,f]=k.useState(null),p=t.models.find(he=>he.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]);k.useEffect(()=>{f(null)},[n.dashboardTab,n.model]);const g=(m==null?void 0:m.metrics)??(p==null?void 0:p.metrics)??[],v=g.filter(Sd),x=new Set(g.map(he=>he.ref)),b=ki(t,n.model).filter(he=>!m||x.has(he.ref)),w=((Pi=m==null?void 0:m.timeDimension)==null?void 0:Pi.ref)??(($i=p==null?void 0:p.timeDimension)==null?void 0:$i.ref),_=g.find(he=>he.ref===n.selectedMetric)??b.find(he=>he.ref===n.selectedMetric)??g[0],C=_&&!Sd(_)?_:void 0,T=!!_&&v.some(he=>he.ref===_.ref),P=k.useMemo(()=>{const he=v.map(mt=>mt.ref);return _&&Sd(_)&&!T?[...he,_.ref]:he},[v,_,T]),U=k.useMemo(()=>xc(t),[t]),E=k.useMemo(()=>[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:n.dateRange,types:U,dialect:t.dialect})],[m,n.filters,w,n.dateRange,U,t.dialect]),F=k.useMemo(()=>n.comparison==="off"||!n.dateRange?null:n.comparison==="year"?vS(n.dateRange):n.comparison==="custom"?n.comparisonRange??null:gS(n.dateRange),[n.comparison,n.dateRange,n.comparisonRange]),A=k.useMemo(()=>F&&w?[...(m==null?void 0:m.filters)??[],...Bs(n.filters,{timeRef:w,range:F,types:U,dialect:t.dialect})]:null,[m,n.filters,w,F,U,t.dialect]),M=n.timezone,R=he=>he?{...he,timezone:M}:null,Y=Bn(i,!C&&P.length?R(vd(P,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),z=Bn(i,!C&&P.length&&w?R(Gm(P,w,n.grain,E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!!n.dateRange)):null),Q=Bn(i,!C&&P.length&&A?R(vd(P,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),W=Bn(i,C?R(vd([C.ref],E,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations)):null),ne=Bn(i,!C&&_&&w&&A?R(Gm([_.ref],w,n.grain,A,m==null?void 0:m.segments,m==null?void 0:m.usePreaggregations,!0)):null),X=Y.error??z.error??Q.error??ne.error??W.error;if(!p)return u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available in this semantic layer."})});const le=(m==null?void 0:m.dimensions)??p.dimensions,ie=new Set(le.map(he=>he.ref)),ye=pc(t,p.name).filter(he=>n.joinedDims.includes(he.ref)&&!ie.has(he.ref)),re=[...le,...ye].filter(he=>he.type!=="time"),O=K_(c,re),G=n.comparison==="year"?"Prev year":n.comparison==="custom"?"Comparison":"Prev period",H=w?`${w}__${n.grain}`:"",N=H?[...P,H]:P,V=_&&H?[_.ref,H]:[],de=v[0]?Tt(v[0].ref,P):_?Tt(_.ref,P):null,te=he=>!he||!de||he.columns.includes(de),q=te(Y.result)?(zi=Y.result)==null?void 0:zi.rows[0]:void 0,ce=te(Q.result)?(Vi=Q.result)==null?void 0:Vi.rows[0]:void 0,Ie=te(z.result)?((Ls=z.result)==null?void 0:Ls.rows)??[]:[],Me=_?Tt(_.ref,P):"",Ue=_?Tt(_.ref,N):"",dt=_?Tt(_.ref,V):"",St=H?Tt(H,N):"",ir=H?Tt(H,V):"",rn=St?cy(Ie,St):Ie,or=q&&Me?Number(q[Me]):NaN,hs=ce&&Me?Number(ce[Me]):void 0,oe=Ue?rn.map(he=>({x:String(he[St]??""),y:Number(he[Ue])})):[],Oe=ir?cy(((ps=ne.result)==null?void 0:ps.rows)??[],ir):[],st=dt&&oe.length>0&&Oe.length>0?(()=>{const he=String(Oe[0][ir]??""),mt=oe[0].x,Ar=new Map;for(const sn of Oe)Ar.set(Wm(he,String(sn[ir]??""),n.grain),Number(sn[dt]));return oe.map(sn=>({x:sn.x,y:Ar.get(Wm(mt,sn.x,n.grain))??NaN}))})():[],_t=Q_(W.resultKey,W.queryKey),Un=_t?((Wi=W.result)==null?void 0:Wi.rows)??[]:[],Fr=(_t?((Or=W.result)==null?void 0:Or.columns)??[]:[]).map(he=>({key:he,label:Re(he),numeric:Un.some(mt=>typeof mt[he]=="number")}));function Ui(he){e(he?{type:"setDateRange",range:J_(he,n.grain)}:{type:"setDateRange",range:void 0})}return u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[X?u.jsx(Li,{message:X}):null,C?null:u.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6","data-testid":"metric-totals",children:v.length===0?u.jsx("div",{className:"col-span-full",children:u.jsx(er,{message:"This model has no metrics."})}):v.map(he=>{const mt=Tt(he.ref,P),Ar=Tt(he.ref,N),sn=q?Number(q[mt]):NaN,Us=ce?Number(ce[mt]):void 0,Br=rn.map(Pn=>Number(Pn[Ar])).filter(Number.isFinite);return u.jsx(Nr,{metric:he.ref,label:he.label,valueText:pt(sn,G_(he)),delta:Us!==void 0?ky(sn,Us):null,sparkValues:Br,selected:n.selectedMetric===he.ref,loading:Y.loading&&!q,onSelect:Pn=>e({type:"setMetric",metric:Pn})},he.ref)})}),C?u.jsxs("section",{className:"flex flex-col gap-2","data-testid":"single-metric-result",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-ink",children:C.label}),C.description?u.jsx("p",{className:"mt-0.5 text-xs text-muted",children:C.description}):null]}),W.error?null:_t?u.jsx(Ri,{columns:Fr,rows:Un,searchable:!0,renderCell:(he,mt)=>mt==null||mt===""?"—":String(mt)}):u.jsx(bc,{message:`Loading ${C.label}…`})]}):_?u.jsx(V_,{metric:_,points:oe,comparisonPoints:F?st:void 0,total:or,prevTotal:F?hs:void 0,hasTime:!!w,loading:z.loading,activeRange:n.dateRange,comparisonLabel:G,formatLabel:he=>xS(he,n.grain),onBrush:Ui}):null,C?null:u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:_&&re.length?re.filter(he=>O===null||O===he.ref).map(he=>u.jsx(U_,{dim:he,model:p,timeDimensionRef:w,rankMetric:_,contextColumn:n.contextColumn,metricTotal:Number.isFinite(or)?or:void 0,comparisonRange:F??void 0,baseFilters:m==null?void 0:m.filters,baseSegments:m==null?void 0:m.segments,usePreaggregations:m==null?void 0:m.usePreaggregations,expanded:O===he.ref,onExpandedChange:mt=>f(mt?he.ref:null)},he.ref)):u.jsx(er,{message:"No categorical dimensions to break down."})}),u.jsx(wc,{queries:{Totals:(Tr=Y.result)==null?void 0:Tr.sql,Series:(sa=z.result)==null?void 0:sa.sql,Comparison:(Hi=Q.result)==null?void 0:Hi.sql,"Prev series":(Gi=ne.result)==null?void 0:Gi.sql,"Focused metric":(ia=W.result)==null?void 0:ia.sql}})]})}function Z_(){var ie,ye;const{state:n,catalog:e,backend:t}=Dr(),i=e.models.find(re=>re.name===n.model),a=[...(i==null?void 0:i.dimensions)??[],...pc(e,n.model)],c=ki(e,n.model),f=k.useMemo(()=>[...(i==null?void 0:i.metrics)??[],...c],[i,c]),p=(ie=i==null?void 0:i.timeDimension)==null?void 0:ie.ref,m=re=>a.some(O=>O.ref===re),g=re=>f.some(O=>O.ref===re),v=n.pivotDims.filter(m),x=n.pivotMetrics.filter(g),b=g(n.selectedMetric)?n.selectedMetric:(ye=i==null?void 0:i.metrics[0])==null?void 0:ye.ref,w=x.length?x:b?[b]:[],[_,C]=k.useState(null),T=k.useMemo(()=>pf(a),[a]),P=k.useMemo(()=>Bs(n.filters,{timeRef:p,range:n.dateRange,types:T,dialect:e.dialect}),[n.filters,p,n.dateRange,T,e.dialect]),U=_??(w[0]?{ref:w[0],dir:"desc"}:null),E=U?[`${U.ref} ${U.dir.toUpperCase()}`]:void 0,F=w.length||v.length?kS(w,v,P,E,500):null,A=F?{...F,timezone:n.timezone}:null,{result:M,loading:R,error:Y}=Bn(t,A),z=[...v,...w],Q=k.useMemo(()=>new Map(f.map(re=>[re.ref,re])),[f]),W=k.useMemo(()=>{const re=new Map;for(const O of z)re.set(Tt(O,z),O);return re},[z]),ne=[...v.map(re=>{var O;return{key:Tt(re,z),label:((O=a.find(G=>G.ref===re))==null?void 0:O.label)??Re(re),numeric:!1}}),...w.map(re=>{var O;return{key:Tt(re,z),label:((O=Q.get(re))==null?void 0:O.label)??Re(re),numeric:!0,sortable:!0}})];function X(re){const O=W.get(re);O&&C(G=>G&&G.ref===O?{ref:O,dir:G.dir==="desc"?"asc":"desc"}:{ref:O,dir:"desc"})}function le(re,O){if(re.numeric){const G=Q.get(W.get(re.key)??"");return pt(O,{format:G==null?void 0:G.format,type:G==null?void 0:G.type})}return O==null||O===""?"—":String(O)}return i?u.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[Y?u.jsx(Li,{message:Y}):ne.length===0?u.jsx(er,{title:"Nothing selected",message:"Pick at least one metric or dimension above."}):u.jsx(Ri,{columns:ne,rows:(M==null?void 0:M.rows)??[],loading:R,sortKey:U?Tt(U.ref,z):void 0,sortDir:U==null?void 0:U.dir,onSort:X,renderCell:le}),u.jsx(wc,{queries:{Pivot:M==null?void 0:M.sql}})]}):u.jsx("div",{className:"p-4",children:u.jsx(er,{message:"No model available."})})}const Cn={top:12,right:14,bottom:26,left:44};function X_(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function d0({data:n,height:e=200,ariaLabel:t,selectedLabel:i,onSelect:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>{const M=c.current;if(!M||typeof ResizeObserver>"u")return;const R=new ResizeObserver(Y=>{for(const z of Y)p(Math.max(160,z.contentRect.width))});return R.observe(M),()=>R.disconnect()},[]);const v=n.map(M=>Number.isFinite(M.value)?M.value:0),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=f-Cn.left-Cn.right,C=e-Cn.top-Cn.bottom,T=M=>Cn.top+(1-(M-x)/w)*C,P=T(0),U=_/Math.max(n.length,1),E=Math.max(8,Math.min(48,U*.62)),F=X_(x,b,4),A=t||`Bar chart, ${n.length} categories, up to ${Gt(b)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":A,className:"h-[200px] w-full overflow-hidden",viewBox:`0 0 ${f} ${e}`,children:[F.map((M,R)=>{const Y=T(M);return u.jsxs("g",{children:[u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:Y,y2:Y,className:"stroke-line"}),u.jsx("text",{x:Cn.left-6,y:Y+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(M)})]},R)}),u.jsx("line",{x1:Cn.left,x2:f-Cn.right,y1:P,y2:P,className:"stroke-line"}),n.map((M,R)=>{const Y=M.filterValue??M.label,z=v[R]??0,Q=T(z),W=Math.abs(Q-P),ne=Cn.left+U*R+(U-E)/2,X=Math.min(Q,P);return u.jsxs("g",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-label":a?`Filter to ${M.label}`:void 0,"aria-pressed":a?i===Y:void 0,onClick:a?()=>a(Y):void 0,onKeyDown:a?le=>{(le.key==="Enter"||le.key===" ")&&a(Y)}:void 0,className:a?"cursor-pointer":void 0,children:[u.jsx("rect",{x:ne,y:X,width:E,height:W,"data-label":M.label,"data-value":z,"data-tone":z<0?"negative":"positive",className:i===Y?"fill-accent":z<0?"fill-danger":"fill-chart-primary",...g(`${M.label}: ${pt(z)}`)}),u.jsx("text",{x:ne+E/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.label.slice(0,8)})]},`${Y}-${R}`)})]}),u.jsx(sr,{tip:m})]})}const _d=7;function xn(n){return`var(--viz-${(n%_d+_d)%_d+1})`}function Es(n,e,t=4){if(!(e>n))return[n];const i=(e-n)/(t-1);return Array.from({length:t},(a,c)=>n+i*c)}function fs(n,e,t){if(!n||typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(a=>{for(const c of a)t(Math.max(e,c.contentRect.width))});return i.observe(n),()=>i.disconnect()}const Vt={top:12,right:14,bottom:30,left:48};function f0({points:n,height:e=240,xLabel:t,yLabel:i,formatX:a=Gt,formatY:c=Gt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();k.useEffect(()=>fs(p.current,200,g),[]);const b=n.filter(W=>Number.isFinite(W.x)&&Number.isFinite(W.y));if(b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No points to chart."});const w=[...new Set(b.map(W=>W.series??""))],_=b.map(W=>W.x),C=b.map(W=>W.y),T=Math.min(..._),P=Math.max(..._),U=Math.min(...C),E=Math.max(...C),F=P-T||1,A=E-U||1,M=m-Vt.left-Vt.right,R=e-Vt.top-Vt.bottom,Y=W=>Vt.left+(W-T)/F*M,z=W=>Vt.top+(1-(W-U)/A)*R,Q=f||`Scatter plot, ${b.length} points${t&&i?` of ${i} by ${t}`:""}`;return u.jsxs(u.Fragment,{children:[w.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:w.map((W,ne)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(ne)}}),W||"(default)"]},W||"(default)"))}):null,u.jsxs("svg",{ref:p,role:"img","aria-label":Q,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${m} ${e}`,children:[Es(U,E,4).map((W,ne)=>{const X=z(W);return u.jsxs("g",{children:[u.jsx("line",{x1:Vt.left,x2:m-Vt.right,y1:X,y2:X,className:"stroke-line"}),u.jsx("text",{x:Vt.left-6,y:X+3,textAnchor:"end",className:"fill-faint text-[10px]",children:c(W)})]},`y${ne}`)}),Es(T,P,5).map((W,ne)=>{const X=Y(W);return u.jsxs("g",{children:[u.jsx("line",{x1:X,x2:X,y1:Vt.top,y2:e-Vt.bottom,className:"stroke-line"}),u.jsx("text",{x:X,y:e-14,textAnchor:"middle",className:"fill-faint text-[10px]",children:a(W)})]},`x${ne}`)}),t?u.jsx("text",{x:Vt.left+M/2,y:e-2,textAnchor:"middle",className:"fill-muted text-[10px]",children:t}):null,i?u.jsx("text",{x:10,y:Vt.top+R/2,textAnchor:"middle",transform:`rotate(-90 10 ${Vt.top+R/2})`,className:"fill-muted text-[10px]",children:i}):null,b.map((W,ne)=>u.jsx("circle",{cx:Y(W.x),cy:z(W.y),r:3.5,fill:xn(w.indexOf(W.series??"")),fillOpacity:.75,"data-x":W.x,"data-y":W.y,"data-label":W.label,...x(u.jsx(us,{title:W.label??W.series,rows:[{label:t??"x",value:a(W.x)},{label:i??"y",value:c(W.y)}]}))},ne))]}),u.jsx(sr,{tip:v})]})}function e2(){const n=zv();return u.jsx("span",{className:"text-2xs text-faint",children:n?"Querying…":"Live data"})}function Nd(n,e){for(const i of n.models){const a=i.metrics.find(c=>c.ref===e);if(a)return{format:a.format,type:a.type}}const t=n.graphMetrics.find(i=>i.ref===e);return{format:t==null?void 0:t.format,type:t==null?void 0:t.type}}function t2(n){return pf(n.models.flatMap(e=>e.dimensions))}function n2(n){var t;const e=(t=n.encoding)==null?void 0:t.y;return(Array.isArray(e)?e[0]:e)??n.query.metrics[0]??""}function r2({chart:n,columns:e,rows:t}){const i=D_(e,t);return u.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(i)}`,download:`${n.id}.csv`,className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Export CSV"})}function s2({chart:n,columns:e,rows:t,loading:i,onDrill:a}){const c=e.map(g=>({key:g,label:Re(g),numeric:n.query.metrics.some(v=>br(v,e)===g)})),f=h_(n),p=f?br(f,e):void 0,m=!!f;return u.jsxs("div",{className:"border-t border-line bg-surface-soft p-3","data-testid":`chart-details-${n.id}`,children:[u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[u.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-faint",children:"Drill details"}),m&&f&&p?u.jsxs("span",{className:"text-2xs text-faint",children:["Choose a ",Re(f)," value to filter every chart."]}):null]}),u.jsx(Ri,{columns:c,rows:t,loading:i,pageSize:20,renderCell:(g,v)=>String(v??"—")}),m&&f&&p&&t.length?u.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":`Drill by ${Re(f)}`,children:t.slice(0,12).map((g,v)=>{const x=dc(g[p]);return u.jsxs("button",{type:"button",onClick:()=>a(f,x),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-accent hover:text-ink",children:["Filter to ",as(x)]},`${String(x)}-${v}`)})}):null]})}function i2({document:n,chart:e,catalog:t,backend:i,state:a,setFilters:c,setRange:f}){var W,ne,X,le,ie,ye,re;const[p,m]=k.useState(!1),g=k.useMemo(()=>t2(t),[t]),v=k.useMemo(()=>w_(n,e,a.filters,g,a.ranges,a,t.dialect),[e,n,a,g,t.dialect]),x=Bn(i,v),b=((W=x.result)==null?void 0:W.rows)??[],w=((ne=x.result)==null?void 0:ne.columns)??[],_=e.query.dimensions??[],C=((X=e.encoding)==null?void 0:X.x)??_[0]??"",T=y_(e),P=T[0]??n2(e),U=br(C,w),E=vf(n,e,a),F=t0(e,g),A=p_(e,C),M=((le=e.title)==null?void 0:le.trim())||Re(e.id),R=[(ie=e.encoding)==null?void 0:ie.color,..._.filter(O=>O!==C)].filter((O,G,H)=>!!O&&H.indexOf(O)===G),Y=v_(e,C,R),z=R.map(O=>br(O,w));let Q;if(x.loading&&!x.result)Q=u.jsx(bc,{title:`Loading ${M}`});else if(x.error)Q=u.jsx(Li,{title:`Could not load ${M}`,message:x.error});else if(!b.length)Q=u.jsx(er,{title:M,message:"The query returned no rows."});else if(_.length)if(F==="scatter"||F==="point"){const O=(ye=e.encoding)!=null&&ye.color?br(e.encoding.color,w):z[0];Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(G=>{const H=br(G,w),N=b.map(V=>({x:Number(V[U]),y:Number(V[H]),label:String(V[U]??""),series:O?String(V[O]??""):void 0}));return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(G)}):null,u.jsx(f0,{points:N,xLabel:Re(C),yLabel:Re(G),formatY:V=>pt(V,Nd(t,G)),ariaLabel:`${M}, ${Re(G)} by ${Re(C)}, ${N.length} points`})]},G)})})}else F==="line"||F==="area"?Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=N_(b,U,br(O,w),z),H=G[0]??{label:"Current",points:[]},N=Nd(t,O);return u.jsxs("div",{className:"min-w-0",children:[T.length>1?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:Re(O)}):null,u.jsx(ra,{points:H.points,seriesLabel:H.label,additionalSeries:G.slice(1),formatValue:V=>pt(V,N),ariaLabel:`${M}, ${Re(O)}, ${G.length} series and ${H.points.length} buckets`,onBrush:A?V=>f(C,V):void 0})]},O)})}):Q=u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-3",children:T.map(O=>{const G=br(O,w),H=__(b,U,G,z);return H.map((N,V)=>{const de=N.data.slice(0,30),te=T.length>1||H.length>1,q=[T.length>1?Re(O):"",H.length>1?N.label:""].filter(Boolean).join(" · ");return u.jsxs("div",{className:"min-w-0",children:[te?u.jsx("h3",{className:"mb-1 text-2xs font-semibold text-muted",children:q}):null,u.jsx(d0,{data:de,ariaLabel:`${M}, ${q||Re(O)}, ${de.length} categories`,selectedLabel:E.filters[C],onSelect:Y?ce=>{c(g_(e,C,ce,R,N.filterValues)),m(!0)}:void 0})]},`${O}-${N.label}-${V}`)})})});else{const O=b[0];Q=u.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:e.query.metrics.map(G=>u.jsx(Nr,{metric:G,label:Re(G),value:O[br(G,w)],format:Nd(t,G)},G))})}return u.jsxs("article",{className:"min-w-0 overflow-hidden border border-line bg-surface","data-testid":"dashboard-chart","data-chart-id":e.id,children:[u.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-2 border-b border-line px-3 py-2",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"truncate text-sm font-semibold text-ink",children:M}),u.jsxs("p",{className:"text-2xs text-faint",children:[Re(P),C?` by ${Re(C)}`:""]})]}),u.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.jsx("button",{type:"button","aria-expanded":p,onClick:()=>m(O=>!O),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:p?"Hide details":"Drill details"}),u.jsx("a",{href:S_(n,e,a,g,t),className:"border border-line px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Explore from here"}),u.jsx(r2,{chart:e,columns:w,rows:b})]})]}),u.jsx("div",{className:"min-h-64 overflow-hidden p-3",children:Q}),p?u.jsx(s2,{chart:e,columns:w,rows:b,loading:x.loading,onDrill:(O,G)=>c({[O]:G})}):null,(re=x.result)!=null&&re.sql?u.jsx("div",{className:"border-t border-line px-3 py-2",children:u.jsx(wc,{queries:{Query:x.result.sql}})}):null]})}function o2({document:n,state:e,onLoad:t}){const[i,a]=k.useState(""),[c,f]=k.useState(()=>I_(n)),[p,m]=k.useState(!1);function g(v){f(v),m(!M_(n,v))}return u.jsxs("details",{className:"relative",children:[u.jsx("summary",{className:"cursor-pointer list-none border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Saved views"}),u.jsxs("div",{className:"absolute right-0 z-50 mt-1 w-72 border border-line bg-surface p-3 shadow-[var(--shadow)]",children:[u.jsx("p",{className:"mb-2 text-2xs text-faint",children:"Stored only in this browser. Nothing is written to the server."}),u.jsxs("div",{className:"flex gap-1",children:[u.jsx("input",{value:i,onChange:v=>a(v.target.value),placeholder:"View name","aria-label":"Saved view name",className:"min-w-0 flex-1 border border-line bg-bg px-2 py-1 text-xs text-ink"}),u.jsx("button",{type:"button",disabled:!i.trim(),onClick:()=>{const v=[...c.filter(x=>x.name!==i.trim()),{name:i.trim(),state:e}];g(v),a("")},className:"border border-line px-2 py-1 text-2xs text-muted hover:text-ink disabled:opacity-40",children:"Save"})]}),p?u.jsx("p",{role:"alert",className:"mt-2 text-2xs text-danger",children:"Browser storage is unavailable."}):null,u.jsx("div",{className:"mt-2 flex flex-col gap-1",children:c.length?c.map(v=>u.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-line pt-1",children:[u.jsx("button",{type:"button",onClick:()=>t(v.state),className:"min-w-0 flex-1 truncate text-left text-xs text-muted hover:text-ink",children:v.name}),u.jsx("button",{type:"button","aria-label":`Delete saved view ${v.name}`,onClick:()=>g(c.filter(x=>x.name!==v.name)),className:"text-2xs text-faint hover:text-danger",children:"Delete"})]},v.name)):u.jsx("span",{className:"text-2xs text-faint",children:"No local views yet."})})]})]})}function a2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",title:"Copies the active tab, filters, and brushed ranges. Data is queried live; local saved views are not shared.",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Share URL copied":"Copy share URL"})}function l2({document:n,catalog:e,backend:t}){const[i,a]=k.useState(()=>j_(window.location.search,n)),c=n.tabs.find(b=>b.id===i.tab)??n.tabs[0];k.useEffect(()=>{window.document.title=n.title},[n.title]),k.useEffect(()=>{const b=k_(i,n);window.history.replaceState(null,"",`${window.location.pathname}${b?`?${b}`:""}`)},[n,i]);function f(b,w){var C,T;const _=fc(n,b);if((((T=(C=n.defaults)==null?void 0:C.interactions)==null?void 0:T.scope)??"dashboard")==="chart"){a(P=>{var U;return{...P,chartFilters:{...P.chartFilters??{},[_]:{...((U=P.chartFilters)==null?void 0:U[_])??{},...w}}}});return}a(P=>({...P,filters:{...P.filters,...w},filterSources:{...P.filterSources,...Object.fromEntries(Object.keys(w).map(U=>[U,_]))}}))}function p(b,w,_){var T,P;const C=fc(n,b);if((((P=(T=n.defaults)==null?void 0:T.interactions)==null?void 0:P.scope)??"dashboard")==="chart"){a(U=>{const E={...U.chartRanges??{}},F={...E[C]??{}};return _?F[w]=_:delete F[w],Object.keys(F).length?E[C]=F:delete E[C],{...U,chartRanges:E}});return}a(U=>{const E={...U.ranges},F={...U.rangeSources};return _?(E[w]=_,F[w]=C):(delete E[w],delete F[w]),{...U,ranges:E,rangeSources:F}})}const m=u.jsxs(u.Fragment,{children:[u.jsx(o2,{document:n,state:i,onLoad:a}),u.jsx(a2,{}),u.jsx(Zo,{}),u.jsx(e2,{})]}),g=Object.entries(i.chartFilters??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,value:C}))),v=Object.entries(i.chartRanges??{}).flatMap(([b,w])=>Object.entries(w).map(([_,C])=>({source:b,dimension:_,range:C}))),x=Object.entries(i.filters).length||Object.entries(i.ranges).length||g.length||v.length?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-2xs font-semibold uppercase tracking-wide text-faint",children:"Filters"}),Object.entries(i.filters).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(b)} ${w}`,onClick:()=>a(_=>{const C={..._.filters},T={..._.filterSources};return delete C[b],delete T[b],{..._,filters:C,filterSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b)," = ",w," ×"]},b)),Object.entries(i.ranges).map(([b,w])=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(b)} ${w.from} to ${w.to}`,onClick:()=>a(_=>{const C={..._.ranges},T={..._.rangeSources};return delete C[b],delete T[b],{..._,ranges:C,rangeSources:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(b),": ",w.from,"–",w.to," ×"]},`range-${b}`)),g.map(({source:b,dimension:w,value:_})=>u.jsxs("button",{type:"button","aria-label":`Remove filter ${Re(w)} ${_} from ${b}`,onClick:()=>a(C=>{const T={...C.chartFilters??{}},P={...T[b]??{}};return delete P[w],Object.keys(P).length?T[b]=P:delete T[b],{...C,chartFilters:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w)," = ",_," · ",b," ×"]},`chart-filter-${b}-${w}`)),v.map(({source:b,dimension:w,range:_})=>u.jsxs("button",{type:"button","aria-label":`Remove range ${Re(w)} ${_.from} to ${_.to} from ${b}`,onClick:()=>a(C=>{const T={...C.chartRanges??{}},P={...T[b]??{}};return delete P[w],Object.keys(P).length?T[b]=P:delete T[b],{...C,chartRanges:T}}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-danger",children:[Re(w),": ",_.from,"–",_.to," · ",b," ×"]},`chart-range-${b}-${w}`)),u.jsx("button",{type:"button",onClick:()=>a(b=>({...b,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}})),className:"text-2xs text-muted hover:text-ink",children:"Clear all"})]}):void 0;return u.jsx(Tv,{brand:u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"truncate text-sm font-semibold text-ink",children:n.title}),u.jsx("p",{className:"text-2xs text-faint",children:"Declarative dashboard"})]}),toolbar:m,filters:x,rail:null,showRail:!1,children:u.jsxs("div",{"data-testid":"dashboard-document",className:"flex min-h-full flex-col",children:[u.jsx("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-line bg-surface px-3 pt-2","aria-label":"Dashboard tabs",children:n.tabs.map(b=>u.jsx("button",{type:"button",role:"tab","aria-selected":b.id===(c==null?void 0:c.id),"data-tab-id":b.id,onClick:()=>a(w=>{var _,C;return w.tab===b.id?w:(((C=(_=n.defaults)==null?void 0:_.interactions)==null?void 0:C.scope)??"dashboard")==="dashboard"?{...w,tab:b.id}:{...w,tab:b.id,filters:{},ranges:{},filterSources:{},rangeSources:{},chartFilters:{},chartRanges:{}}}),className:"border border-b-0 border-line px-3 py-2 text-xs text-muted aria-selected:border-accent aria-selected:bg-bg aria-selected:text-ink",children:C_(b)},b.id))}),c?u.jsx("section",{className:"grid min-w-0 grid-cols-1 gap-3 p-3 xl:grid-cols-2","data-testid":"dashboard-chart-grid","data-tab-id":c.id,children:c.charts.map(b=>u.jsx(i2,{document:n,chart:b,catalog:e,backend:t,state:i,setFilters:w=>f(b,w),setRange:(w,_)=>p(b,w,_)},b.id))}):u.jsx(er,{title:"No dashboard tabs",message:"This dashboard document has no tabs to render."})]})})}function uy(){const n=zv();return u.jsxs("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"flex items-center gap-1.5 text-2xs text-faint",title:n?"Updating data":"Data is up to date",children:[n?u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"spinner size-3.5 text-accent",fill:"none",stroke:"currentColor",strokeWidth:"3",children:u.jsx("path",{d:"M12 3a9 9 0 1 0 9 9",strokeLinecap:"round"})}):u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full bg-accent"}),u.jsx("span",{className:"sr-only",children:n?"Updating data":"Data is up to date"})]})}function c2(){const[n,e]=k.useState(!1);return u.jsx("button",{type:"button",onClick:async()=>{await navigator.clipboard.writeText(window.location.href),e(!0),window.setTimeout(()=>e(!1),1200)},className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:n?"Copied":"Copy link"})}function Nl({children:n}){return u.jsx("div",{className:"grid h-screen place-items-center bg-bg p-6",children:n})}function u2({backend:n,onAuthenticated:e}){const[t,i]=k.useState(""),[a,c]=k.useState(null),[f,p]=k.useState(!1);return u.jsxs("div",{className:"w-full max-w-sm border border-line bg-surface p-6 shadow-sm",children:[u.jsx("h1",{className:"text-base font-semibold text-ink",children:"Connect to Sidemantic"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-muted",children:"Enter the API bearer once. It is exchanged for a short-lived, HttpOnly browser session where supported, and is never placed in the URL or browser storage."}),u.jsxs("form",{className:"mt-5 space-y-3",onSubmit:async m=>{m.preventDefault(),p(!0),c(null);try{await n.createBrowserSession(t),i(""),e()}catch(g){c(g instanceof Error?g.message:String(g))}finally{p(!1)}},children:[u.jsx("label",{className:"block text-xs font-medium text-ink",htmlFor:"api-token",children:"API bearer token"}),u.jsx("input",{id:"api-token",type:"password",autoComplete:"off",required:!0,value:t,onChange:m=>i(m.target.value),className:"w-full border border-line bg-bg px-3 py-2 text-sm text-ink outline-none focus:border-accent"}),a?u.jsx("p",{className:"text-xs text-red-700",children:a}):null,u.jsx("button",{type:"submit",disabled:f||!t,className:"w-full bg-accent px-3 py-2 text-xs font-semibold text-white disabled:opacity-50",children:f?"Connecting…":"Connect"})]})]})}function d2(){const{state:n,dispatch:e,catalog:t,initial:i,dashboard:a}=Dr(),c=!!a,f=n.view==="home"&&!c,p=t.models.find(E=>E.name===n.model),m=k.useMemo(()=>Ts(t,a,n.dashboardTab),[t,a,n.dashboardTab]),g=k.useMemo(()=>a?Uv(t,a,n.dashboardTab):i,[t,a,i,n.dashboardTab]),v=n.datePreset!==g.datePreset||n.datePreset===void 0&&n.dateRange!=null||Object.keys(n.filters).length>0||n.joinedDims.length>0,x=(m==null?void 0:m.timeDimension)??(p==null?void 0:p.timeDimension),b=!!x,w=mS(x==null?void 0:x.supportedGranularities,n.grain),_=k.useMemo(()=>{const E=new Map;for(const F of t.models)for(const A of F.dimensions)E.set(A.ref,{dim:A,model:F});return E},[t]),C=Object.entries(n.filters).flatMap(([E,F])=>{const A=_.get(E);return A?[u.jsx($d,{dim:A.dim,model:A.model,filter:F,onRemove:()=>e({type:"removeFilterDim",dim:E})},E)]:[]}),T=u.jsx(uS,{dashboardTitle:a==null?void 0:a.title,modelLabel:!f&&!c?p==null?void 0:p.label:void 0,onHome:()=>e({type:"setView",view:"home"})}),P=f?u.jsxs(u.Fragment,{children:[u.jsx(Zo,{}),u.jsx(uy,{})]}):u.jsxs(u.Fragment,{children:[a?u.jsx("div",{className:"flex items-center border border-line bg-surface",role:"tablist","aria-label":"Dashboard tabs",children:a.tabs.map(E=>{const F=E.id===n.dashboardTab;return u.jsx("button",{type:"button",role:"tab","aria-selected":F,className:`px-2 py-1 text-2xs ${F?"bg-accent text-white":"text-muted hover:text-ink"}`,onClick:()=>{const A=Ts(t,a,E.id);A&&e({type:"setDashboardTab",tab:A.id,model:A.model.name,metric:A.selectedMetric,grain:A.grain})},children:E.label??E.id},E.id)})}):u.jsx(Qv,{view:n.view,onChange:E=>e({type:"setView",view:E})}),u.jsx(Hv,{range:b?n.dateRange:void 0,disabled:!b,onChange:(E,F)=>e({type:"setDateRange",range:E,preset:F}),comparison:n.comparison,comparisonRange:n.comparisonRange,onComparisonChange:(E,F)=>e({type:"setComparison",comparison:E,range:F})}),u.jsx(zd,{grain:n.grain,options:w,disabled:!b,onChange:E=>e({type:"setGrain",grain:E})}),u.jsx(i_,{timezone:n.timezone,disabled:!b,onChange:E=>e({type:"setTimezone",timezone:E})}),v?u.jsx("button",{type:"button",onClick:()=>e({type:"reset",initial:g}),className:"border border-line bg-surface px-2 py-1 text-2xs text-muted hover:border-faint hover:text-ink",children:"Reset"}):null,u.jsx(c2,{}),u.jsx(Zo,{}),u.jsx(uy,{})]}),U=u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"shrink-0 text-xs font-medium text-muted",children:"Filters"}),C.length?C:u.jsx("span",{className:"text-2xs text-faint",children:"None"}),p?u.jsx(ZS,{model:p}):null,C.length?u.jsx("button",{type:"button",onClick:()=>e({type:"clearFilters"}),className:"shrink-0 text-2xs text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}):null]});return u.jsx(Tv,{brand:T,toolbar:P,filters:f?void 0:U,rail:u.jsx(XS,{}),showRail:!f&&!c,openRailRequest:n.view==="pivot",drawer:f?void 0:u.jsx(c_,{}),children:u.jsxs(e_,{children:[n.view==="home"?u.jsx(F_,{}):null,n.view==="explore"?u.jsx(q_,{}):null,n.view==="pivot"?u.jsx(Z_,{}):null]},n.view)})}function f2(){const[n,e]=k.useState(!1),t=k.useMemo(()=>new cS({transport:"json",onUnauthorized:()=>e(!0)}),[]),[i,a]=k.useState(null),[c,f]=k.useState(null),[p,m]=k.useState(0),g=f_(window.location.pathname,window.location.search);return k.useEffect(()=>{let v=!0;return Promise.all([t.getCatalog(),g?Promise.resolve(null):t.getDashboard()]).then(([x,b])=>v&&a({catalog:x,dashboard:b})).catch(x=>v&&f(x instanceof Error?x.message:String(x))),()=>{v=!1}},[t,g,p]),n?u.jsx(Nl,{children:u.jsx(u2,{backend:t,onAuthenticated:()=>{e(!1),f(null),m(v=>v+1)}})}):c?u.jsx(Nl,{children:u.jsx(Li,{title:"Could not load semantic layer",message:c})}):i?i.catalog.models.length?i.dashboard?u.jsx(l2,{document:i.dashboard,catalog:i.catalog,backend:t}):u.jsx(GS,{catalog:i.catalog,backend:t,children:u.jsx(d2,{})}):u.jsx(Nl,{children:u.jsx(er,{title:"Empty semantic layer",message:"No models were found."})}):u.jsx(Nl,{children:u.jsx(bc,{title:"Loading semantic layer",message:"Reading models and metrics…"})})}const en={top:14,right:48,bottom:26,left:48};function h2({data:n,barLabel:e="Bars",lineLabel:t="Line",height:i=220,formatBar:a=pt,formatLine:c=pt,ariaLabel:f}){const p=k.useRef(null),[m,g]=k.useState(640),{tip:v,handlers:x}=Cr();if(k.useEffect(()=>fs(p.current,240,g),[]),n.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No data to chart."});const b=n.map(ie=>Number.isFinite(ie.bar)?ie.bar:0),w=n.map(ie=>Number.isFinite(ie.line)?ie.line:0),_=Math.min(0,...b),C=Math.max(0,...b),T=C-_||1,P=Math.min(...w),U=Math.max(...w),E=U-P||1,F=m-en.left-en.right,A=i-en.top-en.bottom,M=ie=>en.top+(1-(ie-_)/T)*A,R=ie=>en.top+(1-(ie-P)/E)*A,Y=F/n.length,z=Math.max(8,Math.min(48,Y*.55)),Q=ie=>en.left+Y*ie+Y/2,W=M(0),ne=n.map((ie,ye)=>`${Q(ye).toFixed(1)},${R(w[ye]).toFixed(1)}`).join(" L "),X=xn(1),le=f||`Combo chart, ${n.length} categories: ${e} bars with a ${t} line`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-1 flex items-center gap-3 text-2xs text-faint",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-3 bg-chart-primary"})," ",e]}),u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block h-0.5 w-3",style:{background:X}})," ",t]})]}),u.jsxs("svg",{ref:p,role:"img","aria-label":le,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${m} ${i}`,children:[Es(_,C,4).map((ie,ye)=>{const re=M(ie);return u.jsxs("g",{children:[u.jsx("line",{x1:en.left,x2:m-en.right,y1:re,y2:re,className:"stroke-line"}),u.jsx("text",{x:en.left-6,y:re+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(ie)})]},ye)}),Es(P,U,4).map((ie,ye)=>u.jsx("text",{x:m-en.right+6,y:R(ie)+3,textAnchor:"start",className:"text-[10px]",fill:X,children:c(ie)},ye)),u.jsx("line",{x1:en.left,x2:m-en.right,y1:W,y2:W,className:"stroke-line"}),n.map((ie,ye)=>{const re=b[ye],O=M(re);return u.jsxs("g",{children:[u.jsx("rect",{x:Q(ye)-z/2,y:Math.min(O,W),width:z,height:Math.abs(O-W),"data-label":ie.label,"data-bar":re,"data-line":w[ye],className:re<0?"fill-danger":"fill-chart-primary",...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(re),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:X}]}))}),u.jsx("text",{x:Q(ye),y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:ie.label.slice(0,8)})]},ie.label)}),u.jsx("path",{d:`M ${ne}`,fill:"none",stroke:X,strokeWidth:1.75}),n.map((ie,ye)=>u.jsx("circle",{cx:Q(ye),cy:R(w[ye]),r:3,fill:X,...x(u.jsx(us,{title:ie.label,rows:[{label:e,value:a(b[ye]),swatch:"var(--chart-primary)"},{label:t,value:c(w[ye]),swatch:X}]}))},ie.label))]}),u.jsx(sr,{tip:v})]})}const p2={primary:"border-accent bg-accent-soft font-medium text-accent hover:bg-accent hover:text-surface",secondary:"border-line bg-surface text-ink hover:bg-surface-soft",ghost:"border-transparent bg-transparent text-muted hover:bg-surface-soft hover:text-ink",danger:"border-danger bg-danger-soft font-medium text-danger hover:bg-danger hover:text-surface"};function Ao({variant:n="secondary",size:e="md",type:t="button",className:i,...a}){const c=e==="sm"?"h-6 px-2.5 text-2xs":"h-7 px-3 text-xs";return u.jsx("button",{type:t,"data-variant":n,className:`inline-flex items-center justify-center rounded-full border ${c} ${p2[n]} disabled:pointer-events-none disabled:opacity-50 ${i??""}`,...a})}function m2(n,e){const t=e.trim().toLowerCase();return t?n.filter(i=>i.value.toLowerCase().includes(t)||(i.label??"").toLowerCase().includes(t)):n}function dy(n){const{options:e,placeholder:t="Search…",ariaLabel:i,disabled:a,maxVisible:c=50}=n,f=k.useId(),p=k.useRef(null),[m,g]=k.useState(!1),[v,x]=k.useState(""),[b,w]=k.useState(0),_=k.useMemo(()=>m2(e,v).slice(0,c),[e,v,c]),C=n.multiple?n.values:n.value!=null?[n.value]:[],T=new Set(C),P=M=>{var R;return((R=e.find(Y=>Y.value===M))==null?void 0:R.label)??M};k.useEffect(()=>{if(!m)return;function M(R){p.current&&!p.current.contains(R.target)&&g(!1)}return document.addEventListener("mousedown",M,!0),()=>document.removeEventListener("mousedown",M,!0)},[m]);function U(M){if(M){if(n.multiple){const R=T.has(M.value)?n.values.filter(Y=>Y!==M.value):[...n.values,M.value];n.onChange(R);return}n.onChange(M.value),x(""),g(!1)}}function E(){n.multiple?n.onChange([]):n.onChange(null),x("")}function F(M){M.key==="ArrowDown"?(M.preventDefault(),g(!0),w(R=>Math.min(R+1,_.length-1))):M.key==="ArrowUp"?(M.preventDefault(),w(R=>Math.max(R-1,0))):M.key==="Enter"?(M.preventDefault(),m&&U(_[b])):M.key==="Escape"?g(!1):M.key==="Backspace"&&n.multiple&&!v&&n.values.length&&n.onChange(n.values.slice(0,-1))}const A=!n.multiple&&n.value!=null?P(n.value):t;return u.jsxs("div",{ref:p,className:"relative inline-flex min-w-40 flex-wrap items-center gap-1 text-xs",children:[n.multiple?n.values.map(M=>u.jsxs("span",{"data-chip":M,className:"inline-flex items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 leading-4 text-muted",children:[u.jsx("span",{className:"max-w-32 truncate",children:P(M)}),u.jsx("button",{type:"button","aria-label":`Remove ${P(M)}`,disabled:a,onClick:()=>n.onChange(n.values.filter(R=>R!==M)),className:"text-faint hover:text-ink",children:"×"})]},M)):null,u.jsxs("span",{className:"relative min-w-28 flex-1",children:[u.jsx("input",{type:"text",role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":m&&_[b]?`${f}-${b}`:void 0,"aria-label":i,disabled:a,placeholder:A,value:v,onChange:M=>{x(M.target.value),w(0),g(!0)},onFocus:()=>g(!0),onKeyDown:F,className:"h-7 w-full rounded-full border border-line bg-surface px-3 text-ink placeholder:text-faint disabled:opacity-50"}),C.length>0?u.jsx("button",{type:"button","aria-label":"Clear selection",disabled:a,onClick:E,className:"absolute right-1 top-1/2 -translate-y-1/2 px-1 text-faint hover:text-ink",children:"×"}):null]}),m?u.jsxs("ul",{id:f,role:"listbox","aria-multiselectable":n.multiple||void 0,className:"absolute left-0 top-full z-50 mt-1 max-h-56 w-full min-w-40 overflow-y-auto rounded-xl border border-line bg-surface p-1.5 shadow-[var(--shadow)]",children:[_.length===0?u.jsx("li",{className:"px-1.5 py-1 text-faint",children:"No matches"}):null,_.map((M,R)=>u.jsxs("li",{id:`${f}-${R}`,role:"option","aria-selected":T.has(M.value),"data-active":R===b||void 0,onMouseEnter:()=>w(R),onMouseDown:Y=>{Y.preventDefault(),U(M)},className:"cursor-pointer truncate rounded-md px-2 py-1 text-muted data-[active=true]:bg-surface-soft data-[active=true]:text-ink",children:[M.label??M.value,T.has(M.value)?u.jsx("span",{className:"float-right text-accent",children:"✓"}):null]},M.value))]}):null]})}function y2({title:n,eyebrow:e="Sidemantic",status:t,toolbar:i,children:a}){return u.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-5 text-ink sm:px-6",children:[u.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-line pb-4",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-medium text-faint",children:e}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:n})]}),t?u.jsx("div",{className:"text-sm text-muted",children:t}):null]}),i?u.jsx("section",{className:"flex flex-wrap gap-2 py-3",children:i}):null,u.jsx("section",{className:"grid gap-4 py-4",children:a})]})}const g2=["Su","Mo","Tu","We","Th","Fr","Sa"],fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function h0(n,e,t){return`${String(n).padStart(4,"0")}-${String(e+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function v2(n,e){const t=new Date(Date.UTC(n,e,1)),i=new Date(t);i.setUTCDate(1-t.getUTCDay());const a=[],c=new Date(i);do{const f=[];for(let p=0;p<7;p+=1)f.push({iso:h0(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),day:c.getUTCDate(),inMonth:c.getUTCMonth()===e}),c.setUTCDate(c.getUTCDate()+1);a.push(f)}while(c.getUTCMonth()===e);return a}function jd(){const n=new Date;return h0(n.getFullYear(),n.getMonth(),n.getDate())}function hy(n){var F;const{inline:e,ariaLabel:t,disabled:i}=n,a=n.mode==="range",c=a?((F=n.value)==null?void 0:F.from)??null:n.value,[f,p]=k.useState(()=>Number((c??jd()).slice(0,4))),[m,g]=k.useState(()=>Number((c??jd()).slice(5,7))-1),[v,x]=k.useState(null),b=k.useRef(null);function w(A){const M=new Date(Date.UTC(f,m+A,1));p(M.getUTCFullYear()),g(M.getUTCMonth())}function _(A){if(!a){n.onChange(A),b.current&&(b.current.open=!1);return}if(!v){x(A);return}const[M,R]=v<=A?[v,A]:[A,v];n.onChange({from:M,to:R}),x(null),b.current&&(b.current.open=!1)}function C(A){return a?v?A===v:n.value!=null&&A>=n.value.from&&A<=n.value.to:A===n.value}function T(A){return a?v?A===v:n.value!=null&&(A===n.value.from||A===n.value.to):A===n.value}const P=jd(),U=u.jsxs("div",{className:"w-56 select-none rounded-xl border border-line bg-surface p-2.5 text-2xs","aria-label":t??"Calendar",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[u.jsx("button",{type:"button","aria-label":"Previous month",onClick:()=>w(-1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"‹"}),u.jsxs("span",{className:"font-medium text-ink",children:[fy[m]," ",f]}),u.jsx("button",{type:"button","aria-label":"Next month",onClick:()=>w(1),className:"px-1.5 py-0.5 text-muted hover:bg-surface-soft hover:text-ink",children:"›"})]}),u.jsx("div",{className:"grid grid-cols-7 text-center text-faint",children:g2.map(A=>u.jsx("span",{className:"py-0.5",children:A},A))}),u.jsx("div",{role:"grid","aria-label":`${fy[m]} ${f}`,children:v2(f,m).map((A,M)=>u.jsx("div",{role:"row",className:"grid grid-cols-7",children:A.map(R=>u.jsx("button",{type:"button",role:"gridcell","aria-selected":C(R.iso),"data-date":R.iso,onClick:()=>_(R.iso),className:`py-1 text-center tnum ${T(R.iso)?"bg-accent text-surface":C(R.iso)?"bg-accent-soft text-accent":R.inMonth?"text-ink hover:bg-surface-soft":"text-faint hover:bg-surface-soft"} ${R.iso===P?"underline underline-offset-2":""}`,children:R.day},R.iso))},M))}),a&&v?u.jsxs("p",{className:"mt-1 text-faint",children:["Start ",v," — pick an end date."]}):null,n.value!=null?u.jsx("button",{type:"button",onClick:()=>n.onChange(null),className:"mt-1 w-full rounded-lg border border-line px-2 py-1 text-left text-muted hover:bg-surface-soft",children:"Clear"}):null]});if(e)return U;const E=a?n.value?`${n.value.from} → ${n.value.to}`:"Any dates":n.value??"Any date";return u.jsxs("details",{ref:b,className:"relative inline-block text-xs",children:[u.jsxs("summary",{className:`flex cursor-pointer items-center h-7 gap-1.5 rounded-full border border-line bg-surface px-3 text-ink ${i?"pointer-events-none opacity-50":""}`,children:[u.jsx("span",{className:"text-faint",children:t??"Date"}),u.jsx("span",{className:"tnum",children:E}),u.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"▾"})]}),u.jsx("div",{className:"absolute left-0 z-50 mt-1 shadow-[var(--shadow)]",children:U})]})}function x2({result:n,pageSize:e=10}){const t=(n==null?void 0:n.columns)??[];return u.jsx(Ri,{columns:t.map(i=>({key:i,label:Re(i),numeric:n==null?void 0:n.sample_rows.some(a=>typeof a[i]=="number")})),rows:(n==null?void 0:n.sample_rows)??[],pageSize:e,renderCell:(i,a)=>pt(a)})}function b2({data:n,height:e=200,ariaLabel:t}){return u.jsx("div",{style:{minHeight:e},children:u.jsx(ra,{points:n.map(({label:i,value:a})=>({x:i,y:a})),formatValue:i=>pt(i),ariaLabel:t})})}const p0=Math.PI*2;function w2(n){const e=n.map((a,c)=>({...a,colorIndex:c})).filter(a=>Number.isFinite(a.value)&&a.value>0),t=e.reduce((a,c)=>a+c.value,0);if(t<=0)return[];let i=-Math.PI/2;return e.map(a=>{const c=a.value/t,f=i;return i+=c*p0,{label:a.label,value:a.value,share:c,startAngle:f,endAngle:i,colorIndex:a.colorIndex}})}function S2(n,e,t,i,a,c){const f=Math.min(c-a,p0-1e-4),p=a+f,m=f>Math.PI?1:0,g=n+i*Math.cos(a),v=e+i*Math.sin(a),x=n+i*Math.cos(p),b=e+i*Math.sin(p),w=n+t*Math.cos(p),_=e+t*Math.sin(p),C=n+t*Math.cos(a),T=e+t*Math.sin(a);return[`M ${g.toFixed(2)} ${v.toFixed(2)}`,`A ${i} ${i} 0 ${m} 1 ${x.toFixed(2)} ${b.toFixed(2)}`,`L ${w.toFixed(2)} ${_.toFixed(2)}`,`A ${t} ${t} 0 ${m} 0 ${C.toFixed(2)} ${T.toFixed(2)}`,"Z"].join(" ")}function _2({data:n,height:e=200,centerLabel:t="Total",format:i=pt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(360),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,220,p),[]);const v=w2(n),x=v.reduce((U,E)=>U+E.value,0),b=Math.min(e,f*.55),w=b/2,_=e/2,C=b/2-6,T=Math.max(C*.62,C-34),P=a||`Donut chart, ${v.length} segments totaling ${Gt(x)}`;return v.length===0?u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No positive values to chart."}):u.jsxs("div",{ref:c,className:"flex w-full items-center gap-4",style:{height:e},children:[u.jsxs("svg",{role:"img","aria-label":P,width:b,height:e,className:"shrink-0 overflow-hidden",children:[v.map(U=>u.jsx("path",{d:S2(w,_,T,C,U.startAngle,U.endAngle),fill:xn(U.colorIndex),stroke:"var(--surface)",strokeWidth:1,"data-label":U.label,"data-value":U.value,...g(u.jsx(us,{title:U.label,rows:[{label:"Value",value:i(U.value),swatch:xn(U.colorIndex)},{label:"Share",value:`${(U.share*100).toFixed(1)}%`}]}))},U.label)),u.jsx("text",{x:w,y:_-4,textAnchor:"middle",className:"fill-ink font-mono tnum text-sm font-medium",children:Gt(x)}),u.jsx("text",{x:w,y:_+12,textAnchor:"middle",className:"fill-faint text-[10px]",children:t})]}),u.jsx("ul",{className:"min-w-0 flex-1 space-y-1 text-2xs",children:v.map(U=>u.jsxs("li",{className:"flex items-center gap-2","data-label":U.label,children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 shrink-0",style:{background:xn(U.colorIndex)}}),u.jsx("span",{className:"truncate text-muted",children:U.label}),u.jsx("span",{className:"ml-auto font-mono tnum text-ink",children:i(U.value)}),u.jsxs("span",{className:"w-10 text-right font-mono tnum text-faint",children:[(U.share*100).toFixed(1),"%"]})]},U.label))}),u.jsx(sr,{tip:m})]})}const mr={top:8,right:8,bottom:26,left:76};function py(n,e,t){if(t!=null&&t.length)return t;const i=[];for(const a of n)i.includes(a[e])||i.push(a[e]);return i}function N2({cells:n,xLabels:e,yLabels:t,height:i=240,format:a=pt,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),{tip:g,handlers:v}=Cr();k.useEffect(()=>fs(f.current,240,m),[]);const x=py(n,"x",e),b=py(n,"y",t);if(x.length===0||b.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"No cells to chart."});const w=new Map(n.map(M=>[`${M.x}\0${M.y}`,M.value])),_=n.map(M=>Math.abs(M.value)).filter(Number.isFinite),C=Math.max(..._,0)||1,T=p-mr.left-mr.right,P=i-mr.top-mr.bottom,U=T/x.length,E=P/b.length,F=Math.max(1,Math.ceil(x.length/Math.max(1,Math.floor(T/56)))),A=c||`Heatmap, ${x.length} by ${b.length} cells`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:f,role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:i},viewBox:`0 0 ${p} ${i}`,children:[b.map((M,R)=>u.jsx("text",{x:mr.left-6,y:mr.top+R*E+E/2+3,textAnchor:"end",className:"fill-muted text-[10px]",children:M.slice(0,12)},M)),x.map((M,R)=>R%F===0?u.jsx("text",{x:mr.left+R*U+U/2,y:i-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:M.slice(0,8)},M):null),b.map((M,R)=>x.map((Y,z)=>{const Q=w.get(`${Y}\0${M}`),W=Q!=null&&Number.isFinite(Q),ne=W?.06+.94*(Math.abs(Q)/C):0;return u.jsx("rect",{x:mr.left+z*U+.5,y:mr.top+R*E+.5,width:Math.max(1,U-1),height:Math.max(1,E-1),"data-x":Y,"data-y":M,"data-value":W?Q:void 0,className:W&&Q<0?"fill-danger":"fill-chart-primary",fillOpacity:W?ne:.03,...v(u.jsx(us,{title:`${M} / ${Y}`,rows:[{label:"Value",value:W?a(Q):"no data"}]}))},`${Y}\0${M}`)}))]}),u.jsx(sr,{tip:g})]})}function j2(n,e){const t=n.filter(Number.isFinite);if(t.length===0)return[];const i=Math.min(...t),a=Math.max(...t),c=Math.max(1,Math.floor(e??Math.min(40,Math.ceil(Math.log2(t.length)+1))));if(i===a)return[{x0:i,x1:a,count:t.length}];const f=(a-i)/c,p=Array.from({length:c},(m,g)=>({x0:i+g*f,x1:i+(g+1)*f,count:0}));for(const m of t){const g=Math.min(c-1,Math.floor((m-i)/f));p[g].count+=1}return p}const Fn={top:12,right:14,bottom:26,left:44};function k2({values:n,bins:e,height:t=200,format:i=Gt,ariaLabel:a}){const c=k.useRef(null),[f,p]=k.useState(640),{tip:m,handlers:g}=Cr();k.useEffect(()=>fs(c.current,160,p),[]);const v=j2(n,e);if(v.length===0)return u.jsx("div",{className:"grid h-[200px] place-items-center text-xs text-faint",children:"No numeric values to chart."});const x=Math.max(...v.map(E=>E.count),1),b=f-Fn.left-Fn.right,w=t-Fn.top-Fn.bottom,_=E=>Fn.top+(1-E/x)*w,C=b/v.length,T=Es(0,x,4),P=Math.max(1,Math.ceil(v.length/6)),U=a||`Histogram, ${v.length} bins from ${i(v[0].x0)} to ${i(v[v.length-1].x1)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:c,role:"img","aria-label":U,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${f} ${t}`,children:[T.map((E,F)=>{const A=_(E);return u.jsxs("g",{children:[u.jsx("line",{x1:Fn.left,x2:f-Fn.right,y1:A,y2:A,className:"stroke-line"}),u.jsx("text",{x:Fn.left-6,y:A+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(E)})]},F)}),v.map((E,F)=>{const A=Fn.left+C*F,M=_(E.count);return u.jsx("rect",{x:A+.5,y:M,width:Math.max(1,C-1),height:Fn.top+w-M,"data-x0":E.x0,"data-x1":E.x1,"data-count":E.count,className:"fill-chart-primary",...g(u.jsx(us,{title:`${i(E.x0)} – ${i(E.x1)}`,rows:[{label:"Count",value:E.count.toLocaleString()}]}))},F)}),v.map((E,F)=>F%P===0?u.jsx("text",{x:Fn.left+C*F,y:t-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:i(E.x0)},F):null)]}),u.jsx(sr,{tip:m})]})}function I2(n){let e=2166136261;for(let t=0;t>>0}function M2(n){let e=n||1;return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function D2(n,e,{width:t=640,height:i=320,iterations:a=150}={}){if(n.length===0)return[];const c=M2(I2(n.map(Y=>Y.id).join("\0"))),f=new Map(n.map((Y,z)=>[Y.id,z])),p=n.map(()=>c()*t),m=n.map(()=>c()*i),g=n.map(()=>0),v=n.map(()=>0),x=n.map(()=>0),b=[];for(const Y of e){const z=f.get(Y.source),Q=f.get(Y.target);z==null||Q==null||z===Q||(b.push([z,Q]),x[z]+=1,x[Q]+=1)}const w=t*i,_=Math.sqrt(w/n.length);let C=Math.max(t,i)/8;const T=C/(a+1);for(let Y=0;Y({...Y,x:P+(p[z]-U)/M*(t-P*2),y:P+(m[z]-F)/R*(i-P*2),degree:x[z]}))}function C2({nodes:n,links:e,height:t=320,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,240,f),[]);const g=k.useMemo(()=>D2(n,e,{width:c,height:t}),[n,e,c,t]),v=k.useMemo(()=>new Map(g.map(_=>[_.id,_])),[g]),x=k.useMemo(()=>[...new Set(n.map(_=>_.group??""))],[n]),b=Math.max(...e.map(_=>_.weight??1),1);if(g.length===0)return u.jsx("div",{className:"grid h-[320px] place-items-center text-xs text-faint",children:"No nodes to chart."});const w=i||`Network graph, ${n.length} nodes and ${e.length} links`;return u.jsxs(u.Fragment,{children:[x.length>1?u.jsx("div",{className:"mb-1 flex flex-wrap items-center gap-3 text-2xs text-faint",children:x.map((_,C)=>u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2 rounded-full",style:{background:xn(C)}}),_||"(default)"]},_||"(default)"))}):null,u.jsxs("svg",{ref:a,role:"img","aria-label":w,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${c} ${t}`,children:[e.map((_,C)=>{const T=v.get(_.source),P=v.get(_.target);return!T||!P?null:u.jsx("line",{x1:T.x,y1:T.y,x2:P.x,y2:P.y,className:"stroke-line",strokeWidth:.75+2.25*((_.weight??1)/b),"data-source":_.source,"data-target":_.target},C)}),g.map(_=>{const C=5+Math.min(9,_.degree*1.5);return u.jsxs("g",{children:[u.jsx("circle",{cx:_.x,cy:_.y,r:C,fill:xn(x.indexOf(_.group??"")),stroke:"var(--surface)",strokeWidth:1.5,"data-id":_.id,"data-degree":_.degree,...m(u.jsx(us,{title:_.label??_.id,rows:[{label:"Connections",value:String(_.degree)},..._.group?[{label:"Group",value:_.group,swatch:xn(x.indexOf(_.group))}]:[]]}))}),u.jsx("text",{x:_.x,y:_.y-C-4,textAnchor:"middle",className:"pointer-events-none fill-muted text-[10px]",children:(_.label??_.id).slice(0,14)})]},_.id)})]}),u.jsx(sr,{tip:p})]})}function Al({value:n,options:e,onChange:t,label:i,ariaLabel:a,placeholder:c,disabled:f}){return u.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-faint",children:[i?u.jsx("span",{className:"hidden sm:inline",children:i}):null,u.jsxs("select",{"aria-label":a??i,value:n,disabled:f,onChange:p=>t(p.target.value),className:"h-7 rounded-full border border-line bg-surface px-2.5 text-xs text-ink disabled:opacity-50",children:[c?u.jsx("option",{value:"",disabled:!0,children:c}):null,e.map(p=>u.jsx("option",{value:p.value,children:p.label??p.value},p.value))]})]})}const fn={top:12,right:14,bottom:26,left:48};function F2(n,e,t){return Math.min(Math.max(n,e),t)}function O2({labels:n,series:e,height:t=240,format:i=pt,formatLabel:a=f=>f,ariaLabel:c}){const f=k.useRef(null),[p,m]=k.useState(640),[g,v]=k.useState(null);k.useEffect(()=>fs(f.current,240,m),[]);const x=n.length;if(x<2||e.length===0)return u.jsx("div",{className:"grid h-[240px] place-items-center text-xs text-faint",children:"Not enough data to chart."});const b=e.map(z=>({name:z.name,values:n.map((Q,W)=>{const ne=z.values[W];return Number.isFinite(ne)&&ne>0?ne:0})})),w=[];let _=n.map(()=>0);for(const z of b){const Q=z.values.map((W,ne)=>_[ne]+W);w.push(Q),_=Q}const C=Math.max(..._,1),T=p-fn.left-fn.right,P=t-fn.top-fn.bottom,U=z=>fn.left+z/(x-1)*T,E=z=>fn.top+(1-z/C)*P,F=Math.max(1,Math.ceil(x/8)),A=c||`Stacked area chart, ${e.length} series over ${x} points`;function M(z){const Q=w[z],W=z===0?n.map(()=>0):w[z-1],ne=Q.map((le,ie)=>`${U(ie).toFixed(1)},${E(le).toFixed(1)}`).join(" L "),X=[...W.keys()].reverse().map(le=>`${U(le).toFixed(1)},${E(W[le]).toFixed(1)}`).join(" L ");return`M ${ne} L ${X} Z`}function R(z){const Q=z.currentTarget.getBoundingClientRect(),W=(z.clientX-Q.left)/Q.width*p,ne=Math.round((W-fn.left)/T*(x-1));v(ne>=0&&neu.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]},z.name))}),u.jsxs("svg",{role:"img","aria-label":A,className:"w-full overflow-hidden",style:{height:t},viewBox:`0 0 ${p} ${t}`,onMouseMove:R,onMouseLeave:()=>v(null),children:[Es(0,C,4).map((z,Q)=>{const W=E(z);return u.jsxs("g",{children:[u.jsx("line",{x1:fn.left,x2:p-fn.right,y1:W,y2:W,className:"stroke-line"}),u.jsx("text",{x:fn.left-6,y:W+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(z)})]},Q)}),b.map((z,Q)=>u.jsx("path",{d:M(Q),fill:xn(Q),fillOpacity:.8,"data-series":z.name},z.name)),g!=null?u.jsx("line",{x1:U(g),x2:U(g),y1:fn.top,y2:t-fn.bottom,className:"stroke-faint",strokeDasharray:"3 3"}):null,n.map((z,Q)=>Q%F===0||Q===x-1?u.jsx("text",{x:U(Q),y:t-8,textAnchor:"middle",className:"fill-faint font-mono text-[10px]",children:a(z)},z):null)]}),g!=null?u.jsxs("div",{className:"pointer-events-none absolute top-8 z-20 -translate-x-1/2 whitespace-nowrap border border-line bg-surface px-2 py-1.5 text-2xs shadow-[var(--shadow)]",style:{left:Y},children:[u.jsx("div",{className:"mb-0.5 font-mono text-faint",children:a(n[g])}),b.map((z,Q)=>u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[u.jsx("span",{"aria-hidden":"true",className:"inline-block size-2",style:{background:xn(Q)}}),z.name]}),u.jsx("span",{className:"font-mono tnum text-ink",children:i(z.values[g])})]},z.name))]}):null]})}function T2({checked:n,onChange:e,label:t,ariaLabel:i,disabled:a}){return u.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${a?"opacity-50":""}`,children:[u.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":i??t,disabled:a,onClick:()=>e(!n),"data-checked":n||void 0,className:`relative h-4 w-7 shrink-0 rounded-full border transition-colors ${n?"border-accent bg-accent":"border-line bg-surface-soft"}`,children:u.jsx("span",{"aria-hidden":"true",className:`absolute top-1/2 size-3 -translate-y-1/2 rounded-full bg-surface shadow transition-[left] ${n?"left-[14px]":"left-[2px]"}`})}),t?u.jsx("span",{className:"text-muted",children:t}):null]})}function A2({tabs:n,active:e,onChange:t,ariaLabel:i="Tabs"}){return u.jsx("div",{role:"tablist","aria-label":i,className:"inline-flex items-center gap-0.5 rounded-full border border-line bg-surface p-px",children:n.map(a=>u.jsx("button",{role:"tab",type:"button","aria-selected":e===a.key,"data-tab":a.key,"data-selected":e===a.key||void 0,onClick:()=>t(a.key),className:"inline-flex h-6 items-center rounded-full px-2.5 text-xs font-medium text-muted hover:bg-surface-soft hover:text-ink data-[selected=true]:bg-accent-soft data-[selected=true]:text-accent",children:a.label},a.key))})}function B2({content:n,children:e,className:t}){const{tip:i,handlers:a}=Cr();return u.jsxs(u.Fragment,{children:[u.jsx("span",{className:t??"inline-flex",...a(n),children:e}),u.jsx(sr,{tip:i})]})}function E2(n){let e=0;return n.map(t=>{const i=Number.isFinite(t.value)?t.value:0;if(t.isTotal)return e=i,{...t,value:i,start:0,end:i};const a=e;return e+=i,{...t,value:i,start:a,end:e}})}const hn={top:12,right:14,bottom:26,left:48};function R2({data:n,height:e=220,format:t=pt,ariaLabel:i}){const a=k.useRef(null),[c,f]=k.useState(640),{tip:p,handlers:m}=Cr();k.useEffect(()=>fs(a.current,200,f),[]);const g=E2(n);if(g.length===0)return u.jsx("div",{className:"grid h-[220px] place-items-center text-xs text-faint",children:"No steps to chart."});const v=g.flatMap(A=>[A.start,A.end]),x=Math.min(0,...v),b=Math.max(0,...v),w=b-x||1,_=c-hn.left-hn.right,C=e-hn.top-hn.bottom,T=A=>hn.top+(1-(A-x)/w)*C,P=_/g.length,U=Math.max(10,Math.min(56,P*.62)),E=Es(x,b,4),F=i||`Waterfall chart, ${g.length} steps ending at ${t(g[g.length-1].end)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("svg",{ref:a,role:"img","aria-label":F,className:"w-full overflow-hidden",style:{height:e},viewBox:`0 0 ${c} ${e}`,children:[E.map((A,M)=>{const R=T(A);return u.jsxs("g",{children:[u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:R,y2:R,className:"stroke-line"}),u.jsx("text",{x:hn.left-6,y:R+3,textAnchor:"end",className:"fill-faint text-[10px]",children:Gt(A)})]},M)}),u.jsx("line",{x1:hn.left,x2:c-hn.right,y1:T(0),y2:T(0),className:"stroke-faint"}),g.map((A,M)=>{const R=hn.left+P*M+(P-U)/2,Y=T(A.start),z=T(A.end),Q=A.isTotal?"total":A.value<0?"negative":"positive",W=A.isTotal?"fill-faint":A.value<0?"fill-danger":"fill-chart-primary",ne=g[M+1];return u.jsxs("g",{children:[u.jsx("rect",{x:R,y:Math.min(Y,z),width:U,height:Math.max(1,Math.abs(z-Y)),"data-label":A.label,"data-value":A.value,"data-tone":Q,className:W,...m(u.jsx(us,{title:A.label,rows:A.isTotal?[{label:"Total",value:t(A.end)}]:[{label:"Change",value:t(A.value)},{label:"Running",value:t(A.end)}]}))}),ne?u.jsx("line",{x1:R+U,x2:hn.left+P*(M+1)+(P-U)/2,y1:z,y2:z,className:"stroke-faint",strokeDasharray:"3 3"}):null,u.jsx("text",{x:R+U/2,y:e-8,textAnchor:"middle",className:"fill-muted text-[10px]",children:A.label.slice(0,9)})]},`${A.label}-${M}`)})]}),u.jsx(sr,{tip:p})]})}function my(n){return n==null?"∅":String(n)}function L2(n){const e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:Number.NaN}function U2(n,e){const t=[],i=[],a=new Map;for(const c of n){const f=my(c[e.x]),p=my(c[e.series]);t.includes(f)||t.push(f),i.includes(p)||i.push(p),a.set(`${p}\0${f}`,L2(c[e.y]))}return{labels:t,series:i.map(c=>({name:c,values:t.map(f=>a.get(`${c}\0${f}`)??0)}))}}const P2=[{dimension:"orders.region",title:"Customer Region",rows:[["East",83262],["South",80579],["West",71561],["North",52889]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"orders.status",title:"Order Status",rows:[["completed",170379],["cancelled",64637],["pending",53275]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"products.category",title:"Product Category",rows:[["Electronics",202015],["Furniture",83848],["Office Supplies",2428]].map(([n,e])=>({value:String(n),metric:Number(e)}))},{dimension:"customers.name",title:"Top Customers",rows:[["Bob Smith",46690],["Carol Davis",42227],["Henry Taylor",41633],["Grace Lee",41035],["Frank Brown",33890],["David Wilson",29928],["Alice Johnson",27114],["Emma Martinez",24802]].map(([n,e])=>({value:String(n),metric:Number(e)}))}],$2=[{key:"region",label:"Region",sortable:!0},{key:"revenue",label:"Revenue",numeric:!0,sortable:!0},{key:"orders",label:"Orders",numeric:!0,sortable:!0}],yy=Array.from({length:17},(n,e)=>({region:["East","South","West","North"][e%4],revenue:91e3-e*2875,orders:420-e*11})),wf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],z2=wf.flatMap((n,e)=>[{month:n,plan:"Basic",revenue:120+e*26},{month:n,plan:"Pro",revenue:60+e*24},{month:n,plan:"Enterprise",revenue:e<2?0:10+e*12}]),V2=Array.from({length:48},(n,e)=>({x:e+1,y:(e+1)*1.6+Math.sin(e*78.233)*43758.5453%18,label:`Account ${e+1}`,series:e%2?"Returning":"New"})),W2=Array.from({length:400},(n,e)=>Math.abs(Math.sin(e*12.9898)*43758.5453%1)*100),H2=["East","South","West","North"].flatMap((n,e)=>wf.map((t,i)=>({x:t,y:n,value:(e+1)*(i+1)*7-(i%4===3?80:0)}))),gy=[{value:"orders.revenue",label:"Revenue"},{value:"orders.count",label:"Order count"},{value:"customers.count",label:"Customer count"},{value:"orders.margin",label:"Gross margin"}];function G2(){const[n,e]=k.useState("orders.revenue"),[t,i]=k.useState({}),[a,c]=k.useState(null),[f,p]=k.useState({"orders.region":["East","West"],"orders.status":["completed"]}),[m,g]=k.useState({from:"2025-01-01",to:"2025-06-30"}),[v,x]=k.useState("month"),[b,w]=k.useState("explore"),[_,C]=k.useState("previous"),[T,P]=k.useState("orders.revenue"),[U,E]=k.useState(["orders.revenue","orders.count"]),[F,A]=k.useState("apple"),[M,R]=k.useState(!0),[Y,z]=k.useState("explore"),[Q,W]=k.useState("2025-06-15"),[ne,X]=k.useState({from:"2025-06-01",to:"2025-06-21"}),le=k.useMemo(()=>U2(z2,{x:"month",y:"revenue",series:"plan"}),[]),[ie,ye]=k.useState({key:"revenue",dir:"desc"}),re=k.useMemo(()=>[...yy].sort((O,G)=>{const H=O[ie.key],N=G[ie.key],V=typeof H=="number"&&typeof N=="number"?H-N:String(H).localeCompare(String(N));return ie.dir==="asc"?V:-V}),[ie]);return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Sidemantic component gallery"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Canonical React primitives · ",u.jsx("a",{className:"text-accent hover:underline",href:"/typography",children:"typography workbench →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-8 p-4",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Metric cards"}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},selected:n==="orders.revenue",sparkValues:[31,42,38,55,60,74],onSelect:e}),u.jsx(Nr,{metric:"orders.count",label:"Order Count",value:447,selected:n==="orders.count",sparkValues:[21,34,28,41,44,51],onSelect:e}),u.jsx(Nr,{metric:"orders.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],selected:n==="orders.margin",onSelect:e})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Leaderboard cards"}),u.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-0 border-l border-t border-line",children:P2.filter(O=>a===null||a===O.dimension).map(O=>u.jsx(c0,{dimension:O.dimension,title:O.title,metricLabel:"Total Revenue",rows:O.rows,selectedValues:t[O.dimension],formatMetric:G=>pt(G,{format:"currency"}),onToggle:G=>i(H=>{const N=H[O.dimension]??[];return{...H,[O.dimension]:N.includes(G)?N.filter(V=>V!==G):[...N,G]}}),expanded:a===O.dimension,onExpandedChange:G=>c(G?O.dimension:null)},O.dimension))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Filters and controls"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{"data-testid":"gallery-filter-pills",className:"flex min-h-8 flex-wrap items-center gap-2",children:[Object.entries(f).flatMap(([O,G])=>G.map(H=>u.jsx($d,{dimension:O,value:H,onRemove:()=>p(N=>({...N,[O]:N[O].filter(V=>V!==H)}))},`${O}:${H}`))),Object.values(f).every(O=>O.length===0)?u.jsx("span",{className:"text-2xs text-faint",children:"No active filters"}):null]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Hv,{range:m,onChange:g,comparison:_,onComparisonChange:C}),u.jsx(zd,{grain:v,options:["day","week","month","quarter","year"],onChange:x}),u.jsx(Qv,{view:b,onChange:w}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"ok"})," Ready"]}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 text-2xs text-muted",children:[u.jsx(xd,{status:"loading"})," Updating"]}),u.jsx("button",{type:"button",onClick:()=>p({"orders.region":["East","West"],"orders.status":["completed"]}),className:"inline-flex h-7 items-center rounded-full border border-line px-3 text-xs text-muted hover:bg-surface-soft",children:"Reset filters"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Charts"}),u.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Sparkline"}),u.jsx(u0,{values:[31,42,38,55,60,74,69,83],labels:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"],ariaLabel:"Eight month revenue trend"})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Column chart"}),u.jsx(d0,{data:[{label:"East",value:83},{label:"South",value:81},{label:"West",value:72},{label:"Returns",value:-18}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Line chart compatibility export"}),u.jsx(b2,{data:[{label:"Jan",value:31},{label:"Feb",value:42},{label:"Mar",value:38},{label:"Apr",value:55},{label:"May",value:60}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Interactive time series"}),u.jsx(ra,{points:[31,42,38,55,60,74].map((O,G)=>({x:`2025-0${G+1}-01`,y:O})),comparison:[27,35,33,48,52,61].map((O,G)=>({x:`2024-0${G+1}-01`,y:O})),formatValue:O=>`$${O.toLocaleString()}k`})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Donut"}),u.jsx(_2,{data:[{label:"iOS",value:4200},{label:"Android",value:3100},{label:"Web",value:1900},{label:"Other",value:400}]})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Stacked area (long rows via rowsToSeries)"}),u.jsx(O2,{labels:le.labels,series:le.series,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Bar + line combo (dual axis)"}),u.jsx(h2,{data:wf.map((O,G)=>({label:O,bar:200+G*42,line:.02+G*.004})),barLabel:"Revenue",lineLabel:"Conversion",formatLine:O=>`${(O*100).toFixed(1)}%`,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Histogram"}),u.jsx(k2,{values:W2,bins:20})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Scatter"}),u.jsx(f0,{points:V2,xLabel:"Sessions",yLabel:"Orders",height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Heatmap"}),u.jsx(N2,{cells:H2,height:200})]}),u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Waterfall"}),u.jsx(R2,{data:[{label:"Gross",value:1e3,isTotal:!0},{label:"Refunds",value:-140},{label:"Discounts",value:-90},{label:"Upsells",value:130},{label:"Net",value:900,isTotal:!0}],height:200})]}),u.jsxs("article",{className:"min-w-0 xl:col-span-2",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold",children:"Network"}),u.jsx(C2,{nodes:[{id:"orders",group:"fact"},{id:"payments",group:"fact"},{id:"customers",group:"dimension"},{id:"products",group:"dimension"},{id:"regions",group:"dimension"}],links:[{source:"orders",target:"customers",weight:3},{source:"orders",target:"products",weight:2},{source:"orders",target:"regions"},{source:"payments",target:"orders",weight:2},{source:"payments",target:"customers"}],height:260})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Inputs"}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Ao,{variant:"primary",children:"Primary"}),u.jsx(Ao,{children:"Secondary"}),u.jsx(Ao,{variant:"ghost",children:"Ghost"}),u.jsx(Ao,{variant:"danger",children:"Danger"}),u.jsx(Ao,{size:"sm",children:"Small"}),u.jsx(Al,{label:"Fruit",value:F,onChange:A,options:[{value:"apple",label:"Apple"},{value:"banana",label:"Banana"},{value:"cherry",label:"Cherry"}]}),u.jsx(T2,{checked:M,onChange:R,label:"Compact rows"}),u.jsx(A2,{tabs:[{key:"explore",label:"Explore"},{key:"pivot",label:"Pivot"},{key:"sql",label:"SQL"}],active:Y,onChange:z}),u.jsx(B2,{content:"Revenue in USD, net of refunds",children:u.jsx("span",{className:"cursor-help text-2xs text-muted underline decoration-dotted",children:"What is revenue?"})})]}),u.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[u.jsx(dy,{value:T,onChange:P,options:gy,ariaLabel:"Metric"}),u.jsx(dy,{multiple:!0,values:U,onChange:E,options:gy,ariaLabel:"Metrics"}),u.jsx(hy,{mode:"single",value:Q,onChange:W,ariaLabel:"Date"}),u.jsx(hy,{mode:"range",value:ne,onChange:X,ariaLabel:"Range"})]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Analytical table"}),u.jsx(Ri,{columns:$2,rows:re,pageSize:6,sortKey:ie.key,sortDir:ie.dir,onSort:O=>ye(G=>({key:O,dir:G.key===O&&G.dir==="desc"?"asc":"desc"})),renderCell:(O,G)=>O.numeric?Number(G).toLocaleString():String(G),searchable:!0,totals:{region:"count",revenue:"sum",orders:"sum"}}),u.jsxs("div",{className:"mt-3",children:[u.jsx("h3",{className:"mb-2 text-xs font-semibold text-muted",children:"Distribution-friendly data preview"}),u.jsx(x2,{result:{columns:["region","revenue","orders"],sample_rows:yy.slice(0,8)},pageSize:4})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Query inspection"}),u.jsx(wc,{inputs:{Revenue:{metrics:["orders.revenue"],dimensions:["orders.region"],filters:["orders.status = 'completed'"]}},queries:{Revenue:`SELECT orders.region, SUM(orders.revenue) AS revenue FROM orders WHERE orders.status = 'completed' GROUP BY orders.region -ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(m2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],G2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Y2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],Q2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],K2=[31,42,38,55,60,74],J2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),q2=`select region, sum(revenue) as revenue +ORDER BY revenue DESC`}})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"States"}),u.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[u.jsx(bc,{message:"Loading metric results…"}),u.jsx(er,{message:"No matching rows."}),u.jsx(Li,{message:"The query could not be completed."})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-2 text-xs font-medium text-muted",children:"Dashboard shell"}),u.jsx("div",{children:u.jsx(y2,{eyebrow:"Embedded shell example",title:"Revenue overview",status:u.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[u.jsx(xd,{status:"ok"})," Connected"]}),toolbar:u.jsxs(u.Fragment,{children:[u.jsx($d,{dimension:"orders.region",value:"East"}),u.jsx(zd,{grain:v,options:["day","month","quarter"],onChange:x})]}),children:u.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[u.jsx(Nr,{metric:"orders.revenue",label:"Revenue",value:288291,format:{format:"currency"},sparkValues:[31,42,38,55,60]}),u.jsx(er,{title:"Optional panel",message:"Shell content is composed from the same primitives."})]})})})]})]})]})}function os(n){return`https://api.fontshare.com/v2/css?f[]=${n}&display=swap`}const vy=[{value:"system",label:"System (SF Pro)",stack:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"},{value:"geist",label:"Geist",gf:"Geist:wght@400;500;600",stack:"'Geist', system-ui, sans-serif"},{value:"inter",label:"Inter",gf:"Inter:wght@400;500;600",stack:"'Inter', system-ui, sans-serif"},{value:"instrument",label:"Instrument Sans",gf:"Instrument+Sans:wght@400;500;600",stack:"'Instrument Sans', system-ui, sans-serif"},{value:"plex",label:"IBM Plex Sans",gf:"IBM+Plex+Sans:wght@400;500;600",stack:"'IBM Plex Sans', system-ui, sans-serif"},{value:"schibsted",label:"Schibsted Grotesk",gf:"Schibsted+Grotesk:wght@400;500;600",stack:"'Schibsted Grotesk', system-ui, sans-serif"},{value:"figtree",label:"Figtree",gf:"Figtree:wght@400;500;600",stack:"'Figtree', system-ui, sans-serif"},{value:"manrope",label:"Manrope",gf:"Manrope:wght@400;500;600",stack:"'Manrope', system-ui, sans-serif"},{value:"publicsans",label:"Public Sans",gf:"Public+Sans:wght@400;500;600",stack:"'Public Sans', system-ui, sans-serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"satoshi",label:"Satoshi ✦",url:os("satoshi@400,500,700"),stack:"'Satoshi', system-ui, sans-serif"},{value:"generalsans",label:"General Sans ✦",url:os("general-sans@400,500,600"),stack:"'General Sans', system-ui, sans-serif"},{value:"switzer",label:"Switzer ✦",url:os("switzer@400,500,600"),stack:"'Switzer', system-ui, sans-serif"},{value:"cabinet",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@400,500,700"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"bricolage",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:wght@400;500;600",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"familjen",label:"Familjen Grotesk ✦",gf:"Familjen+Grotesk:wght@400;500;600",stack:"'Familjen Grotesk', system-ui, sans-serif"},{value:"hanken",label:"Hanken Grotesk ✦",gf:"Hanken+Grotesk:wght@400;500;600",stack:"'Hanken Grotesk', system-ui, sans-serif"},{value:"reddit",label:"Reddit Sans ✦",gf:"Reddit+Sans:wght@400;500;600",stack:"'Reddit Sans', system-ui, sans-serif"},{value:"chivo",label:"Chivo ✦",gf:"Chivo:wght@400;500;600",stack:"'Chivo', system-ui, sans-serif"},{value:"hostgrotesk",label:"Host Grotesk ✦",gf:"Host+Grotesk:wght@400;500;600",stack:"'Host Grotesk', system-ui, sans-serif"},{value:"sora",label:"Sora ✦",gf:"Sora:wght@400;500;600",stack:"'Sora', system-ui, sans-serif"}],xy=[{value:"system",label:"System (SF Mono)",stack:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},{value:"geistmono",label:"Geist Mono",gf:"Geist+Mono:wght@400;500",stack:"'Geist Mono', ui-monospace, monospace"},{value:"jetbrains",label:"JetBrains Mono",gf:"JetBrains+Mono:wght@400;500",stack:"'JetBrains Mono', ui-monospace, monospace"},{value:"plexmono",label:"IBM Plex Mono",gf:"IBM+Plex+Mono:wght@400;500",stack:"'IBM Plex Mono', ui-monospace, monospace"},{value:"firacode",label:"Fira Code",gf:"Fira+Code:wght@400;500",stack:"'Fira Code', ui-monospace, monospace"},{value:"splinemono",label:"Spline Sans Mono",gf:"Spline+Sans+Mono:wght@400;500",stack:"'Spline Sans Mono', ui-monospace, monospace"},{value:"dmmono",label:"DM Mono",gf:"DM+Mono:wght@400;500",stack:"'DM Mono', ui-monospace, monospace"},{value:"martianmono",label:"Martian Mono ✦",gf:"Martian+Mono:wght@400;500",stack:"'Martian Mono', ui-monospace, monospace"},{value:"fragment",label:"Fragment Mono ✦",gf:"Fragment+Mono",stack:"'Fragment Mono', ui-monospace, monospace"},{value:"redhatmono",label:"Red Hat Mono ✦",gf:"Red+Hat+Mono:wght@400;500",stack:"'Red Hat Mono', ui-monospace, monospace"},{value:"chivomono",label:"Chivo Mono ✦",gf:"Chivo+Mono:wght@400;500",stack:"'Chivo Mono', ui-monospace, monospace"},{value:"azeret",label:"Azeret Mono ✦",gf:"Azeret+Mono:wght@400;500",stack:"'Azeret Mono', ui-monospace, monospace"},{value:"spacemono",label:"Space Mono ✦",gf:"Space+Mono:wght@400;700",stack:"'Space Mono', ui-monospace, monospace"}],by=[{value:"sans",label:"Same as sans",stack:""},{value:"newsreader",label:"Newsreader (serif)",gf:"Newsreader:opsz,wght@6..72,400..700",stack:"'Newsreader', Georgia, serif"},{value:"sourceserif",label:"Source Serif 4",gf:"Source+Serif+4:opsz,wght@8..60,400..700",stack:"'Source Serif 4', Georgia, serif"},{value:"fraunces",label:"Fraunces",gf:"Fraunces:opsz,wght@9..144,400..700",stack:"'Fraunces', Georgia, serif"},{value:"instrumentserif",label:"Instrument Serif",gf:"Instrument+Serif",stack:"'Instrument Serif', Georgia, serif"},{value:"spacegrotesk",label:"Space Grotesk",gf:"Space+Grotesk:wght@400;500;600",stack:"'Space Grotesk', system-ui, sans-serif"},{value:"clash",label:"Clash Display ✦",url:os("clash-display@400,500,600"),stack:"'Clash Display', system-ui, sans-serif"},{value:"cabinetdisplay",label:"Cabinet Grotesk ✦",url:os("cabinet-grotesk@500,700,800"),stack:"'Cabinet Grotesk', system-ui, sans-serif"},{value:"sentient",label:"Sentient (serif) ✦",url:os("sentient@400,500,700"),stack:"'Sentient', Georgia, serif"},{value:"gambetta",label:"Gambetta (serif) ✦",url:os("gambetta@400,500,700"),stack:"'Gambetta', Georgia, serif"},{value:"bricolagedisplay",label:"Bricolage Grotesque ✦",gf:"Bricolage+Grotesque:opsz,wght@12..96,400..700",stack:"'Bricolage Grotesque', system-ui, sans-serif"},{value:"youngserif",label:"Young Serif ✦",gf:"Young+Serif",stack:"'Young Serif', Georgia, serif"},{value:"unbounded",label:"Unbounded ✦",gf:"Unbounded:wght@400;500;600",stack:"'Unbounded', system-ui, sans-serif"}],Y2=[{label:"Geist / Geist Mono",sans:"geist",mono:"geistmono",display:"sans"},{label:"Inter / JetBrains",sans:"inter",mono:"jetbrains",display:"sans"},{label:"IBM Plex",sans:"plex",mono:"plexmono",display:"sans"},{label:"Instrument / Spline",sans:"instrument",mono:"splinemono",display:"sans"},{label:"Schibsted / Fira",sans:"schibsted",mono:"firacode",display:"sans"},{label:"Editorial: Geist + Newsreader",sans:"geist",mono:"geistmono",display:"newsreader"},{label:"Satoshi / Martian ✦",sans:"satoshi",mono:"martianmono",display:"sans"},{label:"General Sans / Fragment ✦",sans:"generalsans",mono:"fragment",display:"sans"},{label:"Switzer + Clash headings ✦",sans:"switzer",mono:"redhatmono",display:"clash"},{label:"Cabinet + Gambetta ✦",sans:"cabinet",mono:"chivomono",display:"gambetta"},{label:"Bricolage all the way ✦",sans:"bricolage",mono:"spacemono",display:"bricolagedisplay"}],wy=new Set;function kd(n){if(!n)return;const e=n.url??(n.gf?`https://fonts.googleapis.com/css2?family=${n.gf}&display=swap`:void 0);if(!e||wy.has(e))return;wy.add(e);const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}function Id(n,e){return n.find(t=>t.value===e)??n[0]}const Q2=[{px:"8",cls:"text-[8px]",usage:"MetricCard delta arrow glyph",sample:"▲"},{px:"9",cls:"text-[9px]",usage:"DataTable sort direction glyph",sample:"▲▼"},{px:"10",cls:"text-[10px]",usage:"Chart axis labels (all 9 charts)",sample:"Jan Feb Mar 12.4k 18.2k"},{px:"11",cls:"text-2xs",usage:"Captions, chips, table body, helper text (58 uses)",sample:"Canonical React primitives · updated 2h ago"},{px:"12",cls:"text-xs",usage:"Controls, labels, leaderboard rows — the workhorse (70 uses)",sample:"Revenue by region, last 28 days"},{px:"13",cls:"text-sm",usage:"Section titles, panel headers (9 uses); also the body default",sample:"Customer Region"},{px:"14",cls:"text-base",usage:"Explore index page title (1 use)",sample:"Explore"},{px:"19",cls:"text-[19px]",usage:"MetricCard value",sample:"$288,291"},{px:"20",cls:"text-xl",usage:"MetricTimeSeries headline total",sample:"$1,282,392"},{px:"24",cls:"text-2xl",usage:"DashboardShell page title",sample:"Revenue overview"}],K2=[{name:"A — Current",note:"11 / 12 / 13 base. Dense, reads small on 27″ displays.",caption:11,label:12,body:13,section:13,value:19,headline:20,title:24},{name:"B — One up",note:"12 / 13 / 14 base. Same hierarchy, comfortably legible.",caption:12,label:13,body:14,section:14,value:22,headline:24,title:28},{name:"C — Quiet UI, loud numbers",note:"Keeps the dense chrome, doubles down on data: bigger values and titles.",caption:11,label:12,body:13,section:13,value:24,headline:28,title:30}],J2=[31,42,38,55,60,74],q2=Array.from({length:12},(n,e)=>({x:`2025-${String(e+1).padStart(2,"0")}-01`,y:96e3+e*14e3+e%3*9e3})),Z2=`select region, sum(revenue) as revenue from orders where created_at >= date '2025-01-01' group by all -order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function Z2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:G2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:K2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:J2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:q2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Y2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:Q2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}c_();const h0=document.getElementById("root");if(!h0)throw new Error("Missing #root element");vb.createRoot(h0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(H2,{}):window.location.pathname==="/typography"?u.jsx(Z2,{}):u.jsx(d2,{})})); +order by revenue desc`;function Sy({family:n,size:e}){return u.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",style:{fontFamily:n},children:[u.jsx("span",{className:`${e} font-normal`,children:"Regular 400 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-medium`,children:"Medium 500 — Revenue by payment method"}),u.jsx("span",{className:`${e} font-semibold`,children:"Semibold 600 — Revenue by payment method"})]})}function X2(){const[n,e]=k.useState("geist"),[t,i]=k.useState("geistmono"),[a,c]=k.useState("sans"),f=Id(vy,n),p=Id(xy,t),m=Id(by,a),g=m.stack||f.stack;k.useEffect(()=>{kd(f),kd(p),kd(m)},[f,p,m]);const v={"--font-sans":f.stack,"--font-mono":p.stack,"--font-display":g,fontFamily:"var(--font-sans)"};return u.jsxs("main",{className:"min-h-screen bg-bg text-ink",children:[u.jsxs("header",{className:"sticky top-0 z-20 flex items-center justify-between gap-3 border-b border-line bg-surface px-4 py-3",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-sm font-semibold",children:"Typography workbench"}),u.jsxs("p",{className:"text-2xs text-faint",children:["Pick faces, judge them on real components · ",u.jsx("a",{className:"text-accent hover:underline",href:"/components",children:"component gallery →"})]})]}),u.jsx(Zo,{})]}),u.jsxs("div",{className:"space-y-10 p-4",children:[u.jsx("section",{children:u.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[u.jsx(Al,{label:"Sans",value:n,options:vy.map(({value:x,label:b})=>({value:x,label:b})),onChange:e}),u.jsx(Al,{label:"Mono",value:t,options:xy.map(({value:x,label:b})=>({value:x,label:b})),onChange:i}),u.jsx(Al,{label:"Headings",value:a,options:by.map(({value:x,label:b})=>({value:x,label:b})),onChange:c}),u.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:Y2.map(x=>{const b=x.sans===n&&x.mono===t&&x.display===a;return u.jsx("button",{type:"button","data-selected":b||void 0,onClick:()=>{e(x.sans),i(x.mono),c(x.display)},className:`inline-flex h-7 items-center rounded-full border px-3 text-xs transition-colors ${b?"border-accent text-accent":"border-line bg-surface text-muted hover:border-line-strong"}`,children:x.label},x.label)})})]})}),u.jsxs("div",{style:v,className:"space-y-10",children:[u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"In context"}),u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-2xs text-faint",children:"Acme Analytics · production"}),u.jsx("h1",{className:"mt-1 text-2xl font-semibold text-ink",children:"Revenue overview"}),u.jsx("div",{className:"text-sm text-muted",children:"Updated 2 minutes ago · 448,214 rows scanned"})]}),u.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[u.jsx(Nr,{metric:"t.revenue",label:"Revenue",value:288291,format:{format:"currency"},delta:{label:"+12.4%",tone:"positive"},comparison:"vs previous month",sparkValues:J2,selected:!0,onSelect:()=>{}}),u.jsx(Nr,{metric:"t.orders",label:"Order Count",value:447,delta:{label:"-2.1%",tone:"negative"},comparison:"vs previous month",sparkValues:[21,34,28,41,44,38],onSelect:()=>{}}),u.jsx(Nr,{metric:"t.margin",label:"Gross Margin",value:.324,format:{format:"percent"},delta:{label:"+1.1pt",tone:"positive"},comparison:"vs previous month",sparkValues:[24,26,29,27,31,32],onSelect:()=>{}})]}),u.jsx(ra,{points:q2,formatValue:x=>`$${Math.round(x).toLocaleString("en-US")}`,formatAxis:x=>`$${Math.round(x/1e3)}k`,formatLabel:x=>x.slice(0,7),ariaLabel:"Twelve month revenue trend"}),u.jsxs("div",{className:"max-w-xl",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:"How the comparison works"}),u.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"The overlay shifts the previous period onto the current axis so both lines share a scale. Deltas are computed on the visible range only — zooming recomputes them. Hover any point for the exact pair of values; the quiet gray line is always the older period."})]}),u.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-5 text-muted",children:Z2})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Numerals — mono, tabular"}),u.jsxs("div",{className:"flex flex-wrap gap-12",children:[u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["$1,204,918.24","$984,003.10","$88,214.00","$1,111,111.11"].map(x=>u.jsx("div",{className:"text-right",children:x},x))}),u.jsx("div",{className:"font-mono tnum text-sm text-ink",children:["2025-06-30 23:59:59","2025-07-01 00:00:00","2025-12-31 08:15:42"].map(x=>u.jsx("div",{children:x},x))}),u.jsxs("div",{className:"font-mono text-sm text-ink",children:["0O · 1lI · 5S · 8B · ","->"," ","=>"," ","!="," ",">="]})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Weights in use — 400 / 500 / 600 (no bold anywhere)"}),u.jsxs("div",{className:"space-y-2 text-ink",children:[u.jsx(Sy,{family:"var(--font-sans)",size:"text-sm"}),u.jsx(Sy,{family:"var(--font-sans)",size:"text-xs"}),u.jsx("div",{className:"text-xl font-semibold",style:{fontFamily:"var(--font-display)"},children:"Display 600 — Quarterly revenue, all regions"})]})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Current ramp — every size in the app and where it appears"}),u.jsx("div",{className:"space-y-1.5",children:Q2.map(x=>u.jsxs("div",{className:"grid grid-cols-[3rem_7rem_1fr_1.2fr] items-baseline gap-3",children:[u.jsxs("span",{className:"font-mono tnum text-2xs text-faint",children:[x.px,"px"]}),u.jsx("span",{className:"font-mono text-2xs text-faint",children:x.cls}),u.jsx("span",{className:"truncate text-ink",style:{fontSize:`${x.px}px`,lineHeight:1.3},children:x.sample}),u.jsx("span",{className:"text-2xs text-faint",children:x.usage})]},x.px))})]}),u.jsxs("section",{children:[u.jsx("h2",{className:"mb-3 text-xs font-medium text-muted",children:"Size ramp candidates"}),u.jsx("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-3",children:K2.map(x=>u.jsxs("article",{className:"min-w-0",children:[u.jsx("h3",{className:"text-sm font-semibold text-ink",children:x.name}),u.jsx("p",{className:"mt-0.5 text-2xs text-faint",children:x.note}),u.jsxs("div",{className:"mt-3 space-y-2",children:[u.jsxs("div",{className:"text-faint",style:{fontSize:x.caption,lineHeight:1.3},children:["Caption ",x.caption,"px · vs previous month"]}),u.jsxs("div",{className:"text-muted",style:{fontSize:x.label,lineHeight:1.35},children:["Label ",x.label,"px · Revenue by region"]}),u.jsxs("div",{className:"text-ink",style:{fontSize:x.body,lineHeight:1.45},children:["Body ",x.body,"px · The overlay shifts the previous period onto the current axis so both lines share a scale."]}),u.jsxs("div",{className:"font-semibold text-ink",style:{fontSize:x.section,lineHeight:1.35},children:["Section title ",x.section,"px"]}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.value,lineHeight:1.15},children:"$288,291"}),u.jsx("div",{className:"font-mono tnum font-semibold text-ink",style:{fontSize:x.headline,lineHeight:1.15},children:"$1,282,392"}),u.jsx("div",{className:"font-semibold text-ink",style:{fontFamily:"var(--font-display)",fontSize:x.title,lineHeight:1.2,letterSpacing:"-0.025em"},children:"Revenue overview"})]})]},x.name))})]})]})]})]})}u_();const m0=document.getElementById("root");if(!m0)throw new Error("Missing #root element");xb.createRoot(m0).render(u.jsx(k.StrictMode,{children:window.location.pathname==="/components"?u.jsx(G2,{}):window.location.pathname==="/typography"?u.jsx(X2,{}):u.jsx(f2,{})})); diff --git a/sidemantic/ui/static/assets/index-DBXs5BBH.css b/sidemantic/ui/static/assets/index-DBXs5BBH.css new file mode 100644 index 000000000..e6340e97b --- /dev/null +++ b/sidemantic/ui/static/assets/index-DBXs5BBH.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans, sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--font-mono, monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1 / -1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0px}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\,var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[min\(25dvh\,8rem\)\]{max-height:min(25dvh,8rem)}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\,320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0px}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\,minmax\(220px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0px}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:#00000059}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono, monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal: ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\,0\,0\,0\.16\)\]{--tw-shadow: 0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored: 0 -8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color: var(--shadow);--tw-shadow: var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color: var(--shadow-sm);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur: blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans: "Geist Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;--font-display: var(--font-sans)}:root,:root[data-theme=light]{--bg: #f6f5f1;--surface: #ffffff;--surface-soft: #f0eee8;--ink: #1b1917;--muted: #45403a;--faint: #8b8378;--line: #e7e4dd;--line-strong: #d8d2c8;--accent: #8a6116;--accent-hover: #6d4c0f;--accent-soft: #fff6e2;--focus: #1b1917;--danger: #dc2626;--danger-soft: rgba(239, 68, 68, .1);--success: #047857;--success-soft: rgba(16, 185, 129, .1);--chart-primary: #5b7fa6;--chart-primary-soft: rgba(91, 127, 166, .16);--chart-primary-selected: rgba(91, 127, 166, .26);--viz-1: #5b7fa6;--viz-2: #6fa287;--viz-3: #c06e52;--viz-4: #d9a441;--viz-5: #8b7bb0;--viz-6: #c98ba4;--viz-7: #5fa3a8;--shadow-sm: 0 1px 2px 0 rgba(27, 25, 23, .04), 0 1px 3px 0 rgba(27, 25, 23, .06);--shadow: 0 8px 18px -12px rgba(27, 25, 23, .18), 0 2px 8px -4px rgba(27, 25, 23, .12);color-scheme:light}:root[data-theme=dark]{--bg: #141312;--surface: #1c1a18;--surface-soft: #25231f;--ink: #f4f2ee;--muted: #d8d2c8;--faint: #958c80;--line: #2e2b27;--line-strong: #423d36;--accent: #f1bd5b;--accent-hover: #f6d083;--accent-soft: #342817;--focus: #f4f2ee;--danger: #f87171;--danger-soft: rgba(248, 113, 113, .15);--success: #6ee7b7;--success-soft: rgba(52, 211, 153, .15);--chart-primary: #7a9cc0;--chart-primary-soft: rgba(122, 156, 192, .2);--chart-primary-selected: rgba(122, 156, 192, .32);--viz-1: #7a9cc0;--viz-2: #8cbba1;--viz-3: #d98a6e;--viz-4: #e7b95c;--viz-5: #a796c8;--viz-6: #d9a4bc;--viz-7: #7cbec3;--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 1px 2px -1px rgba(0, 0, 0, .3);--shadow: 0 10px 18px -12px rgba(0, 0, 0, .45), 0 2px 8px -4px rgba(0, 0, 0, .35);color-scheme:dark}html,body,#root{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),summary:not([aria-disabled=true]),select:not(:disabled){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}*::-webkit-scrollbar{width:9px;height:9px}*::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}*::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(360deg)}}.spinner{animation:spin .7s linear infinite}@media(hover:hover)and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media(pointer:coarse){button,summary,select,input:not([type=checkbox]):not([type=radio]){min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-row,.leaderboard-expand,.table-sort,.table-pager-button{min-height:44px}.table-pager-button{min-width:44px}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0px}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1 / -1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media(prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media(min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media(min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\,1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media(min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/sidemantic/ui/static/index.html b/sidemantic/ui/static/index.html index 55587f6f8..6536f910e 100644 --- a/sidemantic/ui/static/index.html +++ b/sidemantic/ui/static/index.html @@ -4,8 +4,8 @@ Sidemantic - - + +
diff --git a/sidemantic/widget/static/widget.css b/sidemantic/widget/static/widget.css index 5e531d134..f4ae769a9 100644 --- a/sidemantic/widget/static/widget.css +++ b/sidemantic/widget/static/widget.css @@ -1,5 +1,5 @@ /* Generated from the canonical UI distribution and js/widget.css. */ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--line)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-sans,sans-serif);font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono,monospace);font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.bottom-0{bottom:0}.left-0{left:0}.left-\[14px\]{left:14px}.left-\[2px\]{left:2px}.right-0{right:0}.right-1{right:.25rem}.top-0{top:0}.top-1\/2{top:50%}.top-8{top:2rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.col-span-full{grid-column:1/-1}.float-right{float:right}.-m-1{margin:-.25rem}.-mx-3\.5{margin-left:-.875rem;margin-right:-.875rem}.mx-auto{margin-left:auto;margin-right:auto}.-mr-0\.5{margin-right:-.125rem}.mb-0\.5{margin-bottom:.125rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-auto{margin-left:auto}.mr-0\.5{margin-right:.125rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-5{margin-top:1.25rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.size-10{width:2.5rem;height:2.5rem}.size-2{width:.5rem;height:.5rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-7{width:1.75rem;height:1.75rem}.h-0{height:0}.h-0\.5{height:.125rem}.h-11{height:2.75rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-\[200px\]{height:200px}.h-\[220px\]{height:220px}.h-\[240px\]{height:240px}.h-\[280px\]{height:280px}.h-\[320px\]{height:320px}.h-full{height:100%}.h-screen{height:100vh}.max-h-56{max-height:14rem}.max-h-72{max-height:18rem}.max-h-\[45vh\]{max-height:45vh}.max-h-\[min\(24rem\2c var\(--filter-popover-height\)\)\]{max-height:min(24rem,var(--filter-popover-height))}.max-h-\[min\(25dvh\2c 8rem\)\]{max-height:min(25dvh,8rem)}.max-h-\[var\(--filter-popover-height\)\]{max-height:var(--filter-popover-height)}.min-h-0{min-height:0}.min-h-12{min-height:3rem}.min-h-32{min-height:8rem}.min-h-40{min-height:10rem}.min-h-64{min-height:16rem}.min-h-8{min-height:2rem}.min-h-9{min-height:2.25rem}.min-h-\[200px\]{min-height:200px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-36{width:9rem}.w-56{width:14rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-80{width:20rem}.w-96{width:24rem}.w-\[min\(88vw\2c 320px\)\]{width:min(88vw,320px)}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.min-w-0{min-width:0}.min-w-28{min-width:7rem}.min-w-32{min-width:8rem}.min-w-40{min-width:10rem}.min-w-full{min-width:100%}.max-w-32{max-width:8rem}.max-w-5xl{max-width:64rem}.max-w-64{max-width:16rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[11rem\]{max-width:11rem}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.-translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y:-50%}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-help{cursor:help}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-\[3rem_7rem_1fr_1\.2fr\]{grid-template-columns:3rem 7rem 1fr 1.2fr}.grid-cols-\[minmax\(0\2c 1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.grid-cols-\[minmax\(0\2c 1fr\)_auto_auto\]{grid-template-columns:minmax(0,1fr) auto auto}.grid-cols-\[repeat\(auto-fit\2c minmax\(220px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-cols-\[repeat\(auto-fit\2c minmax\(260px\2c 1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-8{gap:2rem}.gap-px{gap:1px}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.375rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem*var(--tw-space-y-reverse))}.space-y-10>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2.5rem*var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem*var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem*var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(2rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem*var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-b-0{border-bottom-width:0}.border-l{border-left-width:1px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-accent{border-color:var(--accent)}.border-danger{border-color:var(--danger)}.border-faint{border-color:var(--faint)}.border-line{border-color:var(--line)}.border-transparent{border-color:transparent}.border-l-transparent{border-left-color:transparent}.bg-accent{background-color:var(--accent)}.bg-accent-soft{background-color:var(--accent-soft)}.bg-bg{background-color:var(--bg)}.bg-black\/35{background-color:rgba(0,0,0,.35)}.bg-chart-primary{background-color:var(--chart-primary)}.bg-chart-primary-soft{background-color:var(--chart-primary-soft)}.bg-danger-soft{background-color:var(--danger-soft)}.bg-faint{background-color:var(--faint)}.bg-line{background-color:var(--line)}.bg-success{background-color:var(--success)}.bg-surface{background-color:var(--surface)}.bg-surface-soft{background-color:var(--surface-soft)}.bg-transparent{background-color:transparent}.fill-accent{fill:var(--accent)}.fill-chart-primary{fill:var(--chart-primary)}.fill-danger{fill:var(--danger)}.fill-faint{fill:var(--faint)}.fill-ink{fill:var(--ink)}.fill-muted{fill:var(--muted)}.stroke-faint{stroke:var(--faint)}.stroke-line{stroke:var(--line)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-px{padding:1px}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-5{padding-top:1.25rem;padding-bottom:1.25rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-1{padding-top:.25rem}.pt-2{padding-top:.5rem}.pt-2\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono,monospace)}.text-2xl{font-size:1.5rem;line-height:2rem}.text-2xs{font-size:11px;line-height:1.3}.text-\[10px\]{font-size:10px}.text-\[19px\]{font-size:19px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-base{font-size:14px;line-height:1.45}.text-sm{font-size:13px;line-height:1.4}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:12px;line-height:1.35}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-accent{color:var(--accent)}.text-chart-primary{color:var(--chart-primary)}.text-danger{color:var(--danger)}.text-faint{color:var(--faint)}.text-ink{color:var(--ink)}.text-muted{color:var(--muted)}.text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.text-success{color:var(--success)}.text-surface{color:var(--surface)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.underline{text-decoration-line:underline}.decoration-dotted{text-decoration-style:dotted}.underline-offset-2{text-underline-offset:2px}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-\[0_-8px_24px_rgba\(0\2c 0\2c 0\2c 0\.16\)\]{--tw-shadow:0 -8px 24px rgba(0,0,0,.16);--tw-shadow-colored:0 -8px 24px var(--tw-shadow-color)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-\[var\(--shadow\)\]{--tw-shadow-color:var(--shadow);--tw-shadow:var(--tw-shadow-colored)}.shadow-\[var\(--shadow-sm\)\]{--tw-shadow-color:var(--shadow-sm);--tw-shadow:var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\!filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[2px\]{--tw-backdrop-blur:blur(2px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[left\]{transition-property:left;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--font-sans:"Geist Sans",Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--font-mono:"Geist Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--font-display:var(--font-sans)}:root,:root[data-theme=light]{--bg:#f6f5f1;--surface:#fff;--surface-soft:#f0eee8;--ink:#1b1917;--muted:#45403a;--faint:#8b8378;--line:#e7e4dd;--line-strong:#d8d2c8;--accent:#8a6116;--accent-hover:#6d4c0f;--accent-soft:#fff6e2;--focus:#1b1917;--danger:#dc2626;--danger-soft:rgba(239,68,68,.1);--success:#047857;--success-soft:rgba(16,185,129,.1);--chart-primary:#5b7fa6;--chart-primary-soft:rgba(91,127,166,.16);--chart-primary-selected:rgba(91,127,166,.26);--viz-1:#5b7fa6;--viz-2:#6fa287;--viz-3:#c06e52;--viz-4:#d9a441;--viz-5:#8b7bb0;--viz-6:#c98ba4;--viz-7:#5fa3a8;--shadow-sm:0 1px 2px 0 rgba(27,25,23,.04),0 1px 3px 0 rgba(27,25,23,.06);--shadow:0 8px 18px -12px rgba(27,25,23,.18),0 2px 8px -4px rgba(27,25,23,.12);color-scheme:light}:root[data-theme=dark]{--bg:#141312;--surface:#1c1a18;--surface-soft:#25231f;--ink:#f4f2ee;--muted:#d8d2c8;--faint:#958c80;--line:#2e2b27;--line-strong:#423d36;--accent:#f1bd5b;--accent-hover:#f6d083;--accent-soft:#342817;--focus:#f4f2ee;--danger:#f87171;--danger-soft:hsla(0,91%,71%,.15);--success:#6ee7b7;--success-soft:rgba(52,211,153,.15);--chart-primary:#7a9cc0;--chart-primary-soft:rgba(122,156,192,.2);--chart-primary-selected:rgba(122,156,192,.32);--viz-1:#7a9cc0;--viz-2:#8cbba1;--viz-3:#d98a6e;--viz-4:#e7b95c;--viz-5:#a796c8;--viz-6:#d9a4bc;--viz-7:#7cbec3;--shadow-sm:0 1px 3px 0 rgba(0,0,0,.3),0 1px 2px -1px rgba(0,0,0,.3);--shadow:0 10px 18px -12px rgba(0,0,0,.45),0 2px 8px -4px rgba(0,0,0,.35);color-scheme:dark}#root,body,html{height:100%}body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:13px;line-height:1.4;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select,summary{touch-action:manipulation}button,input,select{font:inherit}button:not(:disabled),select:not(:disabled),summary:not([aria-disabled=true]){cursor:pointer}button:disabled,input:disabled,select:disabled{cursor:not-allowed}h1{letter-spacing:-.025em}h2,h3{letter-spacing:-.018em}h1,h2,h3{font-family:var(--font-display)}.tnum{font-feature-settings:"tnum";font-variant-numeric:tabular-nums}:focus-visible{outline:2px solid var(--focus);outline-offset:2px}::-moz-selection{background:var(--accent-soft)}::selection{background:var(--accent-soft)}*{scrollbar-width:thin;scrollbar-color:var(--line) transparent}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background:var(--line);border-radius:6px;border:2px solid var(--bg)}::-webkit-scrollbar-thumb:hover{background:var(--faint)}@keyframes skeleton-pulse{0%{background-position:-200% 0}to{background-position:200% 0}}.skeleton{background:linear-gradient(90deg,var(--surface-soft) 25%,var(--line) 37%,var(--surface-soft) 63%);background-size:200% 100%;animation:skeleton-pulse 1.4s ease-in-out infinite;border-radius:4px}@keyframes spin{to{transform:rotate(1turn)}}.spinner{animation:spin .7s linear infinite}@media (hover:hover) and (pointer:fine){.leaderboard-row:hover{background-color:var(--surface-soft)}}@media (pointer:coarse){button,input:not([type=checkbox]):not([type=radio]),select,summary{min-height:44px}input:not([type=checkbox]):not([type=radio]),select{font-size:16px}button[aria-label]{min-width:44px}.leaderboard-expand,.leaderboard-row,.table-pager-button,.table-sort{min-height:44px}.table-pager-button{min-width:44px}}@media (prefers-reduced-motion:reduce){*,:after,:before{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.skeleton,.spinner{animation:none}}.placeholder\:text-faint::-moz-placeholder{color:var(--faint)}.placeholder\:text-faint::placeholder{color:var(--faint)}.first\:border-l-0:first-child{border-left-width:0}.hover\:border-accent:hover{border-color:var(--accent)}.hover\:border-danger:hover{border-color:var(--danger)}.hover\:border-faint:hover{border-color:var(--faint)}.hover\:border-line-strong:hover{border-color:var(--line-strong)}.hover\:bg-accent:hover{background-color:var(--accent)}.hover\:bg-danger:hover{background-color:var(--danger)}.hover\:bg-line:hover{background-color:var(--line)}.hover\:bg-surface-soft:hover{background-color:var(--surface-soft)}.hover\:text-accent:hover{color:var(--accent)}.hover\:text-danger:hover{color:var(--danger)}.hover\:text-ink:hover{color:var(--ink)}.hover\:text-surface:hover{color:var(--surface)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-75:hover{opacity:.75}.focus\:border-accent:focus{border-color:var(--accent)}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.aria-selected\:border-accent[aria-selected=true]{border-color:var(--accent)}.aria-selected\:bg-bg[aria-selected=true]{background-color:var(--bg)}.aria-selected\:text-ink[aria-selected=true]{color:var(--ink)}.data-\[expanded\=true\]\:col-span-full[data-expanded=true]{grid-column:1/-1}.data-\[selected\=true\]\:border-accent[data-selected=true]{border-color:var(--accent)}.data-\[selected\=true\]\:border-l-accent[data-selected=true]{border-left-color:var(--accent)}.data-\[active\=true\]\:bg-accent-soft[data-active=true]{background-color:var(--accent-soft)}.data-\[active\=true\]\:bg-surface-soft[data-active=true]{background-color:var(--surface-soft)}.data-\[selected\=true\]\:bg-accent-soft[data-selected=true]{background-color:var(--accent-soft)}.data-\[selected\=true\]\:bg-chart-primary-selected[data-selected=true]{background-color:var(--chart-primary-selected)}.data-\[active\=true\]\:text-accent[data-active=true]{color:var(--accent)}.data-\[active\=true\]\:text-ink[data-active=true]{color:var(--ink)}.data-\[selected\=true\]\:text-accent[data-selected=true]{color:var(--accent)}@media (prefers-reduced-motion:no-preference){@keyframes pulse{50%{opacity:.5}}.motion-safe\:animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}}@media (min-width:640px){.sm\:inline{display:inline}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:static{position:static}.md\:z-auto{z-index:auto}.md\:w-auto{width:auto}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-\[260px_minmax\(0\2c 1fr\)\]{grid-template-columns:260px minmax(0,1fr)}.md\:flex-row{flex-direction:row}.md\:flex-nowrap{flex-wrap:nowrap}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:gap-3{gap:.75rem}.md\:border-r{border-right-width:1px}.md\:border-line{border-color:var(--line)}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} /* AnyWidget host layout layered on top of the canonical UI distribution. */ /* Ported from the sidemantic-demo */ diff --git a/sidemantic/widget/static/widget.js b/sidemantic/widget/static/widget.js index 493e6cfba..7f91b9667 100644 --- a/sidemantic/widget/static/widget.js +++ b/sidemantic/widget/static/widget.js @@ -1,20 +1,20 @@ -var _w=Object.defineProperty;var fi=(t,e)=>{for(var n in e)_w(t,n,{get:e[n],enumerable:!0})};function Yp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(t){return this instanceof Z?(this.v=t,this):new Z(t)}function Tt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(w){return Promise.resolve(w).then(v,d)}}function a(v,w){r[v]&&(i[v]=function(I){return new Promise(function(Y,h){s.push([v,I,Y,h])>1||l(v,I)})},w&&(i[v]=w(i[v])))}function l(v,w){try{u(r[v](w))}catch(I){y(s[0][3],I)}}function u(v){v.value instanceof Z?Promise.resolve(v.value.v).then(c,d):y(s[0][2],v)}function c(v){l("next",v)}function d(v){l("throw",v)}function y(v,w){v(w),s.shift(),s.length&&l(s[0][0],s[0][1])}}function es(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:Z(t[i](o)),done:!1}:s?s(o):o}:s}}function rn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hp=="function"?Hp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Et,memcpy:()=>uo,rebaseValueOffsets:()=>il,toArrayBufferView:()=>J,toArrayBufferViewAsyncIterator:()=>on,toArrayBufferViewIterator:()=>En,toBigInt64Array:()=>rl,toBigUint64Array:()=>Tw,toFloat32Array:()=>Ow,toFloat32ArrayAsyncIterator:()=>Hw,toFloat32ArrayIterator:()=>Uw,toFloat64Array:()=>Ew,toFloat64ArrayAsyncIterator:()=>Yw,toFloat64ArrayIterator:()=>Rw,toInt16Array:()=>Bw,toInt16ArrayAsyncIterator:()=>zw,toInt16ArrayIterator:()=>Aw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>Vw,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Iw,toInt8ArrayAsyncIterator:()=>jw,toInt8ArrayIterator:()=>kw,toUint16Array:()=>Dw,toUint16ArrayAsyncIterator:()=>$w,toUint16ArrayIterator:()=>Mw,toUint32Array:()=>Nw,toUint32ArrayAsyncIterator:()=>Ww,toUint32ArrayIterator:()=>Cw,toUint8Array:()=>V,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>Fw,toUint8ClampedArrayAsyncIterator:()=>Kw,toUint8ClampedArrayIterator:()=>Pw});var ww=new TextDecoder("utf-8"),ao=t=>ww.decode(t),Sw=new TextEncoder,On=t=>Sw.encode(t);var bw=t=>typeof t=="number",Kp=t=>typeof t=="boolean",je=t=>typeof t=="function",ct=t=>t!=null&&Object(t)===t,Ot=t=>ct(t)&&je(t.then);var sn=t=>ct(t)&&je(t[Symbol.iterator]),Wt=t=>ct(t)&&je(t[Symbol.asyncIterator]),Za=t=>ct(t)&&ct(t.schema);var Ja=t=>ct(t)&&"done"in t&&"value"in t;var qa=t=>ct(t)&&je(t.stat)&&bw(t.fd);var el=t=>ct(t)&&lo(t.body),tl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Qp=t=>ct(t)&&je(t.abort)&&je(t.getWriter)&&!tl(t),lo=t=>ct(t)&&je(t.cancel)&&je(t.getReader)&&!tl(t),Gp=t=>ct(t)&&je(t.end)&&je(t.write)&&Kp(t.writable)&&!tl(t),nl=t=>ct(t)&&je(t.read)&&je(t.pipe)&&Kp(t.readable)&&!tl(t),Xp=t=>ct(t)&&je(t.clear)&&je(t.bytes)&&je(t.position)&&je(t.setPosition)&&je(t.capacity)&&je(t.getBufferIdentifier)&&je(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function xw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+d.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lJ(Int8Array,t),Bw=t=>J(Int16Array,t),di=t=>J(Int32Array,t),rl=t=>J(BigInt64Array,t),V=t=>J(Uint8Array,t),Dw=t=>J(Uint16Array,t),Nw=t=>J(Uint32Array,t),Tw=t=>J(BigUint64Array,t),Ow=t=>J(Float32Array,t),Ew=t=>J(Float64Array,t),Fw=t=>J(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*En(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):sn(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield J(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var kw=t=>En(Int8Array,t),Aw=t=>En(Int16Array,t),Lw=t=>En(Int32Array,t),df=t=>En(Uint8Array,t),Mw=t=>En(Uint16Array,t),Cw=t=>En(Uint32Array,t),Uw=t=>En(Float32Array,t),Rw=t=>En(Float64Array,t),Pw=t=>En(Uint8ClampedArray,t);function on(t,e){return Tt(this,arguments,function*(){if(Ot(e))return yield Z(yield Z(yield*es(rn(on(t,yield Z(e))))));let r=function(o){return Tt(this,arguments,function*(){yield yield Z(yield Z(o))})},i=function(o){return Tt(this,arguments,function*(){yield Z(yield*es(rn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):sn(e)?i(e):Wt(e)?e:r(e);return yield Z(yield*es(rn(cf((function(o){return Tt(this,arguments,function*(){let a=null;do a=yield Z(o.next(yield yield Z(J(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield Z(new t)})}var jw=t=>on(Int8Array,t),zw=t=>on(Int16Array,t),Vw=t=>on(Int32Array,t),hf=t=>on(Uint8Array,t),$w=t=>on(Uint16Array,t),Ww=t=>on(Uint32Array,t),Hw=t=>on(Float32Array,t),Yw=t=>on(Float64Array,t),Kw=t=>on(Uint8ClampedArray,t);function il(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Qw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Et(r,o)[0]:([i,r,a]=Et(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a0&&(i.push(V(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return O(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return O(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=V(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Zw(t){return Tt(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function d(){return o==="peek"?Et(u,a)[0]:([c,u,l]=Et(u,a),c)}if({cmd:o,size:a}=(yield yield Z(null))||{cmd:"read",size:0},t.isTTY)return yield yield Z(new Uint8Array(0)),yield Z(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield Z(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=V(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield Z(d()));while(a{for(let[h,f]of v)t.off(h,f);try{let h=t.destroy;h&&h.call(t,w),w=void 0}catch(h){w=h||w}finally{w!=null?Y(w):I()}})}})}var ae;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(ae||(ae={}));var de;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(de||(de={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var Ae;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Ae||(Ae={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var He;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(He||(He={}));var Fn=new Int32Array(2),ol=new Float32Array(Fn.buffer),al=new Float64Array(Fn.buffer),ts=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var co;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(co||(co={}));var Ft=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){ol[0]=n,this.writeInt32(e,Fn[0])}writeFloat64(e,n){al[0]=n,this.writeInt32(e,Fn[ts?0:1]),this.writeInt32(e+4,Fn[ts?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var bo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new kn).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var gt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):kr.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,kr.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var ee;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(ee||(ee={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var cn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(cn||(cn={}));var Uf={};fi(Uf,{clampRange:()=>Do,createElementComparator:()=>$r,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>fn});function fn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>fn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Io,bigNumToBigInt:()=>Jp,bigNumToNumber:()=>Sf,bigNumToString:()=>os,isArrowBigNumSymbol:()=>Zp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Zp=Symbol.for("isArrowBigNum");function dn(t,...e){return e.length===0?Object.setPrototypeOf(J(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}dn.prototype[Zp]=!0;dn.prototype.toJSON=function(){return`"${os(this)}"`};dn.prototype.valueOf=function(t){return Sf(this,t)};dn.prototype.toString=function(){return os(this)};dn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return os(this);case"default":return Jp(this)}return os(this)};function is(...t){return dn.apply(this,t)}function ss(...t){return dn.apply(this,t)}function xo(...t){return dn.apply(this,t)}Object.setPrototypeOf(is.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ss.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(xo.prototype,Object.create(Uint32Array.prototype));Object.assign(is.prototype,dn.prototype,{constructor:is,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ss.prototype,dn.prototype,{constructor:ss,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(xo.prototype,dn.prototype,{constructor:xo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Jw=BigInt(4294967296)*BigInt(4294967296),qw=Jw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(E.prototype);var ft=class extends E{constructor(){super(p.Null)}toString(){return"Null"}};em=Symbol.toStringTag;ft[em]=(t=>t[Symbol.toStringTag]="Null")(ft.prototype);var Ve=class extends E{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};tm=Symbol.toStringTag;Ve[tm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Ve.prototype);var cl=class extends Ve{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},fl=class extends Ve{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Ln=class extends Ve{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},dl=class extends Ve{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},hl=class extends Ve{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},pl=class extends Ve{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ml=class extends Ve{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},yl=class extends Ve{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(cl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(fl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Ln.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(dl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(hl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(yl.prototype,"ArrayType",{value:BigUint64Array});var Yt=class extends E{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};nm=Symbol.toStringTag;Yt[nm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Yt.prototype);var gl=class extends Yt{constructor(){super(ce.HALF)}},vl=class extends Yt{constructor(){super(ce.SINGLE)}},_l=class extends Yt{constructor(){super(ce.DOUBLE)}};Object.defineProperty(gl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vl.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float64Array});var Gn=class extends E{constructor(){super(p.Binary)}toString(){return"Binary"}};rm=Symbol.toStringTag;Gn[rm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Gn.prototype);var Xn=class extends E{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};im=Symbol.toStringTag;Xn[im]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Xn.prototype);var Zn=class extends E{constructor(){super(p.Utf8)}toString(){return"Utf8"}};sm=Symbol.toStringTag;Zn[sm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Zn.prototype);var Jn=class extends E{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};om=Symbol.toStringTag;Jn[om]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(Jn.prototype);var qn=class extends E{constructor(){super(p.Bool)}toString(){return"Bool"}};am=Symbol.toStringTag;qn[am]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(qn.prototype);var er=class extends E{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};lm=Symbol.toStringTag;er[lm]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(er.prototype);var tr=class extends E{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Ae[this.unit]}>`}get ArrayType(){return this.unit===Ae.DAY?Int32Array:BigInt64Array}};um=Symbol.toStringTag;tr[um]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(tr.prototype);var nr=class extends E{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};cm=Symbol.toStringTag;nr[cm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(nr.prototype);var rr=class extends E{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};fm=Symbol.toStringTag;rr[fm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(rr.prototype);var ir=class extends E{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${He[this.unit]}>`}};dm=Symbol.toStringTag;ir[dm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(ir.prototype);var sr=class extends E{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};hm=Symbol.toStringTag;sr[hm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(sr.prototype);var hn=class extends E{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};pm=Symbol.toStringTag;hn[pm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(hn.prototype);var pe=class extends E{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};mm=Symbol.toStringTag;pe[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(pe.prototype);var pn=class extends E{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};ym=Symbol.toStringTag;pn[ym]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(pn.prototype);var or=class extends E{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};gm=Symbol.toStringTag;or[gm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(or.prototype);var mn=class extends E{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};vm=Symbol.toStringTag;mn[vm]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(mn.prototype);var yn=class extends E{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(yn.prototype);var eS=(t=>()=>++t)(-1),At=class extends E{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?eS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};wm=Symbol.toStringTag;At[wm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(At.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var C=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return tS(this,e,n)}getVisitFnByTypeId(e,n=!0){return as(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function tS(t,e,n=!0){return typeof e=="number"?as(t,e,n):typeof e=="string"&&e in p?as(t,p[e],n):e&&e instanceof E?as(t,Sm(e),n):e?.type&&e.type instanceof E?as(t,Sm(e.type),n):as(t,p.NONE,n)}function as(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function Sm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case Ae.DAY:return p.DateDay;case Ae.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case He.DAY_TIME:return p.IntervalDayTime;case He.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case de.Dense:return p.DenseUnion;case de.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}C.prototype.visitInt8=null;C.prototype.visitInt16=null;C.prototype.visitInt32=null;C.prototype.visitInt64=null;C.prototype.visitUint8=null;C.prototype.visitUint16=null;C.prototype.visitUint32=null;C.prototype.visitUint64=null;C.prototype.visitFloat16=null;C.prototype.visitFloat32=null;C.prototype.visitFloat64=null;C.prototype.visitDateDay=null;C.prototype.visitDateMillisecond=null;C.prototype.visitTimestampSecond=null;C.prototype.visitTimestampMillisecond=null;C.prototype.visitTimestampMicrosecond=null;C.prototype.visitTimestampNanosecond=null;C.prototype.visitTimeSecond=null;C.prototype.visitTimeMillisecond=null;C.prototype.visitTimeMicrosecond=null;C.prototype.visitTimeNanosecond=null;C.prototype.visitDenseUnion=null;C.prototype.visitSparseUnion=null;C.prototype.visitIntervalDayTime=null;C.prototype.visitIntervalYearMonth=null;C.prototype.visitDuration=null;C.prototype.visitDurationSecond=null;C.prototype.visitDurationMillisecond=null;C.prototype.visitDurationMicrosecond=null;C.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Bo,uint16ToFloat64:()=>wl});var bm=new Float64Array(1),ls=new Uint32Array(bm.buffer);function wl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Bo(t){if(t!==t)return 32256;bm[0]=t;let e=(ls[1]&2147483648)>>16&65535,n=ls[1]&2146435072,r=0;return n>=1089470464?ls[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ls[1]&1048575)>>10):n<=1056964608?(r=1048576+(ls[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ls[1]&1048575)+512>>10),e|n|r&65535}var z=class extends C{};function H(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var nS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},xm=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Im=({values:t},e,n)=>{t[e]=Bo(n)},iS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Im(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},Sl=({values:t},e,n)=>{nS(t,e,n.valueOf())},bl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Bm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,r),Dm=({values:t,valueOffsets:e},n,r)=>xm(t,e,n,On(r)),Df=(t,e,n)=>{t.type.unit===Ae.DAY?Sl(t,e,n):bl(t,e,n)},xl=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Il=({values:t},e,n)=>{t[e]=BigInt(n)},Bl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return xl(t,e,n);case k.MILLISECOND:return Il(t,e,n);case k.MICROSECOND:return Bl(t,e,n);case k.NANOSECOND:return Dl(t,e,n)}},Nl=({values:t},e,n)=>{t[e]=n},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},El=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Nl(t,e,n);case k.MILLISECOND:return Tl(t,e,n);case k.MICROSECOND:return Ol(t,e,n);case k.NANOSECOND:return El(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},sS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},aS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),fS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?uS(e,n):n instanceof te?lS(e,n):Array.isArray(n)?aS(e,n):cS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},dS=(t,e,n)=>{t.type.mode===de.Dense?Nm(t,e,n):Tm(t,e,n)},Nm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},hS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ef=(t,e,n)=>{t.type.unit===He.DAY_TIME?Fl(t,e,n):kl(t,e,n)},Fl=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},kl=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Al=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Ml=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ff=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Al(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Ml(t,e,n);case k.NANOSECOND:return Cl(t,e,n)}},pS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[gn],this[us])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[gn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[gn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[gn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Me.visit(e[gn].children[r],e[us]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[gn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[gn].children[i],e[us],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var U=class extends C{};function $(t){return(e,n)=>e.getValid(n)?t(e,n):null}var mS=(t,e)=>864e5*t[e],yS=(t,e)=>null,Om=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},gS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<mS(t,e),Fm=({values:t},e)=>ne(t[e]),zr=({stride:t,values:e},n)=>e[t*n],vS=({stride:t,values:e},n)=>wl(e[t*n]),km=({values:t},e)=>t[e],_S=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Am=({values:t,valueOffsets:e},n)=>Om(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Om(t,e,n);return r!==null?ao(r):null},wS=({values:t},e)=>t[e],SS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:wl(e[n]),bS=(t,e)=>t.type.unit===Ae.DAY?Em(t,e):Fm(t,e),Mm=({values:t},e)=>1e3*ne(t[e]),Cm=({values:t},e)=>ne(t[e]),Um=({values:t},e)=>_f(t[e],BigInt(1e3)),Rm=({values:t},e)=>_f(t[e],BigInt(1e6)),xS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Mm(t,e);case k.MILLISECOND:return Cm(t,e);case k.MICROSECOND:return Um(t,e);case k.NANOSECOND:return Rm(t,e)}},Pm=({values:t},e)=>t[e],jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Pm(t,e);case k.MILLISECOND:return jm(t,e);case k.MICROSECOND:return zm(t,e);case k.NANOSECOND:return Vm(t,e)}},BS=({values:t,stride:e},n)=>Io.decimal(t.subarray(e*n,e*(n+1))),DS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new te([l])},NS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Mn(o.slice(i,s-i))},TS=(t,e)=>new jr(t,e),OS=(t,e)=>t.type.mode===de.Dense?$m(t,e):Wm(t,e),$m=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,t.valueOffsets[e])},Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Me.visit(r,e)},ES=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},FS=(t,e)=>t.type.unit===He.DAY_TIME?Hm(t,e):Ym(t,e),Hm=({values:t},e)=>t.subarray(2*e,2*(e+1)),Ym=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Km=({values:t},e)=>t[e],Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],kS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Km(t,e);case k.MILLISECOND:return Qm(t,e);case k.MICROSECOND:return Gm(t,e);case k.NANOSECOND:return Xm(t,e)}},AS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new te([s])};U.prototype.visitNull=$(yS);U.prototype.visitBool=$(gS);U.prototype.visitInt=$(wS);U.prototype.visitInt8=$(zr);U.prototype.visitInt16=$(zr);U.prototype.visitInt32=$(zr);U.prototype.visitInt64=$(km);U.prototype.visitUint8=$(zr);U.prototype.visitUint16=$(zr);U.prototype.visitUint32=$(zr);U.prototype.visitUint64=$(km);U.prototype.visitFloat=$(SS);U.prototype.visitFloat16=$(vS);U.prototype.visitFloat32=$(zr);U.prototype.visitFloat64=$(zr);U.prototype.visitUtf8=$(Lm);U.prototype.visitLargeUtf8=$(Lm);U.prototype.visitBinary=$(Am);U.prototype.visitLargeBinary=$(Am);U.prototype.visitFixedSizeBinary=$(_S);U.prototype.visitDate=$(bS);U.prototype.visitDateDay=$(Em);U.prototype.visitDateMillisecond=$(Fm);U.prototype.visitTimestamp=$(xS);U.prototype.visitTimestampSecond=$(Mm);U.prototype.visitTimestampMillisecond=$(Cm);U.prototype.visitTimestampMicrosecond=$(Um);U.prototype.visitTimestampNanosecond=$(Rm);U.prototype.visitTime=$(IS);U.prototype.visitTimeSecond=$(Pm);U.prototype.visitTimeMillisecond=$(jm);U.prototype.visitTimeMicrosecond=$(zm);U.prototype.visitTimeNanosecond=$(Vm);U.prototype.visitDecimal=$(BS);U.prototype.visitList=$(DS);U.prototype.visitStruct=$(TS);U.prototype.visitUnion=$(OS);U.prototype.visitDenseUnion=$($m);U.prototype.visitSparseUnion=$(Wm);U.prototype.visitDictionary=$(ES);U.prototype.visitInterval=$(FS);U.prototype.visitIntervalDayTime=$(Hm);U.prototype.visitIntervalYearMonth=$(Ym);U.prototype.visitDuration=$(kS);U.prototype.visitDurationSecond=$(Km);U.prototype.visitDurationMillisecond=$(Qm);U.prototype.visitDurationMicrosecond=$(Gm);U.prototype.visitDurationNanosecond=$(Xm);U.prototype.visitFixedSizeList=$(AS);U.prototype.visitMap=$(NS);var Me=new U;var Vr=Symbol.for("keys"),fs=Symbol.for("vals"),cs=Symbol.for("kKeysAsStrings"),Lf=Symbol.for("_kKeysAsStrings"),Mn=class{constructor(e){return this[Vr]=new te([e.children[0]]).memoize(),this[fs]=e.children[1],new Proxy(this,new Cf)}get[cs](){return this[Lf]||(this[Lf]=Array.from(this[Vr].toArray(),String))}[Symbol.iterator](){return new Mf(this[Vr],this[fs])}get size(){return this[Vr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Vr],n=this[fs],r={};for(let i=-1,s=e.length;++i`${fn(e)}: ${fn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Mf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Me.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[cs]}has(e,n){return e[cs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[cs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[cs].indexOf(n);if(r!==-1){let i=Me.visit(Reflect.get(e,fs),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[cs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,fs),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Mn.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Vr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[fs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Lf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Zm;function Do(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,Jm=t=>t!==t;function $r(t){if(typeof t!=="object"||t===null)return Jm(t)?Jm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?MS(t):Array.isArray(t)?LS(t):t instanceof te?CS(t):US(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return RS(t,n);case Map:return qm(t,n,n.keys());case Mn:case jr:case Object:case void 0:return qm(t,n,e||Object.keys(n))}return n instanceof te?PS(t,n):!1}}function RS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ey,getBool:()=>Pl,packBools:()=>gi,popcnt_array:()=>ty,popcnt_bit_range:()=>No,popcnt_uint32:()=>Rl,setBool:()=>jS,truncateBitmap:()=>yi});function Pl(t,e,n,r){return(n&1<>r}function jS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,Pl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return No(t,e,i)+No(t,r,n)+ty(t,i>>3,r-i>>3)}function ty(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Rl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Rl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Rl(s.getUint8(i)),i+=1;return r}function Rl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var zS=-1,ie=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return E.isSparseUnion(e)?this.children.some(n=>n.nullable):E.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(E.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=zS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-No(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(E.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===de.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let d=s[c];r=(d&u)!==0,s[c]=n?d|u:d&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[cn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[cn.TYPE])&&(o[cn.TYPE]=s.subarray(e,e+n)),(s=o[cn.OFFSET])&&(o[cn.OFFSET]=s.subarray(e,e+n+1))||(s=o[cn.DATA])&&(o[cn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};ie.prototype.children=Object.freeze([]);var Pf=class t extends C{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new ie(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.data),s=V(e.nullBitmap),o=rl(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=V(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=J(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(E.isSparseUnion(n))return new ie(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new ie(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.indices.ArrayType,e.data),{["dictionary"]:o=new te([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=V(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=V(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new ie(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=V(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new ie(n,r,a,l,[o,void 0,s],[i])}},VS=new Pf;function Q(t){return VS.visit(t)}var To=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function jl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function zl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function Vl(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),d=Math.min(r-l,u);i.push(a.slice(c,d-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function WS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,Pl)){if(!i)return r;++r}return-1}function G(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return WS(t,n)}let r=Me.getVisitFn(t),i=$r(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new To(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof ie)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=sy[o.typeId],c=s[0];this.isValid=d=>Oo(c,d),this.get=d=>a(c,d),this.set=(d,y)=>l(c,d,y),this.indexOf=d=>u(c,d),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,oy[o.typeId]),this._offsets=zl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ny(this.data)}get nullCount(){return jl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return hs.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(Do(this,e,n,({data:r,_offsets:i},s,o)=>Vl(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return E.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(E.isDictionary(this.type)){let e=new Hl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Hl(this)}unmemoize(){if(E.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};iy=Symbol.toStringTag;te[iy]=(t=>{t.type=E.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Me.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);sy[n]={get:r,set:i,indexOf:s},oy[n]=Object.create(t,{isValid:{value:ds(Oo)},get:{value:ds(Me.getVisitFnByTypeId(n))},set:{value:$l(Xe.getVisitFnByTypeId(n))},indexOf:{value:Wl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(te.prototype);var Hl=class t extends te{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new te(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ay(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` +var ww=Object.defineProperty;var fi=(t,e)=>{for(var n in e)ww(t,n,{get:e[n],enumerable:!0})};function Kp(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(t){return this instanceof Z?(this.v=t,this):new Z(t)}function Ot(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(v){return function(_){return Promise.resolve(_).then(v,f)}}function a(v,_){r[v]&&(i[v]=function(b){return new Promise(function(K,h){s.push([v,b,K,h])>1||l(v,b)})},_&&(i[v]=_(i[v])))}function l(v,_){try{u(r[v](_))}catch(b){y(s[0][3],b)}}function u(v){v.value instanceof Z?Promise.resolve(v.value.v).then(c,f):y(s[0][2],v)}function c(v){l("next",v)}function f(v){l("throw",v)}function y(v,_){v(_),s.shift(),s.length&&l(s[0][0],s[0][1])}}function ts(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:Z(t[i](o)),done:!1}:s?s(o):o}:s}}function sn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Yp=="function"?Yp(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}var mf={};fi(mf,{compareArrayLike:()=>pf,joinUint8Arrays:()=>Ft,memcpy:()=>co,rebaseValueOffsets:()=>sl,toArrayBufferView:()=>J,toArrayBufferViewAsyncIterator:()=>an,toArrayBufferViewIterator:()=>En,toBigInt64Array:()=>il,toBigUint64Array:()=>Ow,toFloat32Array:()=>Ew,toFloat32ArrayAsyncIterator:()=>Yw,toFloat32ArrayIterator:()=>Rw,toFloat64Array:()=>Fw,toFloat64ArrayAsyncIterator:()=>Kw,toFloat64ArrayIterator:()=>Pw,toInt16Array:()=>Dw,toInt16ArrayAsyncIterator:()=>Vw,toInt16ArrayIterator:()=>Mw,toInt32Array:()=>di,toInt32ArrayAsyncIterator:()=>$w,toInt32ArrayIterator:()=>Lw,toInt8Array:()=>Bw,toInt8ArrayAsyncIterator:()=>zw,toInt8ArrayIterator:()=>Aw,toUint16Array:()=>Nw,toUint16ArrayAsyncIterator:()=>Ww,toUint16ArrayIterator:()=>Cw,toUint32Array:()=>Tw,toUint32ArrayAsyncIterator:()=>Hw,toUint32ArrayIterator:()=>Uw,toUint8Array:()=>$,toUint8ArrayAsyncIterator:()=>hf,toUint8ArrayIterator:()=>df,toUint8ClampedArray:()=>kw,toUint8ClampedArrayAsyncIterator:()=>Qw,toUint8ClampedArrayIterator:()=>jw});var Sw=new TextDecoder("utf-8"),lo=t=>Sw.decode(t),bw=new TextEncoder,On=t=>bw.encode(t);var xw=t=>typeof t=="number",Qp=t=>typeof t=="boolean",Pe=t=>typeof t=="function",ft=t=>t!=null&&Object(t)===t,Et=t=>ft(t)&&Pe(t.then);var on=t=>ft(t)&&Pe(t[Symbol.iterator]),Ht=t=>ft(t)&&Pe(t[Symbol.asyncIterator]),Ja=t=>ft(t)&&ft(t.schema);var qa=t=>ft(t)&&"done"in t&&"value"in t;var el=t=>ft(t)&&Pe(t.stat)&&xw(t.fd);var tl=t=>ft(t)&&uo(t.body),nl=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Gp=t=>ft(t)&&Pe(t.abort)&&Pe(t.getWriter)&&!nl(t),uo=t=>ft(t)&&Pe(t.cancel)&&Pe(t.getReader)&&!nl(t),Xp=t=>ft(t)&&Pe(t.end)&&Pe(t.write)&&Qp(t.writable)&&!nl(t),rl=t=>ft(t)&&Pe(t.read)&&Pe(t.pipe)&&Qp(t.readable)&&!nl(t),Zp=t=>ft(t)&&Pe(t.clear)&&Pe(t.bytes)&&Pe(t.position)&&Pe(t.setPosition)&&Pe(t.capacity)&&Pe(t.getBufferIdentifier)&&Pe(t.createLong);var ff=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Iw(t){let e=t[0]?[t[0]]:[],n,r,i,s;for(let o,a,l=0,u=0,c=t.length;++lc+f.byteLength,0),i,s,o,a=0,l=-1,u=Math.min(e||Number.POSITIVE_INFINITY,r);for(let c=n.length;++lJ(Int8Array,t),Dw=t=>J(Int16Array,t),di=t=>J(Int32Array,t),il=t=>J(BigInt64Array,t),$=t=>J(Uint8Array,t),Nw=t=>J(Uint16Array,t),Tw=t=>J(Uint32Array,t),Ow=t=>J(BigUint64Array,t),Ew=t=>J(Float32Array,t),Fw=t=>J(Float64Array,t),kw=t=>J(Uint8ClampedArray,t),cf=t=>(t.next(),t);function*En(t,e){let n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?n(e):on(e)?e:n(e);return yield*cf((function*(i){let s=null;do s=i.next(yield J(t,s));while(!s.done)})(r[Symbol.iterator]())),new t}var Aw=t=>En(Int8Array,t),Mw=t=>En(Int16Array,t),Lw=t=>En(Int32Array,t),df=t=>En(Uint8Array,t),Cw=t=>En(Uint16Array,t),Uw=t=>En(Uint32Array,t),Rw=t=>En(Float32Array,t),Pw=t=>En(Float64Array,t),jw=t=>En(Uint8ClampedArray,t);function an(t,e){return Ot(this,arguments,function*(){if(Et(e))return yield Z(yield Z(yield*ts(sn(an(t,yield Z(e))))));let r=function(o){return Ot(this,arguments,function*(){yield yield Z(yield Z(o))})},i=function(o){return Ot(this,arguments,function*(){yield Z(yield*ts(sn(cf((function*(a){let l=null;do l=a.next(yield l?.value);while(!l.done)})(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ff?r(e):on(e)?i(e):Ht(e)?e:r(e);return yield Z(yield*ts(sn(cf((function(o){return Ot(this,arguments,function*(){let a=null;do a=yield Z(o.next(yield yield Z(J(t,a))));while(!a.done)})})(s[Symbol.asyncIterator]()))))),yield Z(new t)})}var zw=t=>an(Int8Array,t),Vw=t=>an(Int16Array,t),$w=t=>an(Int32Array,t),hf=t=>an(Uint8Array,t),Ww=t=>an(Uint16Array,t),Hw=t=>an(Uint32Array,t),Yw=t=>an(Float32Array,t),Kw=t=>an(Float64Array,t),Qw=t=>an(Uint8ClampedArray,t);function sl(t,e,n){if(t!==0){n=n.slice(0,e);for(let r=-1,i=n.length;++r0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*Gw(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?Ft(r,o)[0]:([i,r,a]=Ft(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let u=df(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?u.next():u.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a0&&(i.push($(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield Z(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return T(this,void 0,void 0,function*(){let{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return T(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};let n=yield this.reader.read();return!n.done&&(n.value=$(n)),n})}},yf=(t,e)=>{let n=i=>r([e,i]),r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function Jw(t){return Ot(this,arguments,function*(){let n=[],r="error",i=!1,s=null,o,a,l=0,u=[],c;function f(){return o==="peek"?Ft(u,a)[0]:([c,u,l]=Ft(u,a),c)}if({cmd:o,size:a}=(yield yield Z(null))||{cmd:"read",size:0},t.isTTY)return yield yield Z(new Uint8Array(0)),yield Z(null);try{n[0]=yf(t,"end"),n[1]=yf(t,"error");do{if(n[2]=yf(t,"readable"),[r,s]=yield Z(Promise.race(n.map(v=>v[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(c=$(t.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield Z(f()));while(a{for(let[h,d]of v)t.off(h,d);try{let h=t.destroy;h&&h.call(t,_),_=void 0}catch(h){_=h||_}finally{_!=null?K(_):b()}})}})}var le;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(le||(le={}));var pe;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(pe||(pe={}));var ce;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(ce||(ce={}));var ke;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(ke||(ke={}));var k;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var He;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(He||(He={}));var Fn=new Int32Array(2),al=new Float32Array(Fn.buffer),ll=new Float64Array(Fn.buffer),ns=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var fo;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(fo||(fo={}));var kt=class t{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,Number(BigInt.asIntN(32,n))),this.writeInt32(e+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(e,n){this.writeUint32(e,Number(BigInt.asUintN(32,n))),this.writeUint32(e+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(e,n){al[0]=n,this.writeInt32(e,Fn[0])}writeFloat64(e,n){ll[0]=n,this.writeInt32(e,Fn[ns?0:1]),this.writeInt32(e+4,Fn[ns?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);let r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);let r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);let i=2;this.addInt16(e-this.object_start);let s=(r+i)*2;this.addInt16(s);let o=0,a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){let r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(n=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return t.startUnion(e),t.addMode(e,n),t.addTypeIds(e,r),t.endUnion(e)}};var xo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return t.startUtf8(e),t.endUtf8(e)}};var fe;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"})(fe||(fe={}));var nt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(e){let n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):fe.NONE}type(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new kn).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,16);return r?(n||new je).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,fe.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}};var vt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):kr.Little}fields(e,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new nt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new je).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,kr.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,r),t.addCustomMetadata(e,i),t.addFeatures(e,s),t.endSchema(e)}};var ee;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(ee||(ee={}));var p;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"})(p||(p={}));var fn;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(fn||(fn={}));var Uf={};fi(Uf,{clampRange:()=>No,createElementComparator:()=>$r,wrapIndex:()=>pi});var vf={};fi(vf,{valueToString:()=>dn});function dn(t){if(t===null)return"null";if(t===void 0)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map(e=>dn(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}var bf={};fi(bf,{BN:()=>Bo,bigNumToBigInt:()=>qp,bigNumToNumber:()=>Sf,bigNumToString:()=>as,isArrowBigNumSymbol:()=>Jp});function ne(t){if(typeof t=="bigint"&&(tNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}function _f(t,e){return ne(t/e)+ne(t%e)/ne(e)}var Jp=Symbol.for("isArrowBigNum");function hn(t,...e){return e.length===0?Object.setPrototypeOf(J(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}hn.prototype[Jp]=!0;hn.prototype.toJSON=function(){return`"${as(this)}"`};hn.prototype.valueOf=function(t){return Sf(this,t)};hn.prototype.toString=function(){return as(this)};hn.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Sf(this);case"string":return as(this);case"default":return qp(this)}return as(this)};function ss(...t){return hn.apply(this,t)}function os(...t){return hn.apply(this,t)}function Io(...t){return hn.apply(this,t)}Object.setPrototypeOf(ss.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(os.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Io.prototype,Object.create(Uint32Array.prototype));Object.assign(ss.prototype,hn.prototype,{constructor:ss,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(os.prototype,hn.prototype,{constructor:os,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Io.prototype,hn.prototype,{constructor:Io,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var qw=BigInt(4294967296)*BigInt(4294967296),eS=qw-BigInt(1);function Sf(t,e){let{buffer:n,byteOffset:r,byteLength:i,signed:s}=t,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<=0)return wf(t);e=e.slice();let r=1;for(let s=0;s(t.children=null,t.ArrayType=Array,t.OffsetArrayType=Int32Array,t[Symbol.toStringTag]="DataType"))(O.prototype);var dt=class extends O{constructor(){super(p.Null)}toString(){return"Null"}};tm=Symbol.toStringTag;dt[tm]=(t=>t[Symbol.toStringTag]="Null")(dt.prototype);var ze=class extends O{constructor(e,n){super(p.Int),this.isSigned=e,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};nm=Symbol.toStringTag;ze[nm]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(ze.prototype);var fl=class extends ze{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},dl=class extends ze{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Mn=class extends ze{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},hl=class extends ze{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},pl=class extends ze{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},ml=class extends ze{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},yl=class extends ze{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},gl=class extends ze{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(fl.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(dl.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Mn.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(hl.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(pl.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(ml.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(yl.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(gl.prototype,"ArrayType",{value:BigUint64Array});var Kt=class extends O{constructor(e){super(p.Float),this.precision=e}get ArrayType(){switch(this.precision){case ce.HALF:return Uint16Array;case ce.SINGLE:return Float32Array;case ce.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};rm=Symbol.toStringTag;Kt[rm]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Kt.prototype);var vl=class extends Kt{constructor(){super(ce.HALF)}},_l=class extends Kt{constructor(){super(ce.SINGLE)}},wl=class extends Kt{constructor(){super(ce.DOUBLE)}};Object.defineProperty(vl.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(_l.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(wl.prototype,"ArrayType",{value:Float64Array});var Xn=class extends O{constructor(){super(p.Binary)}toString(){return"Binary"}};im=Symbol.toStringTag;Xn[im]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Xn.prototype);var Zn=class extends O{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}};sm=Symbol.toStringTag;Zn[sm]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeBinary"))(Zn.prototype);var Jn=class extends O{constructor(){super(p.Utf8)}toString(){return"Utf8"}};om=Symbol.toStringTag;Jn[om]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Jn.prototype);var qn=class extends O{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}};am=Symbol.toStringTag;qn[am]=(t=>(t.ArrayType=Uint8Array,t.OffsetArrayType=BigInt64Array,t[Symbol.toStringTag]="LargeUtf8"))(qn.prototype);var er=class extends O{constructor(){super(p.Bool)}toString(){return"Bool"}};lm=Symbol.toStringTag;er[lm]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(er.prototype);var tr=class extends O{constructor(e,n,r=128){super(p.Decimal),this.scale=e,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};um=Symbol.toStringTag;tr[um]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(tr.prototype);var nr=class extends O{constructor(e){super(p.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${ke[this.unit]}>`}get ArrayType(){return this.unit===ke.DAY?Int32Array:BigInt64Array}};cm=Symbol.toStringTag;nr[cm]=(t=>(t.unit=null,t[Symbol.toStringTag]="Date"))(nr.prototype);var rr=class extends O{constructor(e,n){super(p.Time),this.unit=e,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};fm=Symbol.toStringTag;rr[fm]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(rr.prototype);var ir=class extends O{constructor(e,n){super(p.Timestamp),this.unit=e,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};dm=Symbol.toStringTag;ir[dm]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Timestamp"))(ir.prototype);var sr=class extends O{constructor(e){super(p.Interval),this.unit=e}toString(){return`Interval<${He[this.unit]}>`}};hm=Symbol.toStringTag;sr[hm]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(sr.prototype);var or=class extends O{constructor(e){super(p.Duration),this.unit=e}toString(){return`Duration<${k[this.unit]}>`}};pm=Symbol.toStringTag;or[pm]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(or.prototype);var pn=class extends O{constructor(e){super(p.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};mm=Symbol.toStringTag;pn[mm]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(pn.prototype);var me=class extends O{constructor(e){super(p.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};ym=Symbol.toStringTag;me[ym]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(me.prototype);var mn=class extends O{constructor(e,n,r){super(p.Union),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}};gm=Symbol.toStringTag;mn[gm]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(mn.prototype);var ar=class extends O{constructor(e){super(p.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};vm=Symbol.toStringTag;ar[vm]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(ar.prototype);var yn=class extends O{constructor(e,n){super(p.FixedSizeList),this.listSize=e,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};_m=Symbol.toStringTag;yn[_m]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(yn.prototype);var gn=class extends O{constructor(e,n=!1){var r,i,s;if(super(p.Map),this.children=[e],this.keysSorted=n,e&&(e.name="entries",!((r=e?.type)===null||r===void 0)&&r.children)){let o=(i=e?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=e?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}};wm=Symbol.toStringTag;gn[wm]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(gn.prototype);var tS=(t=>()=>++t)(-1),Mt=class extends O{constructor(e,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?tS():ne(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};Sm=Symbol.toStringTag;Mt[Sm]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Mt.prototype);function Lt(t){let e=t;switch(t.typeId){case p.Decimal:return t.bitWidth/32;case p.Interval:return 1+e.unit;case p.FixedSizeList:return e.listSize;case p.FixedSizeBinary:return e.byteWidth;default:return 1}}var U=class{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return nS(this,e,n)}getVisitFnByTypeId(e,n=!0){return ls(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitLargeUtf8(e,...n){return null}visitBinary(e,...n){return null}visitLargeBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitDuration(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}};function nS(t,e,n=!0){return typeof e=="number"?ls(t,e,n):typeof e=="string"&&e in p?ls(t,p[e],n):e&&e instanceof O?ls(t,bm(e),n):e?.type&&e.type instanceof O?ls(t,bm(e.type),n):ls(t,p.NONE,n)}function ls(t,e,n=!0){let r=null;switch(e){case p.Null:r=t.visitNull;break;case p.Bool:r=t.visitBool;break;case p.Int:r=t.visitInt;break;case p.Int8:r=t.visitInt8||t.visitInt;break;case p.Int16:r=t.visitInt16||t.visitInt;break;case p.Int32:r=t.visitInt32||t.visitInt;break;case p.Int64:r=t.visitInt64||t.visitInt;break;case p.Uint8:r=t.visitUint8||t.visitInt;break;case p.Uint16:r=t.visitUint16||t.visitInt;break;case p.Uint32:r=t.visitUint32||t.visitInt;break;case p.Uint64:r=t.visitUint64||t.visitInt;break;case p.Float:r=t.visitFloat;break;case p.Float16:r=t.visitFloat16||t.visitFloat;break;case p.Float32:r=t.visitFloat32||t.visitFloat;break;case p.Float64:r=t.visitFloat64||t.visitFloat;break;case p.Utf8:r=t.visitUtf8;break;case p.LargeUtf8:r=t.visitLargeUtf8;break;case p.Binary:r=t.visitBinary;break;case p.LargeBinary:r=t.visitLargeBinary;break;case p.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case p.Date:r=t.visitDate;break;case p.DateDay:r=t.visitDateDay||t.visitDate;break;case p.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case p.Timestamp:r=t.visitTimestamp;break;case p.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case p.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case p.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case p.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case p.Time:r=t.visitTime;break;case p.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case p.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case p.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case p.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case p.Decimal:r=t.visitDecimal;break;case p.List:r=t.visitList;break;case p.Struct:r=t.visitStruct;break;case p.Union:r=t.visitUnion;break;case p.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case p.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case p.Dictionary:r=t.visitDictionary;break;case p.Interval:r=t.visitInterval;break;case p.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case p.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case p.Duration:r=t.visitDuration;break;case p.DurationSecond:r=t.visitDurationSecond||t.visitDuration;break;case p.DurationMillisecond:r=t.visitDurationMillisecond||t.visitDuration;break;case p.DurationMicrosecond:r=t.visitDurationMicrosecond||t.visitDuration;break;case p.DurationNanosecond:r=t.visitDurationNanosecond||t.visitDuration;break;case p.FixedSizeList:r=t.visitFixedSizeList;break;case p.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[e]}'`)}function bm(t){switch(t.typeId){case p.Null:return p.Null;case p.Int:{let{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(t.precision){case ce.HALF:return p.Float16;case ce.SINGLE:return p.Float32;case ce.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(t.unit){case k.SECOND:return p.TimeSecond;case k.MILLISECOND:return p.TimeMillisecond;case k.MICROSECOND:return p.TimeMicrosecond;case k.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(t.unit){case k.SECOND:return p.TimestampSecond;case k.MILLISECOND:return p.TimestampMillisecond;case k.MICROSECOND:return p.TimestampMicrosecond;case k.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(t.unit){case ke.DAY:return p.DateDay;case ke.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(t.unit){case He.DAY_TIME:return p.IntervalDayTime;case He.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(t.unit){case k.SECOND:return p.DurationSecond;case k.MILLISECOND:return p.DurationMillisecond;case k.MICROSECOND:return p.DurationMicrosecond;case k.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(t.mode){case pe.Dense:return p.DenseUnion;case pe.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[t.typeId]}'`)}U.prototype.visitInt8=null;U.prototype.visitInt16=null;U.prototype.visitInt32=null;U.prototype.visitInt64=null;U.prototype.visitUint8=null;U.prototype.visitUint16=null;U.prototype.visitUint32=null;U.prototype.visitUint64=null;U.prototype.visitFloat16=null;U.prototype.visitFloat32=null;U.prototype.visitFloat64=null;U.prototype.visitDateDay=null;U.prototype.visitDateMillisecond=null;U.prototype.visitTimestampSecond=null;U.prototype.visitTimestampMillisecond=null;U.prototype.visitTimestampMicrosecond=null;U.prototype.visitTimestampNanosecond=null;U.prototype.visitTimeSecond=null;U.prototype.visitTimeMillisecond=null;U.prototype.visitTimeMicrosecond=null;U.prototype.visitTimeNanosecond=null;U.prototype.visitDenseUnion=null;U.prototype.visitSparseUnion=null;U.prototype.visitIntervalDayTime=null;U.prototype.visitIntervalYearMonth=null;U.prototype.visitDuration=null;U.prototype.visitDurationSecond=null;U.prototype.visitDurationMillisecond=null;U.prototype.visitDurationMicrosecond=null;U.prototype.visitDurationNanosecond=null;var xf={};fi(xf,{float64ToUint16:()=>Do,uint16ToFloat64:()=>Sl});var xm=new Float64Array(1),us=new Uint32Array(xm.buffer);function Sl(t){let e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function Do(t){if(t!==t)return 32256;xm[0]=t;let e=(us[1]&2147483648)>>16&65535,n=us[1]&2146435072,r=0;return n>=1089470464?us[0]>0?n=31744:(n=(n&2080374784)>>16,r=(us[1]&1048575)>>10):n<=1056964608?(r=1048576+(us[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(us[1]&1048575)+512>>10),e|n|r&65535}var V=class extends U{};function Y(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}var rS=(t,e,n)=>{t[e]=Math.floor(n/864e5)},Im=(t,e,n,r)=>{if(n+1{let i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},If=({values:t},e,n)=>{t[e]=n},Bm=({values:t},e,n)=>{t[e]=Do(n)},sS=(t,e,n)=>{switch(t.type.precision){case ce.HALF:return Bm(t,e,n);case ce.SINGLE:case ce.DOUBLE:return If(t,e,n)}},bl=({values:t},e,n)=>{rS(t,e,n.valueOf())},xl=({values:t},e,n)=>{t[e]=BigInt(n)},Bf=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},Dm=({values:t,valueOffsets:e},n,r)=>Im(t,e,n,r),Nm=({values:t,valueOffsets:e},n,r)=>Im(t,e,n,On(r)),Df=(t,e,n)=>{t.type.unit===ke.DAY?bl(t,e,n):xl(t,e,n)},Il=({values:t},e,n)=>{t[e]=BigInt(n/1e3)},Bl=({values:t},e,n)=>{t[e]=BigInt(n)},Dl=({values:t},e,n)=>{t[e]=BigInt(n*1e3)},Nl=({values:t},e,n)=>{t[e]=BigInt(n*1e6)},Nf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Il(t,e,n);case k.MILLISECOND:return Bl(t,e,n);case k.MICROSECOND:return Dl(t,e,n);case k.NANOSECOND:return Nl(t,e,n)}},Tl=({values:t},e,n)=>{t[e]=n},Ol=({values:t},e,n)=>{t[e]=n},El=({values:t},e,n)=>{t[e]=n},Fl=({values:t},e,n)=>{t[e]=n},Tf=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Tl(t,e,n);case k.MILLISECOND:return Ol(t,e,n);case k.MICROSECOND:return El(t,e,n);case k.NANOSECOND:return Fl(t,e,n)}},Of=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},oS=(t,e,n)=>{let r=t.children[0],i=t.valueOffsets,s=Xe.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{let r=t.children[0],{valueOffsets:i}=t,s=Xe.getVisitFn(r),{[e]:o,[e+1]:a}=i,l=n instanceof Map?n.entries():Object.entries(n);for(let u of l)if(s(r,o,u),++o>=a)break},lS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),uS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),cS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),fS=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),dS=(t,e,n)=>{let r=t.type.children.map(s=>Xe.getVisitFn(s.type)),i=n instanceof Map?cS(e,n):n instanceof te?uS(e,n):Array.isArray(n)?lS(e,n):fS(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},hS=(t,e,n)=>{t.type.mode===pe.Dense?Tm(t,e,n):Om(t,e,n)},Tm=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,t.valueOffsets[e],n)},Om=(t,e,n)=>{let r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];Xe.visit(i,e,n)},pS=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},Ef=(t,e,n)=>{t.type.unit===He.DAY_TIME?kl(t,e,n):Al(t,e,n)},kl=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},Al=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},Ml=({values:t},e,n)=>{t[e]=n},Ll=({values:t},e,n)=>{t[e]=n},Cl=({values:t},e,n)=>{t[e]=n},Ul=({values:t},e,n)=>{t[e]=n},Ff=(t,e,n)=>{switch(t.type.unit){case k.SECOND:return Ml(t,e,n);case k.MILLISECOND:return Ll(t,e,n);case k.MICROSECOND:return Cl(t,e,n);case k.NANOSECOND:return Ul(t,e,n)}},mS=(t,e,n)=>{let{stride:r}=t,i=t.children[0],s=Xe.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${dn(e)}: ${dn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new kf(this[vn],this[cs])}},kf=class{constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return en.name)}has(e,n){return e[vn].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[vn].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[vn].type.children.findIndex(i=>i.name===n);if(r!==-1){let i=Ce.visit(e[vn].children[r],e[cs]);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[vn].type.children.findIndex(s=>s.name===n);return i!==-1?(Xe.visit(e[vn].children[i],e[cs],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}};var R=class extends U{};function W(t){return(e,n)=>e.getValid(n)?t(e,n):null}var yS=(t,e)=>864e5*t[e],gS=(t,e)=>null,Em=(t,e,n)=>{if(n+1>=e.length)return null;let r=ne(e[n]),i=ne(e[n+1]);return t.subarray(r,i)},vS=({offset:t,values:e},n)=>{let r=t+n;return(e[r>>3]&1<yS(t,e),km=({values:t},e)=>ne(t[e]),zr=({stride:t,values:e},n)=>e[t*n],_S=({stride:t,values:e},n)=>Sl(e[t*n]),Am=({values:t},e)=>t[e],wS=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),Mm=({values:t,valueOffsets:e},n)=>Em(t,e,n),Lm=({values:t,valueOffsets:e},n)=>{let r=Em(t,e,n);return r!==null?lo(r):null},SS=({values:t},e)=>t[e],bS=({type:t,values:e},n)=>t.precision!==ce.HALF?e[n]:Sl(e[n]),xS=(t,e)=>t.type.unit===ke.DAY?Fm(t,e):km(t,e),Cm=({values:t},e)=>1e3*ne(t[e]),Um=({values:t},e)=>ne(t[e]),Rm=({values:t},e)=>_f(t[e],BigInt(1e3)),Pm=({values:t},e)=>_f(t[e],BigInt(1e6)),IS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Cm(t,e);case k.MILLISECOND:return Um(t,e);case k.MICROSECOND:return Rm(t,e);case k.NANOSECOND:return Pm(t,e)}},jm=({values:t},e)=>t[e],zm=({values:t},e)=>t[e],Vm=({values:t},e)=>t[e],$m=({values:t},e)=>t[e],BS=(t,e)=>{switch(t.type.unit){case k.SECOND:return jm(t,e);case k.MILLISECOND:return zm(t,e);case k.MICROSECOND:return Vm(t,e);case k.NANOSECOND:return $m(t,e)}},DS=({values:t,stride:e},n)=>Bo.decimal(t.subarray(e*n,e*(n+1))),NS=(t,e)=>{let{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new te([l])},TS=(t,e)=>{let{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new Ln(o.slice(i,s-i))},OS=(t,e)=>new jr(t,e),ES=(t,e)=>t.type.mode===pe.Dense?Wm(t,e):Hm(t,e),Wm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Ce.visit(r,t.valueOffsets[e])},Hm=(t,e)=>{let n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Ce.visit(r,e)},FS=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},kS=(t,e)=>t.type.unit===He.DAY_TIME?Ym(t,e):Km(t,e),Ym=({values:t},e)=>t.subarray(2*e,2*(e+1)),Km=({values:t},e)=>{let n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Qm=({values:t},e)=>t[e],Gm=({values:t},e)=>t[e],Xm=({values:t},e)=>t[e],Zm=({values:t},e)=>t[e],AS=(t,e)=>{switch(t.type.unit){case k.SECOND:return Qm(t,e);case k.MILLISECOND:return Gm(t,e);case k.MICROSECOND:return Xm(t,e);case k.NANOSECOND:return Zm(t,e)}},MS=(t,e)=>{let{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new te([s])};R.prototype.visitNull=W(gS);R.prototype.visitBool=W(vS);R.prototype.visitInt=W(SS);R.prototype.visitInt8=W(zr);R.prototype.visitInt16=W(zr);R.prototype.visitInt32=W(zr);R.prototype.visitInt64=W(Am);R.prototype.visitUint8=W(zr);R.prototype.visitUint16=W(zr);R.prototype.visitUint32=W(zr);R.prototype.visitUint64=W(Am);R.prototype.visitFloat=W(bS);R.prototype.visitFloat16=W(_S);R.prototype.visitFloat32=W(zr);R.prototype.visitFloat64=W(zr);R.prototype.visitUtf8=W(Lm);R.prototype.visitLargeUtf8=W(Lm);R.prototype.visitBinary=W(Mm);R.prototype.visitLargeBinary=W(Mm);R.prototype.visitFixedSizeBinary=W(wS);R.prototype.visitDate=W(xS);R.prototype.visitDateDay=W(Fm);R.prototype.visitDateMillisecond=W(km);R.prototype.visitTimestamp=W(IS);R.prototype.visitTimestampSecond=W(Cm);R.prototype.visitTimestampMillisecond=W(Um);R.prototype.visitTimestampMicrosecond=W(Rm);R.prototype.visitTimestampNanosecond=W(Pm);R.prototype.visitTime=W(BS);R.prototype.visitTimeSecond=W(jm);R.prototype.visitTimeMillisecond=W(zm);R.prototype.visitTimeMicrosecond=W(Vm);R.prototype.visitTimeNanosecond=W($m);R.prototype.visitDecimal=W(DS);R.prototype.visitList=W(NS);R.prototype.visitStruct=W(OS);R.prototype.visitUnion=W(ES);R.prototype.visitDenseUnion=W(Wm);R.prototype.visitSparseUnion=W(Hm);R.prototype.visitDictionary=W(FS);R.prototype.visitInterval=W(kS);R.prototype.visitIntervalDayTime=W(Ym);R.prototype.visitIntervalYearMonth=W(Km);R.prototype.visitDuration=W(AS);R.prototype.visitDurationSecond=W(Qm);R.prototype.visitDurationMillisecond=W(Gm);R.prototype.visitDurationMicrosecond=W(Xm);R.prototype.visitDurationNanosecond=W(Zm);R.prototype.visitFixedSizeList=W(MS);R.prototype.visitMap=W(TS);var Ce=new R;var Vr=Symbol.for("keys"),ds=Symbol.for("vals"),fs=Symbol.for("kKeysAsStrings"),Mf=Symbol.for("_kKeysAsStrings"),Ln=class{constructor(e){return this[Vr]=new te([e.children[0]]).memoize(),this[ds]=e.children[1],new Proxy(this,new Cf)}get[fs](){return this[Mf]||(this[Mf]=Array.from(this[Vr].toArray(),String))}[Symbol.iterator](){return new Lf(this[Vr],this[ds])}get size(){return this[Vr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Vr],n=this[ds],r={};for(let i=-1,s=e.length;++i`${dn(e)}: ${dn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Lf=class{constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Ce.visit(this.vals,e)]})}},Cf=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[fs]}has(e,n){return e[fs].includes(n)}getOwnPropertyDescriptor(e,n){if(e[fs].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];let r=e[fs].indexOf(n);if(r!==-1){let i=Ce.visit(Reflect.get(e,ds),r);return Reflect.set(e,n,i),i}}set(e,n,r){let i=e[fs].indexOf(n);return i!==-1?(Xe.visit(Reflect.get(e,ds),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}};Object.defineProperties(Ln.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Vr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ds]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Mf]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Jm;function No(t,e,n,r){let{length:i=0}=t,s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}var pi=(t,e)=>t<0?e+t:t,qm=t=>t!==t;function $r(t){if(typeof t!=="object"||t===null)return qm(t)?qm:n=>n===t;if(t instanceof Date){let n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?pf(t,n):!1:t instanceof Map?CS(t):Array.isArray(t)?LS(t):t instanceof te?US(t):RS(t,!0)}function LS(t){let e=[];for(let n=-1,r=t.length;++n!1;let r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return PS(t,n);case Map:return ey(t,n,n.keys());case Ln:case jr:case Object:case void 0:return ey(t,n,e||Object.keys(n))}return n instanceof te?jS(t,n):!1}}function PS(t,e){let n=t.length;if(e.length!==n)return!1;for(let r=-1;++rmi,getBit:()=>ty,getBool:()=>jl,packBools:()=>gi,popcnt_array:()=>ny,popcnt_bit_range:()=>To,popcnt_uint32:()=>Pl,setBool:()=>zS,truncateBitmap:()=>yi});function jl(t,e,n,r){return(n&1<>r}function zS(t,e,n){return n?!!(t[e>>3]|=1<>3]&=~(1<0||n.byteLength>3):gi(new mi(n,t,e,null,jl)).subarray(0,r)),i}return n}function gi(t){let e=[],n=0,r=0,i=0;for(let o of t)o&&(i|=1<0)&&(e[n++]=i);let s=new Uint8Array(e.length+7&-8);return s.set(e),s}var mi=class{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return To(t,e,i)+To(t,r,n)+ny(t,i>>3,r-i>>3)}function ny(t,e,n){let r=0,i=Math.trunc(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Pl(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Pl(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Pl(s.getUint8(i)),i+=1;return r}function Pl(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}var VS=-1,se=class t{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return O.isSparseUnion(e)?this.children.some(n=>n.nullable):O.isDenseUnion(e)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){if(O.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let e=this._nullCount,n;return e<=VS&&(n=this.nullBitmap)&&(this._nullCount=e=n.length===0?0:this.length-To(n,this.offset,this.offset+this.length)),e}constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof t?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Lt(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(e){let{type:n}=this;if(O.isUnion(n)){let r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[e]]],s=r.mode===pe.Dense?this.valueOffsets[e]:e;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let r=this.offset+e;return(this.nullBitmap[r>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(yi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let f=s[c];r=(f&u)!==0,s[c]=n?f|u:f&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(e=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,o=this.children){return new t(e,n,r,i,s,o,this.dictionary)}slice(e,n){let{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,l=this._sliceBuffers(e,n,r,i);return this.clone(this.type,this.offset+e,n,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*e,a*n))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===p.Null)return this.clone(this.type,0,e,0);let{length:n,nullCount:r}=this,i=new Uint8Array((e+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(yi(this.offset,n,this.nullBitmap),0);let s=this.buffers;return s[fn.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s,{buffers:o}=this;return(s=o[fn.TYPE])&&(o[fn.TYPE]=s.subarray(e,e+n)),(s=o[fn.OFFSET])&&(o[fn.OFFSET]=s.subarray(e,e+n+1))||(s=o[fn.DATA])&&(o[fn.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}};se.prototype.children=Object.freeze([]);var Pf=class t extends U{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new se(n,r,i,i)}visitBool(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitInt(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFloat(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.data),s=$(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeUtf8(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.data),s=$(e.nullBitmap),o=il(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.data),s=$(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitLargeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.data),s=$(e.nullBitmap),o=il(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDate(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTimestamp(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitTime(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDecimal(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitList(e){let{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=$(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=$(e.nullBitmap),{length:o=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){let{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=J(n.ArrayType,e.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=e;if(O.isSparseUnion(n))return new se(n,r,o,a,[void 0,void 0,void 0,s],i);let l=di(e.valueOffsets);return new se(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.indices.ArrayType,e.data),{["dictionary"]:o=new te([new t().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitDuration(e){let{["type"]:n,["offset"]:r=0}=e,i=$(e.nullBitmap),s=J(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.valueType})}=e,s=$(e.nullBitmap),{["length"]:o=i.length/Lt(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new se(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){let{["type"]:n,["offset"]:r=0,["child"]:i=new t().visit({type:n.childType})}=e,s=$(e.nullBitmap),o=di(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new se(n,r,a,l,[o,void 0,s],[i])}},$S=new Pf;function G(t){return $S.visit(t)}var Oo=class{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function zl(t){return t.reduce((e,n)=>e+n.nullCount,0)}function Vl(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function $l(t,e,n,r){let i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(a);continue}let c=Math.max(0,n-l),f=Math.min(r-l,u);i.push(a.slice(c,f-c))}return i.length===0&&i.push(t[0].slice(0,0)),i}function jf(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function HS(t,e){let{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(let i of new mi(n,t.offset+(e||0),t.length,n,jl)){if(!i)return r;++r}return-1}function X(t,e,n){if(e===void 0)return-1;if(e===null)switch(t.typeId){case p.Union:break;case p.Dictionary:break;default:return HS(t,n)}let r=Ce.getVisitFn(t),i=$r(e);for(let s=(n||0)-1,o=t.length;++s{let i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Oo(t.data.length,r=>{let s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new zf(o)})}var zf=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexa.data):e;if(s.length===0||s.some(a=>!(a instanceof se)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:l,indexOf:u}=oy[o.typeId],c=s[0];this.isValid=f=>Eo(c,f),this.get=f=>a(c,f),this.set=(f,y)=>l(c,f,y),this.indexOf=f=>u(c,f),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,ay[o.typeId]),this._offsets=Vl(s);break}this.data=s,this.type=o,this.stride=Lt(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,n)=>e+n.byteLength,0)}get nullable(){return ry(this.data)}get nullCount(){return zl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.length))}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>-1}[Symbol.iterator](){return ps.visit(this)}concat(...e){return new t(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new t(No(this,e,n,({data:r,_offsets:i},s,o)=>$l(r,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return O.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(O.isDictionary(this.type)){let e=new Yl(this.data[0].dictionary),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return new Yl(this)}unmemoize(){if(O.isDictionary(this.type)&&this.isMemoized){let e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{let i=r.clone();return i.dictionary=e,i});return new t(n)}return this}};sy=Symbol.toStringTag;te[sy]=(t=>{t.type=O.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;let e=Object.keys(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(let n of e){let r=Ce.getVisitFnByTypeId(n),i=Xe.getVisitFnByTypeId(n),s=vi.getVisitFnByTypeId(n);oy[n]={get:r,set:i,indexOf:s},ay[n]=Object.create(t,{isValid:{value:hs(Eo)},get:{value:hs(Ce.getVisitFnByTypeId(n))},set:{value:Wl(Xe.getVisitFnByTypeId(n))},indexOf:{value:Hl(vi.getVisitFnByTypeId(n))}})}return"Vector"})(te.prototype);var Yl=class t extends te{constructor(e){super(e.data);let n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new t(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new te(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function ly(t){if(!t||t.length<=0)return function(i){return!0};let e="",n=t.filter(r=>r===r);return n.length>0&&(e=` switch (x) {${n.map(r=>` - case ${HS(r)}:`).join("")} + case ${YS(r)}:`).join("")} return false; }`),t.length!==n.length&&(e=`if (x !== x) return false; ${e}`),new Function("x",`${e} -return true;`)}function HS(t){return typeof t!="bigint"?fn(t):`${fn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function ly(t,e=0){return t.length>=e?t.subarray(0,e):uo(new t.constructor(e),t,0)}var vn=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=ly(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=ly(this.buffer,e)}},lr=class extends vn{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ps=class extends lr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ge=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ps,n&&n.length>0&&(this._isValid=ay(n))}toVector(){return new te([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:d}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=d?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),Q({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ge.prototype.length=1;ge.prototype.stride=1;ge.prototype.children=null;ge.prototype.finished=!1;ge.prototype.nullValues=null;ge.prototype._isValid=()=>!0;var Ce=class extends ge{constructor(e){super(e),this._values=new lr(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},vt=class extends ge{constructor(e){super(e),this._pendingLength=0,this._offsets=new ms(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Mn?n[Vr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Mt=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new gt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var oe=class t{constructor(e=[],n,r,i=ae.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Yl(Yl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Yl(Yl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};oe.prototype.fields=null;oe.prototype.metadata=null;oe.prototype.dictionaries=null;var q=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};q.prototype.type=null;q.prototype.name=null;q.prototype.nullable=null;q.prototype.metadata=null;function Yl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var YS=hi,KS=Ft,ur=class{static decode(e){e=new KS(V(e));let n=Mt.getRootAsFooter(e),r=oe.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new YS,r=oe.encode(n,e.schema);Mt.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())cr.encode(n,o);let i=n.endVector();Mt.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())cr.encode(n,o);let s=n.endVector();return Mt.startFooter(n),Mt.addSchema(n,r),Mt.addVersion(n,ae.V5),Mt.addRecordBatches(n,i),Mt.addDictionaries(n,s),Mt.finishFooterBuffer(n,Mt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=ae.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(me);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return O(this,void 0,void 0,function*(){return yield this.abort(e),me})}return(e){return O(this,void 0,void 0,function*(){return yield this.close(),me})}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(me)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Cn=class extends Kl{write(e){if((e=V(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ao(this.toUint8Array(!0)):this.toUint8Array(!1).then(ao)}toUint8Array(e=!1){return e?Et(this._values)[0]:O(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=rn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Et(o,a)[0]})}},Un=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Kt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Cn?this.source=new fr(Ge.fromAsyncIterable(e)):nl(e)?this.source=new fr(Ge.fromNodeStream(e)):lo(e)?this.source=new fr(Ge.fromDOMStream(e)):el(e)?this.source=new fr(Ge.fromDOMStream(e.body)):sn(e)?this.source=new fr(Ge.fromIterable(e)):Ot(e)?this.source=new fr(Ge.fromAsyncIterable(e)):Wt(e)&&(this.source=new fr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||me)}return(e){return Object.create(this.source.return&&this.source.return(e)||me)}},fr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return O(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return O(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return O(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return O(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||me;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return O(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||me;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var Fo=class extends Un{constructor(e,n){super(),this.position=0,this.buffer=V(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eko,Int128:()=>Ao,Int64:()=>dr,Uint64:()=>De});function ys(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var gs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ko=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ys(this.buffer[3])} ${ys(this.buffer[2])} ${ys(this.buffer[1])} ${ys(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Ql=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return E.isTimestamp(e)?J(Uint8Array,dr.convertArray(r[n])):(E.isInt(e)||E.isTime(e))&&e.bitWidth===64||E.isDuration(e)?J(Uint8Array,dr.convertArray(r[n])):E.isDate(e)&&e.unit===Ae.MILLISECOND?J(Uint8Array,dr.convertArray(r[n])):E.isDecimal(e)?J(Uint8Array,Ao.convertArray(r[n])):E.isBinary(e)||E.isLargeBinary(e)||E.isFixedSizeBinary(e)?QS(r[n]):E.isBool(e)?gi(r[n]):E.isUtf8(e)||E.isLargeUtf8(e)?On(r[n].join("")):J(Uint8Array,J(e.ArrayType,r[n].map(i=>+i)))}};function QS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var vs=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var _s=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,V(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Gl=class extends ge{constructor(e){super(e),this._values=new ps}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Ce{};Si.prototype._setValue=Df;var Mo=class extends Si{};Mo.prototype._setValue=Sl;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Ce{};Uo.prototype._setValue=Of;var Xl=class extends ge{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new At(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Ro=class extends Ce{};Ro.prototype._setValue=Bf;var Zl=class extends ge{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new mn(this.type.listSize,new q(n,e.type,!0)),r}};var xi=class extends Ce{setValue(e,n){this._values.set(e,n)}},Jl=class extends xi{setValue(e,n){super.setValue(e,Bo(n))}},ql=class extends xi{},eu=class extends xi{};var Ii=class extends Ce{};Ii.prototype._setValue=Ef;var Po=class extends Ii{};Po.prototype._setValue=Fl;var jo=class extends Ii{};jo.prototype._setValue=kl;var hr=class extends Ce{};hr.prototype._setValue=Ff;var zo=class extends hr{};zo.prototype._setValue=Al;var Vo=class extends hr{};Vo.prototype._setValue=Ll;var $o=class extends hr{};$o.prototype._setValue=Ml;var Wo=class extends hr{};Wo.prototype._setValue=Cl;var Qt=class extends Ce{setValue(e,n){this._values.set(e,n)}},tu=class extends Qt{},nu=class extends Qt{},ru=class extends Qt{},iu=class extends Qt{},su=class extends Qt{},ou=class extends Qt{},au=class extends Qt{},lu=class extends Qt{};var uu=class extends vt{constructor(e){super(e),this._offsets=new ms(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new hn(new q(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new yn(new q(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var fu=class extends ge{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var du=class extends ge{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new pe([...this.type.children,new q(n,e.type,!0)]),r}};var pr=class extends Ce{};pr.prototype._setValue=Nf;var Ho=class extends pr{};Ho.prototype._setValue=xl;var Yo=class extends pr{};Yo.prototype._setValue=Il;var Ko=class extends pr{};Ko.prototype._setValue=Bl;var Qo=class extends pr{};Qo.prototype._setValue=Dl;var mr=class extends Ce{};mr.prototype._setValue=Tf;var Go=class extends mr{};Go.prototype._setValue=Nl;var Xo=class extends mr{};Xo.prototype._setValue=Tl;var Zo=class extends mr{};Zo.prototype._setValue=Ol;var Jo=class extends mr{};Jo.prototype._setValue=El;var ws=class extends ge{constructor(e){super(e),this._typeIds=new lr(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new q(n,e.type)];return this.type=new pn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},hu=class extends ws{},pu=class extends ws{constructor(e){super(e),this._offsets=new lr(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var qo=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};qo.prototype._flushPending=vs.prototype._flushPending;var ea=class extends vt{constructor(e){super(e),this._values=new vn(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var Qf=class extends C{visitNull(){return fu}visitBool(){return Gl}visitInt(){return Qt}visitInt8(){return tu}visitInt16(){return nu}visitInt32(){return ru}visitInt64(){return iu}visitUint8(){return su}visitUint16(){return ou}visitUint32(){return au}visitUint64(){return lu}visitFloat(){return xi}visitFloat16(){return Jl}visitFloat32(){return ql}visitFloat64(){return eu}visitUtf8(){return qo}visitLargeUtf8(){return ea}visitBinary(){return vs}visitLargeBinary(){return _s}visitFixedSizeBinary(){return Ro}visitDate(){return Si}visitDateDay(){return Mo}visitDateMillisecond(){return Co}visitTimestamp(){return pr}visitTimestampSecond(){return Ho}visitTimestampMillisecond(){return Yo}visitTimestampMicrosecond(){return Ko}visitTimestampNanosecond(){return Qo}visitTime(){return mr}visitTimeSecond(){return Go}visitTimeMillisecond(){return Xo}visitTimeMicrosecond(){return Zo}visitTimeNanosecond(){return Jo}visitDecimal(){return Uo}visitList(){return uu}visitStruct(){return du}visitUnion(){return ws}visitDenseUnion(){return pu}visitSparseUnion(){return hu}visitDictionary(){return Xl}visitInterval(){return Ii}visitIntervalDayTime(){return Po}visitIntervalYearMonth(){return jo}visitDuration(){return hr}visitDurationSecond(){return zo}visitDurationMillisecond(){return Vo}visitDurationMicrosecond(){return $o}visitDurationNanosecond(){return Wo}visitFixedSizeList(){return Zl}visitMap(){return cu}},uy=new Qf;var j=class extends C{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function dt(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||dt(t,e)}function yr(t,e){return t===e||dt(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function mu(t,e){return t===e||dt(t,e)&&t.precision===e.precision}function GS(t,e){return t===e||dt(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ta(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function na(t,e){return t===e||dt(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function XS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function ZS(t,e){return t===e||dt(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||dt(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Rn.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||dt(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Rn.visit(t.indices,e.indices)&&Rn.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function ra(t,e){return t===e||dt(t,e)&&t.unit===e.unit}function qS(t,e){return t===e||dt(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function eb(t,e){return t===e||dt(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}j.prototype.visitNull=Bi;j.prototype.visitBool=Bi;j.prototype.visitInt=yr;j.prototype.visitInt8=yr;j.prototype.visitInt16=yr;j.prototype.visitInt32=yr;j.prototype.visitInt64=yr;j.prototype.visitUint8=yr;j.prototype.visitUint16=yr;j.prototype.visitUint32=yr;j.prototype.visitUint64=yr;j.prototype.visitFloat=mu;j.prototype.visitFloat16=mu;j.prototype.visitFloat32=mu;j.prototype.visitFloat64=mu;j.prototype.visitUtf8=Bi;j.prototype.visitLargeUtf8=Bi;j.prototype.visitBinary=Bi;j.prototype.visitLargeBinary=Bi;j.prototype.visitFixedSizeBinary=GS;j.prototype.visitDate=Gf;j.prototype.visitDateDay=Gf;j.prototype.visitDateMillisecond=Gf;j.prototype.visitTimestamp=ta;j.prototype.visitTimestampSecond=ta;j.prototype.visitTimestampMillisecond=ta;j.prototype.visitTimestampMicrosecond=ta;j.prototype.visitTimestampNanosecond=ta;j.prototype.visitTime=na;j.prototype.visitTimeSecond=na;j.prototype.visitTimeMillisecond=na;j.prototype.visitTimeMicrosecond=na;j.prototype.visitTimeNanosecond=na;j.prototype.visitDecimal=Bi;j.prototype.visitList=XS;j.prototype.visitStruct=ZS;j.prototype.visitUnion=Xf;j.prototype.visitDenseUnion=Xf;j.prototype.visitSparseUnion=Xf;j.prototype.visitDictionary=JS;j.prototype.visitInterval=Zf;j.prototype.visitIntervalDayTime=Zf;j.prototype.visitIntervalYearMonth=Zf;j.prototype.visitDuration=ra;j.prototype.visitDurationSecond=ra;j.prototype.visitDurationMillisecond=ra;j.prototype.visitDurationMicrosecond=ra;j.prototype.visitDurationNanosecond=ra;j.prototype.visitFixedSizeList=qS;j.prototype.visitMap=eb;var Rn=new j;function Di(t,e){return Rn.compareSchemas(t,e)}function cy(t,e){return Rn.compareFields(t,e)}function fy(t,e){return Rn.visit(t,e)}function bi(t){let e=t.type,n=new(uy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function yu(t,e){return tb(t,e.map(n=>n.data.concat()))}function tb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((d,y)=>Math.max(d,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Q({type:new pe(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(d=>new Oe(t,d))]}function nb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let d=t[a];t[a]=d.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Q({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var dy,_t=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new oe([]),this._offsets=[0],this;let i,s;e[0]instanceof oe&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Oe)return[l];if(l instanceof t)return l.batches;if(l instanceof ie){if(l.type instanceof pe)return[new Oe(new oe(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new te([l[v]])),d=i??new oe(u.map((v,w)=>new q(String(v),c[w].type,c[w].nullable))),[,y]=yu(d,c);return y.length===0?[new Oe(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new oe([]),!(i instanceof oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?hs.visit(new te(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ +return true;`)}function YS(t){return typeof t!="bigint"?dn(t):`${dn(t)}n`}function Vf(t,e){let n=Math.ceil(t)*e-1;return(n-n%64+64||64)/e}function uy(t,e=0){return t.length>=e?t.subarray(0,e):co(new t.constructor(e),t,0)}var _n=class{constructor(e,n=0,r=1){this.length=Math.ceil(n/r),this.buffer=new e(this.length),this.stride=r,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,n){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let n=this.stride,r=this.length*n,i=this.buffer.length;r>=i&&this._resize(i===0?Vf(r*1,this.BYTES_PER_ELEMENT):Vf(r*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=Vf(e*this.stride,this.BYTES_PER_ELEMENT);let n=uy(this.buffer,e);return this.clear(),n}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=uy(this.buffer,e)}},ur=class extends _n{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,n){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=n,this}},ms=class extends ur{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,n){let{buffer:r}=this.reserve(e-this.length+1),i=e>>3,s=e%8,o=r[i]>>s&1;return n?o===0&&(r[i]|=1<=0&&i.fill(i[r],r,e),i[e]=i[e-1]+n,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}};var ve=class{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e){throw new Error('"throughDOM" not available in this environment')}constructor({type:e,nullValues:n}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=n,this.stride=Lt(e),this._nulls=new ms,n&&n.length>0&&(this._isValid=ly(n))}toVector(){return new te([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:n,_values:r,_nulls:i,_typeIds:s,children:o}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),o.reduce((a,l)=>a+l.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((n,r)=>n+r.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,n){return this.setValid(e,this.isValid(n))&&this.setValue(e,n),this}setValue(e,n){this._setValue(this,e,n)}setValid(e,n){return this.length=this._nulls.set(e,+n).length,n}addChild(e,n=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,n,r,i,{type:s,length:o,nullCount:a,_typeIds:l,_offsets:u,_values:c,_nulls:f}=this;(n=l?.flush(o))?i=u?.flush(o):(i=u?.flush(o))?e=c?.flush(u.last()):e=c?.flush(o),a>0&&(r=f?.flush(o));let y=this.children.map(v=>v.flush());return this.clear(),G({type:s,length:o,nullCount:a,children:y,child:y[0],data:e,typeIds:n,nullBitmap:r,valueOffsets:i})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,n,r,i;this.length=0,(e=this._nulls)===null||e===void 0||e.clear(),(n=this._values)===null||n===void 0||n.clear(),(r=this._offsets)===null||r===void 0||r.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};ve.prototype.length=1;ve.prototype.stride=1;ve.prototype.children=null;ve.prototype.finished=!1;ve.prototype.nullValues=null;ve.prototype._isValid=()=>!0;var Ue=class extends ve{constructor(e){super(e),this._values=new ur(this.ArrayType,0,this.stride)}setValue(e,n){let r=this._values;return r.reserve(e-r.length+1),super.setValue(e,n)}},_t=class extends ve{constructor(e){super(e),this._pendingLength=0,this._offsets=new ys(e.type)}setValue(e,n){let r=this._pending||(this._pending=new Map),i=r.get(e);i&&(this._pendingLength-=i.length),this._pendingLength+=n instanceof Ln?n[Vr].length:n.length,r.set(e,n)}setValid(e,n){return super.setValid(e,n)?!0:((this._pending||(this._pending=new Map)).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,n=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,n),this}};var _i=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(BigInt(i??0)),e.pad(4),e.writeInt32(r),e.writeInt64(BigInt(n??0)),e.offset()}};var Ct=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}schema(e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new vt).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){let r=this.bb.__offset(this.bb_pos,10);return r?(n||new _i).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new je).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}};var ae=class t{constructor(e=[],n,r,i=le.V5){this.fields=e||[],this.metadata=n||new Map,r||(r=$f(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){let n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new t(r,this.metadata)}selectAt(e){let n=e.map(r=>this.fields[r]).filter(Boolean);return new t(n,this.metadata)}assign(...e){let n=e[0]instanceof t?e[0]:Array.isArray(e[0])?new t(e[0]):new t(e),r=[...this.fields],i=Kl(Kl(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{let l=r.findIndex(u=>u.name===a.name);return~l?(r[l]=a.clone({metadata:Kl(Kl(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=$f(s,new Map);return new t([...r,...s],i,new Map([...this.dictionaries,...o]))}};ae.prototype.fields=null;ae.prototype.metadata=null;ae.prototype.dictionaries=null;var q=class t{static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new t(`${n}`,r,i,s)}constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],t.new(n,r,i,s)}};q.prototype.type=null;q.prototype.name=null;q.prototype.nullable=null;q.prototype.metadata=null;function Kl(t,e){return new Map([...t||new Map,...e||new Map])}function $f(t,e=new Map){for(let n=-1,r=t.length;++n0&&$f(s.children,e)}return e}var KS=hi,QS=kt,cr=class{static decode(e){e=new QS($(e));let n=Ct.getRootAsFooter(e),r=ae.decode(n.schema(),new Map,n.version());return new Wf(r,n)}static encode(e){let n=new KS,r=ae.encode(n,e.schema);Ct.startRecordBatchesVector(n,e.numRecordBatches);for(let o of[...e.recordBatches()].slice().reverse())fr.encode(n,o);let i=n.endVector();Ct.startDictionariesVector(n,e.numDictionaries);for(let o of[...e.dictionaryBatches()].slice().reverse())fr.encode(n,o);let s=n.endVector();return Ct.startFooter(n),Ct.addSchema(n,r),Ct.addVersion(n,le.V5),Ct.addRecordBatches(n,i),Ct.addDictionaries(n,s),Ct.finishFooterBuffer(n,Ct.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,n=le.V5,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return T(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(ye);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Ge.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Ge.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return T(this,void 0,void 0,function*(){return yield this.abort(e),ye})}return(e){return T(this,void 0,void 0,function*(){return yield this.close(),ye})}read(e){return T(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return T(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(ye)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Cn=class extends Ql{write(e){if((e=$(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?lo(this.toUint8Array(!0)):this.toUint8Array(!1).then(lo)}toUint8Array(e=!1){return e?Ft(this._values)[0]:T(this,void 0,void 0,function*(){var n,r,i,s;let o=[],a=0;try{for(var l=!0,u=sn(this),c;c=yield u.next(),n=c.done,!n;l=!0){s=c.value,l=!1;let f=s;o.push(f),a+=f.byteLength}}catch(f){r={error:f}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Ft(o,a)[0]})}},Un=class{constructor(e){e&&(this.source=new Hf(Ge.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Qt=class t{constructor(e){e instanceof t?this.source=e.source:e instanceof Cn?this.source=new dr(Ge.fromAsyncIterable(e)):rl(e)?this.source=new dr(Ge.fromNodeStream(e)):uo(e)?this.source=new dr(Ge.fromDOMStream(e)):tl(e)?this.source=new dr(Ge.fromDOMStream(e.body)):on(e)?this.source=new dr(Ge.fromIterable(e)):Et(e)?this.source=new dr(Ge.fromAsyncIterable(e)):Ht(e)&&(this.source=new dr(Ge.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Hf=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||ye)}return(e){return Object.create(this.source.return&&this.source.return(e)||ye)}},dr=class{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return T(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return T(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return T(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e){return T(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(e){return T(this,void 0,void 0,function*(){let n=this.source.throw&&(yield this.source.throw(e))||ye;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return T(this,void 0,void 0,function*(){let n=this.source.return&&(yield this.source.return(e))||ye;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}};var ko=class extends Un{constructor(e,n){super(),this.position=0,this.buffer=$(e),this.size=n===void 0?this.buffer.byteLength:n}readInt32(e){let{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eAo,Int128:()=>Mo,Int64:()=>hr,Uint64:()=>De});function gs(t){return t<0&&(t=4294967295+t+1),`0x${t.toString(16)}`}var vs=8,Yf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Ao=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){let n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${gs(this.buffer[3])} ${gs(this.buffer[2])} ${gs(this.buffer[1])} ${gs(this.buffer[0])}`}static multiply(e,n){return new t(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new t(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return t.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return t.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){let r=e.startsWith("-"),i=e.length,s=new t(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}},Gl=class extends Lo{constructor(e,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):gi(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.OffsetArrayType,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return J(Uint8Array,J(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){let{sources:r}=this;return O.isTimestamp(e)?J(Uint8Array,hr.convertArray(r[n])):(O.isInt(e)||O.isTime(e))&&e.bitWidth===64||O.isDuration(e)?J(Uint8Array,hr.convertArray(r[n])):O.isDate(e)&&e.unit===ke.MILLISECOND?J(Uint8Array,hr.convertArray(r[n])):O.isDecimal(e)?J(Uint8Array,Mo.convertArray(r[n])):O.isBinary(e)||O.isLargeBinary(e)||O.isFixedSizeBinary(e)?GS(r[n]):O.isBool(e)?gi(r[n]):O.isUtf8(e)||O.isLargeUtf8(e)?On(r[n].join("")):J(Uint8Array,J(e.ArrayType,r[n].map(i=>+i)))}};function GS(t){let e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}var _s=class extends _t{constructor(e){super(e),this._values=new _n(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,$(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,0);else{let l=a.length;i.set(a,s),r.set(o,l),s+=l}}};var ws=class extends _t{constructor(e){super(e),this._values=new _n(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,$(n))}_flushPending(e,n){let r=this._offsets,i=this._values.reserve(n).buffer,s=0;for(let[o,a]of e)if(a===void 0)r.set(o,BigInt(0));else{let l=a.length;i.set(a,s),r.set(o,BigInt(l)),s+=l}}};var Xl=class extends ve{constructor(e){super(e),this._values=new ms}setValue(e,n){this._values.set(e,+n)}};var Si=class extends Ue{};Si.prototype._setValue=Df;var Co=class extends Si{};Co.prototype._setValue=bl;var Uo=class extends Si{};Uo.prototype._setValue=xl;var Ro=class extends Ue{};Ro.prototype._setValue=Of;var Zl=class extends ve{constructor({type:e,nullValues:n,dictionaryHashFunction:r}){super({type:new Mt(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=bi({type:this.type.indices,nullValues:n}),this.dictionary=bi({type:this.type.dictionary,nullValues:null}),typeof r=="function"&&(this.valueToKey=r)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,n){let r=this.indices;return n=r.setValid(e,n),this.length=r.length,n}setValue(e,n){let r=this._keysToIndices,i=this.valueToKey(n),s=r[i];return s===void 0&&(r[i]=s=this._dictionaryOffset+this.dictionary.append(n).length-1),this.indices.setValue(e,s)}flush(){let e=this.type,n=this._dictionary,r=this.dictionary.toVector(),i=this.indices.flush().clone(e);return i.dictionary=n?n.concat(r):r,this.finished||(this._dictionaryOffset+=r.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e=="string"?e:`${e}`}};var Po=class extends Ue{};Po.prototype._setValue=Bf;var Jl=class extends ve{setValue(e,n){let[r]=this.children,i=e*this.stride;for(let s=-1,o=n.length;++s0)throw new Error("FixedSizeListBuilder can only have one child.");let r=this.children.push(e);return this.type=new yn(this.type.listSize,new q(n,e.type,!0)),r}};var xi=class extends Ue{setValue(e,n){this._values.set(e,n)}},ql=class extends xi{setValue(e,n){super.setValue(e,Do(n))}},eu=class extends xi{},tu=class extends xi{};var Ii=class extends Ue{};Ii.prototype._setValue=Ef;var jo=class extends Ii{};jo.prototype._setValue=kl;var zo=class extends Ii{};zo.prototype._setValue=Al;var pr=class extends Ue{};pr.prototype._setValue=Ff;var Vo=class extends pr{};Vo.prototype._setValue=Ml;var $o=class extends pr{};$o.prototype._setValue=Ll;var Wo=class extends pr{};Wo.prototype._setValue=Cl;var Ho=class extends pr{};Ho.prototype._setValue=Ul;var Gt=class extends Ue{setValue(e,n){this._values.set(e,n)}},nu=class extends Gt{},ru=class extends Gt{},iu=class extends Gt{},su=class extends Gt{},ou=class extends Gt{},au=class extends Gt{},lu=class extends Gt{},uu=class extends Gt{};var cu=class extends _t{constructor(e){super(e),this._offsets=new ys(e.type)}addChild(e,n="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new pn(new q(n,e.type,!0)),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(typeof s>"u")n.set(i,0);else{let o=s,a=o.length,l=n.set(i,a).buffer[i];for(let u=-1;++u0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=e,this.type=new gn(new q(n,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let n=this._offsets,[r]=this.children;for(let[i,s]of e)if(s===void 0)n.set(i,0);else{let{[i]:o,[i+1]:a}=n.set(i,s.size).buffer;for(let l of s.entries())if(r.set(o,l),++o>=a)break}}};var du=class extends ve{setValue(e,n){}setValid(e,n){return this.length=Math.max(e+1,this.length),n}};var hu=class extends ve{setValue(e,n){let{children:r,type:i}=this;switch(Array.isArray(n)||n.constructor){case!0:return i.children.forEach((s,o)=>r[o].set(e,n[o]));case Map:return i.children.forEach((s,o)=>r[o].set(e,n.get(s.name)));default:return i.children.forEach((s,o)=>r[o].set(e,n[s.name]))}}setValid(e,n){return super.setValid(e,n)||this.children.forEach(r=>r.setValid(e,n)),n}addChild(e,n=`${this.numChildren}`){let r=this.children.push(e);return this.type=new me([...this.type.children,new q(n,e.type,!0)]),r}};var mr=class extends Ue{};mr.prototype._setValue=Nf;var Yo=class extends mr{};Yo.prototype._setValue=Il;var Ko=class extends mr{};Ko.prototype._setValue=Bl;var Qo=class extends mr{};Qo.prototype._setValue=Dl;var Go=class extends mr{};Go.prototype._setValue=Nl;var yr=class extends Ue{};yr.prototype._setValue=Tf;var Xo=class extends yr{};Xo.prototype._setValue=Tl;var Zo=class extends yr{};Zo.prototype._setValue=Ol;var Jo=class extends yr{};Jo.prototype._setValue=El;var qo=class extends yr{};qo.prototype._setValue=Fl;var Ss=class extends ve{constructor(e){super(e),this._typeIds=new ur(Int8Array,0,1),typeof e.valueToChildTypeId=="function"&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,n){return this.set(this.length,e,n)}set(e,n,r){return r===void 0&&(r=this._valueToChildTypeId(this,n,e)),this.setValue(e,n,r),this}setValue(e,n,r){this._typeIds.set(e,r);let i=this.type.typeIdToChildIndex[r],s=this.children[i];s?.set(e,n)}addChild(e,n=`${this.children.length}`){let r=this.children.push(e),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new q(n,e.type)];return this.type=new mn(s,[...o,r],a),r}_valueToChildTypeId(e,n,r){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},pu=class extends Ss{},mu=class extends Ss{constructor(e){super(e),this._offsets=new ur(Int32Array)}setValue(e,n,r){let i=this._typeIds.set(e,r).buffer[e],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(e,s.length).buffer[e];s?.set(o,n)}};var ea=class extends _t{constructor(e){super(e),this._values=new _n(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};ea.prototype._flushPending=_s.prototype._flushPending;var ta=class extends _t{constructor(e){super(e),this._values=new _n(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,n){return super.setValue(e,On(n))}_flushPending(e,n){}};ta.prototype._flushPending=ws.prototype._flushPending;var Qf=class extends U{visitNull(){return du}visitBool(){return Xl}visitInt(){return Gt}visitInt8(){return nu}visitInt16(){return ru}visitInt32(){return iu}visitInt64(){return su}visitUint8(){return ou}visitUint16(){return au}visitUint32(){return lu}visitUint64(){return uu}visitFloat(){return xi}visitFloat16(){return ql}visitFloat32(){return eu}visitFloat64(){return tu}visitUtf8(){return ea}visitLargeUtf8(){return ta}visitBinary(){return _s}visitLargeBinary(){return ws}visitFixedSizeBinary(){return Po}visitDate(){return Si}visitDateDay(){return Co}visitDateMillisecond(){return Uo}visitTimestamp(){return mr}visitTimestampSecond(){return Yo}visitTimestampMillisecond(){return Ko}visitTimestampMicrosecond(){return Qo}visitTimestampNanosecond(){return Go}visitTime(){return yr}visitTimeSecond(){return Xo}visitTimeMillisecond(){return Zo}visitTimeMicrosecond(){return Jo}visitTimeNanosecond(){return qo}visitDecimal(){return Ro}visitList(){return cu}visitStruct(){return hu}visitUnion(){return Ss}visitDenseUnion(){return mu}visitSparseUnion(){return pu}visitDictionary(){return Zl}visitInterval(){return Ii}visitIntervalDayTime(){return jo}visitIntervalYearMonth(){return zo}visitDuration(){return pr}visitDurationSecond(){return Vo}visitDurationMillisecond(){return $o}visitDurationMicrosecond(){return Wo}visitDurationNanosecond(){return Ho}visitFixedSizeList(){return Jl}visitMap(){return fu}},cy=new Qf;var z=class extends U{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}};function ht(t,e){return e instanceof t.constructor}function Bi(t,e){return t===e||ht(t,e)}function gr(t,e){return t===e||ht(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function yu(t,e){return t===e||ht(t,e)&&t.precision===e.precision}function XS(t,e){return t===e||ht(t,e)&&t.byteWidth===e.byteWidth}function Gf(t,e){return t===e||ht(t,e)&&t.unit===e.unit}function na(t,e){return t===e||ht(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function ra(t,e){return t===e||ht(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function ZS(t,e){return t===e||ht(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function JS(t,e){return t===e||ht(t,e)&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function Xf(t,e){return t===e||ht(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&Rn.compareManyFields(t.children,e.children)}function qS(t,e){return t===e||ht(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Rn.visit(t.indices,e.indices)&&Rn.visit(t.dictionary,e.dictionary)}function Zf(t,e){return t===e||ht(t,e)&&t.unit===e.unit}function ia(t,e){return t===e||ht(t,e)&&t.unit===e.unit}function eb(t,e){return t===e||ht(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}function tb(t,e){return t===e||ht(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Rn.compareManyFields(t.children,e.children)}z.prototype.visitNull=Bi;z.prototype.visitBool=Bi;z.prototype.visitInt=gr;z.prototype.visitInt8=gr;z.prototype.visitInt16=gr;z.prototype.visitInt32=gr;z.prototype.visitInt64=gr;z.prototype.visitUint8=gr;z.prototype.visitUint16=gr;z.prototype.visitUint32=gr;z.prototype.visitUint64=gr;z.prototype.visitFloat=yu;z.prototype.visitFloat16=yu;z.prototype.visitFloat32=yu;z.prototype.visitFloat64=yu;z.prototype.visitUtf8=Bi;z.prototype.visitLargeUtf8=Bi;z.prototype.visitBinary=Bi;z.prototype.visitLargeBinary=Bi;z.prototype.visitFixedSizeBinary=XS;z.prototype.visitDate=Gf;z.prototype.visitDateDay=Gf;z.prototype.visitDateMillisecond=Gf;z.prototype.visitTimestamp=na;z.prototype.visitTimestampSecond=na;z.prototype.visitTimestampMillisecond=na;z.prototype.visitTimestampMicrosecond=na;z.prototype.visitTimestampNanosecond=na;z.prototype.visitTime=ra;z.prototype.visitTimeSecond=ra;z.prototype.visitTimeMillisecond=ra;z.prototype.visitTimeMicrosecond=ra;z.prototype.visitTimeNanosecond=ra;z.prototype.visitDecimal=Bi;z.prototype.visitList=ZS;z.prototype.visitStruct=JS;z.prototype.visitUnion=Xf;z.prototype.visitDenseUnion=Xf;z.prototype.visitSparseUnion=Xf;z.prototype.visitDictionary=qS;z.prototype.visitInterval=Zf;z.prototype.visitIntervalDayTime=Zf;z.prototype.visitIntervalYearMonth=Zf;z.prototype.visitDuration=ia;z.prototype.visitDurationSecond=ia;z.prototype.visitDurationMillisecond=ia;z.prototype.visitDurationMicrosecond=ia;z.prototype.visitDurationNanosecond=ia;z.prototype.visitFixedSizeList=eb;z.prototype.visitMap=tb;var Rn=new z;function Di(t,e){return Rn.compareSchemas(t,e)}function fy(t,e){return Rn.compareFields(t,e)}function dy(t,e){return Rn.visit(t,e)}function bi(t){let e=t.type,n=new(cy.getVisitFn(e)())(t);if(e.children&&e.children.length>0){let r=t.children||[],i={nullValues:t.nullValues},s=Array.isArray(r)?((o,a)=>r[a]||i):(({name:o})=>r[o]||i);for(let[o,a]of e.children.entries()){let{type:l}=a,u=s(a,o);n.children.push(bi(Object.assign(Object.assign({},u),{type:l})))}}return n}function gu(t,e){return nb(t,e.map(n=>n.data.concat()))}function nb(t,e){let n=[...t.fields],r=[],i={numBatches:e.reduce((f,y)=>Math.max(f,y.length),0)},s=0,o=0,a=-1,l=e.length,u,c=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=G({type:new me(n),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(n),r.map(f=>new Oe(t,f))]}function rb(t,e,n,r,i){var s;let o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)c===e?n[a]=u:(n[a]=u.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(u.slice(e,c-e))));else{let f=t[a];t[a]=f.clone({nullable:!0}),n[a]=(s=u?._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:G({type:f.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var hy,wt=class t{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new ae([]),this._offsets=[0],this;let i,s;e[0]instanceof ae&&(i=e.shift()),e.at(-1)instanceof Uint32Array&&(s=e.pop());let o=l=>{if(l){if(l instanceof Oe)return[l];if(l instanceof t)return l.batches;if(l instanceof se){if(l.type instanceof me)return[new Oe(new ae(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){let u=Object.keys(l),c=u.map(v=>new te([l[v]])),f=i??new ae(u.map((v,_)=>new q(String(v),c[_].type,c[_].nullable))),[,y]=gu(f,c);return y.length===0?[new Oe(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new ae([]),!(i instanceof ae))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of a){if(!(l instanceof Oe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Di(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??Vl(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=zl(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(pi(e,this.numRows))}set(e,n){}indexOf(e,n){return-1}[Symbol.iterator](){return this.batches.length>0?ps.visit(new te(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){let n=this.schema,r=this.data.concat(e.flatMap(({data:i})=>i));return new t(n,r.map(i=>new Oe(n,i)))}slice(e,n){let r=this.schema;[e,n]=Do({length:this.numRows},e,n);let i=Vl(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Oe(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new te(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=yu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,d]=a,y=n.findIndex(v=>v.name===l.name);return~y?d[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...yu(s,o))}};dy=Symbol.toStringTag;_t[dy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ds(Oo),t.get=ds(Me.getVisitFn(p.Struct)),t.set=$l(Xe.getVisitFn(p.Struct)),t.indexOf=Wl(vi.getVisitFn(p.Struct)),"Table"))(_t.prototype);var py,Oe=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof oe))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new pe(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=e,!(this.data instanceof ie))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=hy(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=q.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new oe(r),a=Q({type:new pe(r),length:s,children:i,nullCount:0});[this.schema,this.data]=hy(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=my(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Me.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return hs.visit(new te([this.data]))}toArray(){return[...this]}concat(...e){return new _t(this.schema,[this,...e])}slice(e,n){let[r]=new te([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,Q({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Q({type:new pe(n.fields),length:this.numRows,children:r});return new t(n,i)}};py=Symbol.toStringTag;Oe[py]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Oe.prototype);function hy(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Q({type:new pe(i),length:n,children:s})]}function my(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sQ({type:i.type})),r=Q({type:new pe(e.fields),nullCount:0,children:n});super(e,r)}};var _n=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ae.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):ee.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new ze).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,ae.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,ee.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends C{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return ln.startInt(n),ln.addBitWidth(n,e.bitWidth),ln.addIsSigned(n,e.isSigned),ln.endInt(n)}visitFloat(e,n){return Ur.startFloatingPoint(n),Ur.addPrecision(n,e.precision),Ur.endFloatingPoint(n)}visitBinary(e,n){return mo.startBinary(n),mo.endBinary(n)}visitLargeBinary(e,n){return go.startLargeBinary(n),go.endLargeBinary(n)}visitBool(e,n){return yo.startBool(n),yo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitLargeUtf8(e,n){return vo.startLargeUtf8(n),vo.endLargeUtf8(n)}visitDecimal(e,n){return An.startDecimal(n),An.addScale(n,e.scale),An.addPrecision(n,e.precision),An.addBitWidth(n,e.bitWidth),An.endDecimal(n)}visitDate(e,n){return Ar.startDate(n),Ar.addUnit(n,e.unit),Ar.endDate(n)}visitTime(e,n){return Kn.startTime(n),Kn.addUnit(n,e.unit),Kn.addBitWidth(n,e.bitWidth),Kn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Qn.startTimestamp(n),Qn.addUnit(n,e.unit),r!==void 0&&Qn.addTimezone(n,r),Qn.endTimestamp(n)}visitInterval(e,n){return Rr.startInterval(n),Rr.addUnit(n,e.unit),Rr.endInterval(n)}visitDuration(e,n){return Lr.startDuration(n),Lr.addUnit(n,e.unit),Lr.endDuration(n)}visitList(e,n){return _o.startList(n),_o.endList(n)}visitStruct(e,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(e,n){un.startTypeIdsVector(n,e.typeIds.length);let r=un.createTypeIdsVector(n,e.typeIds);return un.startUnion(n),un.addMode(n,e.mode),un.addTypeIds(n,r),un.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return kn.startDictionaryEncoding(n),kn.addId(n,BigInt(e.id)),kn.addIsOrdered(n,e.isOrdered),r!==void 0&&kn.addIndexType(n,r),kn.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Mr.startFixedSizeBinary(n),Mr.addByteWidth(n,e.byteWidth),Mr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Cr.startFixedSizeList(n),Cr.addListSize(n,e.listSize),Cr.endFixedSizeList(n)}visitMap(e,n){return Pr.startMap(n),Pr.addKeysSorted(n,e.keysSorted),Pr.endMap(n)}},gu=new Jf;function _y(t,e=new Map){return new oe(ib(t,e),vu(t.metadata),e)}function qf(t){return new Ze(t.count,Sy(t.columns),by(t.columns))}function wy(t){return new St(qf(t.data),t.id,t.isDelta)}function ib(t,e){return(t.fields||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function yy(t,e){return(t.children||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function Sy(t){return(t||[]).reduce((e,n)=>[...e,new Gt(n.count,sb(n.VALIDITY)),...Sy(n.children)],[])}function by(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function xy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=vy(t,yy(t,e)),i=new q(t.name,o,t.nullable,vu(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?gy(r):new Ln,a=new At(e.get(n),r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))):(r=(r=s.indexType)?gy(r):new Ln,e.set(n,o=vy(t,yy(t,e))),a=new At(o,r,n,s.isOrdered),i=new q(t.name,a,t.nullable,vu(t.metadata))),i||null}function vu(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function gy(t){return new Ve(t.isSigned,t.bitWidth)}function vy(t,e){let n=t.type.name;switch(n){case"NONE":return new ft;case"null":return new ft;case"binary":return new Gn;case"largebinary":return new Xn;case"utf8":return new Zn;case"largeutf8":return new Jn;case"bool":return new qn;case"list":return new hn((e||[])[0]);case"struct":return new pe(e||[]);case"struct_":return new pe(e||[])}switch(n){case"int":{let r=t.type;return new Ve(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Yt(ce[r.precision])}case"decimal":{let r=t.type;return new er(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new tr(Ae[r.unit])}case"time":{let r=t.type;return new nr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new rr(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new ir(He[r.unit])}case"duration":{let r=t.type;return new sr(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new pn(de[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new or(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new mn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new yn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ob=hi,ab=Ft,bt=class t{static fromJSON(e,n){let r=new t(0,ae.V5,n);return r._createHeader=lb(e,n),r}static decode(e){e=new ab(V(e));let n=_n.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=ub(n,s),o}static encode(e){let n=new ob,r=-1;return e.isSchema()?r=oe.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=St.encode(n,e.header())),_n.startMessage(n),_n.addVersion(n,ae.V5),_n.addHeader(n,r),_n.addHeaderType(n,e.headerType),_n.addBodyLength(n,BigInt(e.bodyLength)),_n.finishMessageBuffer(n,_n.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof oe)return new t(0,ae.V5,ee.Schema,e);if(e instanceof Ze)return new t(n,ae.V5,ee.RecordBatch,e);if(e instanceof St)return new t(n,ae.V5,ee.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===ee.Schema}isRecordBatch(){return this.headerType===ee.RecordBatch}isDictionaryBatch(){return this.headerType===ee.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},St=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},wt=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Gt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function lb(t,e){return(()=>{switch(e){case ee.Schema:return oe.fromJSON(t);case ee.RecordBatch:return Ze.fromJSON(t);case ee.DictionaryBatch:return St.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}function ub(t,e){return(()=>{switch(e){case ee.Schema:return oe.decode(t.header(new gt),new Map,t.version());case ee.RecordBatch:return Ze.decode(t.header(new kt),t.version());case ee.DictionaryBatch:return St.decode(t.header(new Yn),t.version())}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}q.encode=wb;q.decode=vb;q.fromJSON=xy;oe.encode=_b;oe.decode=cb;oe.fromJSON=_y;Ze.encode=Sb;Ze.decode=fb;Ze.fromJSON=qf;St.encode=bb;St.decode=db;St.fromJSON=wy;Gt.encode=xb;Gt.decode=pb;wt.encode=Ib;wt.decode=hb;function cb(t,e=new Map,n=ae.V5){let r=gb(t,e);return new oe(r,_u(t),e,n)}function fb(t,e=ae.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),mb(t),yb(t,e))}function db(t,e=ae.V5){return new St(Ze.decode(t.data(),e),t.id(),t.isDelta())}function hb(t){return new wt(t.offset(),t.length())}function pb(t){return new Gt(t.length(),t.nullCount())}function mb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rq.encode(t,s));gt.startFieldsVector(t,n.length);let r=gt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?gt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return ze.startKeyValue(t),ze.addKey(t,a),ze.addValue(t,l),ze.endKeyValue(t)})):-1;return gt.startSchema(t),gt.addFields(t,r),gt.addEndianness(t,Bb?kr.Little:kr.Big),i!==-1&>.addCustomMetadata(t,i),gt.endSchema(t)}function wb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;E.isDictionary(s)?(o=s.dictionary.typeId,i=gu.visit(s,t),r=gu.visit(s.dictionary,t)):r=gu.visit(s,t);let a=(s.children||[]).map(c=>q.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,d])=>{let y=t.createString(`${c}`),v=t.createString(`${d}`);return ze.startKeyValue(t),ze.addKey(t,y),ze.addValue(t,v),ze.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function Sb(t,e){let n=e.nodes||[],r=e.buffers||[];kt.startNodesVector(t,n.length);for(let o of n.slice().reverse())Gt.encode(t,o);let i=t.endVector();kt.startBuffersVector(t,r.length);for(let o of r.slice().reverse())wt.encode(t,o);let s=t.endVector();return kt.startRecordBatch(t),kt.addLength(t,BigInt(e.length)),kt.addNodes(t,i),kt.addBuffers(t,s),kt.endRecordBatch(t)}function bb(t,e){let n=Ze.encode(t,e.data);return Yn.startDictionaryBatch(t),Yn.addId(t,BigInt(e.id)),Yn.addIsDelta(t,e.isDelta),Yn.addData(t,n),Yn.endDictionaryBatch(t)}function xb(t,e){return rs.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Ib(t,e){return ns.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Bb=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${ee[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${ee[t]} Message is null or length 0.`,Ny=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Ty=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,Ss=class{constructor(e){this.source=e instanceof Un?e:new Un(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?me:e.value===-1&&(e=this.readMetadataLength()).done?me:(e=this.readMetadata(e.value)).done?me:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=V(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=ee.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},wu=4,ed="ARROW1",bs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Za(e)?Nb(e):qa(e)?Eb(e):Ot(e)?O(this,void 0,void 0,function*(){return yield t.from(yield e)}):el(e)||lo(e)||nl(e)||Wt(e)?Ob(new Kt(e)):Tb(new Un(e))}static readAll(e){return e instanceof t?e.isSync()?Ey(e):Fy(e):Za(e)||ArrayBuffer.isView(e)||sn(e)||Ja(e)?Ey(e):Fy(e)}},gr=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Tt(this,arguments,function*(){yield Z(yield*es(rn(this[Symbol.iterator]())))})}},Ti=class extends Ct{constructor(e){super(e),this._impl=e}readAll(){return O(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=rn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends gr{constructor(e){super(e),this._impl=e}},bu=class extends Ti{constructor(e){super(e),this._impl=e}},xu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=Q({type:new pe(this.schema.fields),length:e.length,children:r});return new Oe(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new te(u)):new te(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Is=class extends xu{constructor(e,n){super(n),this._reader=Za(e)?new sa(this._handle=e):new Ss(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):me}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):me}next(){if(this.closed)return me;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Bs=class extends xu{constructor(e,n){super(n),this._reader=new ia(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return O(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return O(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ky(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):me})}return(e){return O(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):me})}next(){return O(this,void 0,void 0,function*(){if(this.closed)return me;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Iu=class extends Is{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof Fo?e:new Fo(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return ur.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return O(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return O(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return O(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return O(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return ur.decode(i)})}_readNextMessageAndValidate(e){return O(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?Su(e)?new Oi(new Iu(t.read())):new gr(new Is(t)):new gr(new Is((function*(){})()))}function Ob(t){return O(this,void 0,void 0,function*(){let e=yield t.peek(xs+7&-8);return e&&e.byteLength>=4?Su(e)?new Oi(new Iu(yield t.read())):new Ti(new Bs(t)):new Ti(new Bs((function(){return Tt(this,arguments,function*(){})})()))})}function Eb(t){return O(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new Wr(t,e);return e>=Oy&&Su(yield n.readAt(0,xs+7&-8))?new bu(new id(n)):new Ti(new Bs(n))})}var we=class t extends C{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Oe?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof te)return this.visitMany(e.data),this;let{type:n}=e;if(!E.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(E.isUnion(n))this.nodes.push(new Gt(r,0));else{let{nullCount:i}=e;E.isNull(n)||wn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Gt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function wn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new wt(this._byteLength,e)),this._byteLength+=e,this}function Fb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(wn.call(this,i),n.mode===de.Sparse)return od.call(this,t);if(n.mode===de.Dense){if(t.offset<=0)return wn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,d=-1;++d{let d=n.typeIds[c],y=a[d],v=l[d];return u.slice(y,Math.min(r,v))}))}}return this}function kb(t){let e;return t.nullCount>=t.length?wn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?wn.call(this,yi(t.offset,t.length,e)):wn.call(this,gi(t.values))}function vr(t){return wn.call(this,t.values.subarray(0,t.length*t.stride))}function Bu(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return wn.call(this,il(-i,e+1,r)),wn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return wn.call(this,il(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}we.prototype.visitBool=kb;we.prototype.visitInt=vr;we.prototype.visitFloat=vr;we.prototype.visitUtf8=Bu;we.prototype.visitLargeUtf8=Bu;we.prototype.visitBinary=Bu;we.prototype.visitLargeBinary=Bu;we.prototype.visitFixedSizeBinary=vr;we.prototype.visitDate=vr;we.prototype.visitTimestamp=vr;we.prototype.visitTime=vr;we.prototype.visitDecimal=vr;we.prototype.visitList=ad;we.prototype.visitStruct=od;we.prototype.visitUnion=Fb;we.prototype.visitInterval=vr;we.prototype.visitDuration=vr;we.prototype.visitFixedSizeList=ad;we.prototype.visitMap=ad;var Ei=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Cn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ct(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ot(e)?e.then(n=>this.writeAll(n)):Wt(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Cn?this._sink=e:(this._sink=new Cn,e&&Qp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Gp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof _t&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Oe&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Oe?e instanceof Ni||this._writeRecordBatch(e):e instanceof _t?this.writeAll(e.batches):sn(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=bt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===ee.RecordBatch?this._recordBatchBlocks.push(new cr(a,e.bodyLength,this._position)):e.headerType===ee.DictionaryBatch&&this._dictionaryBlocks.push(new cr(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=V(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(bt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(bs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=we.assemble(e),o=new Ze(e.numRows,r,i),a=bt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=we.assemble(new te([e])),l=new Ze(e.length,s,o),u=new St(l,n,r),c=bt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):Wt(e)?ud(r,e):ld(r,e)}},aa=class t extends Ei{static writeAll(e){let n=new t;return Ot(e)?e.then(r=>n.writeAll(r)):Wt(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=ur.encode(new ur(e,ae.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof _t&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return O(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=rn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function Ay(t,e){if(Wt(t))return Lb(t,e);if(sn(t))return Ab(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Ab(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return O(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return O(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return O(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return O(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=V(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Cy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Yp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:My;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:My}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},My=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Du(t,e){let n=new Cn,r=null,i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield n.close()})},start(a){return O(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return O(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return O(this,void 0,void 0,function*(){return yield(yield Ct.from(n)).open(e)})}function o(a,l){return O(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Nu(t,e){let n=new this(t),r=new Kt(n),i=new ReadableStream({cancel(){return O(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return O(this,void 0,void 0,function*(){yield s(o)})},start(o){return O(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return O(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function la(t){let e=Ct.from(t);return Ot(e)?e.then(n=>la(n)):e.isAsync()?e.readAll().then(n=>new _t(n)):new _t(e.readAll())}var Cb=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:cy,compareTypes:fy});Ge.toDOMStream=Ay;ge.throughDOM=Cy;Ct.throughDOM=Du;Oi.throughDOM=Du;gr.throughDOM=Du;Ei.throughDOM=Nu;aa.throughDOM=Nu;oa.throughDOM=Nu;var Ub=Object.create,Rb=Object.getPrototypeOf,Vd=Object.defineProperty,Pb=Object.getOwnPropertyNames,jb=Object.prototype.hasOwnProperty;function zb(t){return this[t]}var Vb,$b,he=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?Vb??=new WeakMap:$b??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Ub(Rb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of Pb(t))jb.call(o,a)||Vd(o,a,{get:zb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},so=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wb=t=>t;function Hb(t,e){this[t]=Wb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Hb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),bv={};Qh(bv,{Children:()=>Ev,Component:()=>Fv,Fragment:()=>kv,Profiler:()=>Av,PureComponent:()=>Lv,StrictMode:()=>Mv,Suspense:()=>Cv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Uv,act:()=>Rv,cloneElement:()=>Xb,createContext:()=>Zb,createElement:()=>Pv,createFactory:()=>Jb,createRef:()=>qb,forwardRef:()=>ex,isValidElement:()=>jv,lazy:()=>tx,memo:()=>nx,startTransition:()=>rx,unstable_act:()=>zv,useCallback:()=>ix,useContext:()=>sx,useDebugValue:()=>ox,useDeferredValue:()=>ax,useEffect:()=>lx,useId:()=>ux,useImperativeHandle:()=>cx,useInsertionEffect:()=>fx,useLayoutEffect:()=>dx,useMemo:()=>hx,useReducer:()=>px,useRef:()=>mx,useState:()=>yx,useSyncExternalStore:()=>gx,useTransition:()=>vx,version:()=>_x});function Yb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ds(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Uy(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function xv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{oo=Symbol.for("react.element"),Iv=Symbol.for("react.portal"),Py=Symbol.for("react.fragment"),jy=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),Bv=Symbol.for("react.provider"),Dv=Symbol.for("react.context"),Nv=Symbol.for("react.forward_ref"),Vy=Symbol.for("react.suspense"),Tv=Symbol.for("react.memo"),Ov=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ds.prototype.isReactComponent={},Ds.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ds.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Uy.prototype=Ds.prototype,Ou=fd.prototype=new Uy,Ou.constructor=fd,Hd(Ou,Ds.prototype),Ou.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,cc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ia={transition:null},$y={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ia,ReactCurrentOwner:cc},Ev={map:Tu,forEach:function(t,e,n){Tu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Tu(t,function(){e++}),e},toArray:function(t){return Tu(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Fv=Ds,kv=Py,Av=zy,Lv=fd,Mv=jy,Cv=Vy,Uv=$y,Rv=Ry,Pv=xv,jv=$d,zv=Ry}),$t=so(function(t,e){wx(),e.exports=bv}),Sx=so(function(t){function e(T,M){var B=T.length;T.push(M);e:for(;0>>1,X=T[b];if(0>>1;bi(uf,B))cii(Xa,uf)?(T[b]=Xa,T[ci]=B,b=ci):(T[b]=uf,T[Tn]=B,b=Tn);else if(cii(Xa,B))T[b]=Xa,T[ci]=B,b=ci;else break e}}return M}function i(T,M){var B=T.sortIndex-M.sortIndex;return B!==0?B:T.id-M.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,d=null,y=3,v=!1,w=!1,I=!1,Y=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(T){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=T)r(u),M.sortIndex=M.expirationTime,e(l,M);else break;M=n(u)}}function g(T){if(I=!1,m(T),!w)if(n(l)!==null)w=!0,Pe(_);else{var M=n(u);M!==null&&Fr(g,M.startTime-T)}}function _(T,M){w=!1,I&&(I=!1,h(S),S=-1),v=!0;var B=y;try{for(m(M),d=n(l);d!==null&&(!(d.expirationTime>M)||T&&!ue());){var b=d.callback;if(typeof b=="function"){d.callback=null,y=d.priorityLevel;var X=b(d.expirationTime<=M);M=t.unstable_now(),typeof X=="function"?d.callback=X:d===n(l)&&r(l),m(M)}else r(l);d=n(l)}if(d!==null)var Be=!0;else{var Tn=n(u);Tn!==null&&Fr(g,Tn.startTime-M),Be=!1}return Be}finally{d=null,y=B,v=!1}}var D=!1,N=null,S=-1,K=5,L=-1;function ue(){return!(t.unstable_now()-LT||125b?(T.sortIndex=B,e(u,T),n(l)===null&&T===n(u)&&(I?(h(S),S=-1):I=!0,Fr(g,B-b))):(T.sortIndex=X,e(l,T),w||v||(w=!0,Pe(_))),T},t.unstable_shouldYield=ue,t.unstable_wrapCallback=function(T){var M=y;return function(){var B=y;y=M;try{return T.apply(this,arguments)}finally{y=B}}}}),bx=so(function(t,e){var n=he(Sx());e.exports=n}),Vv={};Qh(Vv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>G_,createPortal:()=>I1,createRoot:()=>B1,findDOMNode:()=>D1,flushSync:()=>N1,hydrate:()=>T1,hydrateRoot:()=>O1,render:()=>E1,unmountComponentAtNode:()=>F1,unstable_batchedUpdates:()=>X_,unstable_renderSubtreeIntoContainer:()=>k1,version:()=>A1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Ix(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ht(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=Ye.hasOwnProperty(e)?Ye[e]:null;(i!==null?i.type!==0:r||!(2i));return new t(n,r.map(i=>new Oe(n,i)))}slice(e,n){let r=this.schema;[e,n]=No({length:this.numRows},e,n);let i=$l(this.data,this._offsets,e,n);return new t(r,i.map(s=>new Oe(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){let{type:r}=this.schema.fields[e],i=G({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new te(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(u));[s[e],a[e]]=[o,n],[r,i]=gu(r,a)}return new t(r,i)}select(e){let n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){let n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new t(n,r)}assign(e){let n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,u)=>{let[c,f]=a,y=n.findIndex(v=>v.name===l.name);return~y?f[y]=u:c.push(u),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new t(...gu(s,o))}};hy=Symbol.toStringTag;wt[hy]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=hs(Eo),t.get=hs(Ce.getVisitFn(p.Struct)),t.set=Wl(Xe.getVisitFn(p.Struct)),t.indexOf=Hl(vi.getVisitFn(p.Struct)),"Table"))(wt.prototype);var my,Oe=class t{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof ae))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=G({nullCount:0,type:new me(this.schema.fields),children:this.schema.fields.map(n=>G({type:n.type,nullCount:0}))})]=e,!(this.data instanceof se))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=py(this.schema,this.data.children);break}case 1:{let[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,c)=>(l.children[c]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[c]=q.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new ae(r),a=G({type:new me(r),length:s,children:i,nullCount:0});[this.schema,this.data]=py(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=yy(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Ce.visit(this.data,e)}at(e){return this.get(pi(e,this.numRows))}set(e,n){return Xe.visit(this.data,e,n)}indexOf(e,n){return vi.visit(this.data,e,n)}[Symbol.iterator](){return ps.visit(new te([this.data]))}toArray(){return[...this]}concat(...e){return new wt(this.schema,[this,...e])}slice(e,n){let[r]=new te([this.data]).slice(e,n).data;return new t(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new t(n,G({type:r,length:this.numRows,children:i}))}selectAt(e){let n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=G({type:new me(n.fields),length:this.numRows,children:r});return new t(n,i)}};my=Symbol.toStringTag;Oe[my]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Oe.prototype);function py(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;let i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(let[a,l]of t.fields.entries()){let u=e[a];(!u||u.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=u?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:G({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),G({type:new me(i),length:n,children:s})]}function yy(t,e,n=new Map){var r,i;if(((r=t?.length)!==null&&r!==void 0?r:0)>0&&t?.length===e?.length)for(let s=-1,o=t.length;++sG({type:i.type})),r=G({type:new me(e.fields),nullCount:0,children:n});super(e,r)}};var wn=class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):le.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):ee.NONE}header(e){let n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt("0")}customMetadata(e,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new je).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,le.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,ee.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,r),t.addHeader(e,i),t.addBodyLength(e,s),t.addCustomMetadata(e,o),t.endMessage(e)}};var Jf=class extends U{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return So.startNull(n),So.endNull(n)}visitInt(e,n){return un.startInt(n),un.addBitWidth(n,e.bitWidth),un.addIsSigned(n,e.isSigned),un.endInt(n)}visitFloat(e,n){return Ur.startFloatingPoint(n),Ur.addPrecision(n,e.precision),Ur.endFloatingPoint(n)}visitBinary(e,n){return yo.startBinary(n),yo.endBinary(n)}visitLargeBinary(e,n){return vo.startLargeBinary(n),vo.endLargeBinary(n)}visitBool(e,n){return go.startBool(n),go.endBool(n)}visitUtf8(e,n){return xo.startUtf8(n),xo.endUtf8(n)}visitLargeUtf8(e,n){return _o.startLargeUtf8(n),_o.endLargeUtf8(n)}visitDecimal(e,n){return An.startDecimal(n),An.addScale(n,e.scale),An.addPrecision(n,e.precision),An.addBitWidth(n,e.bitWidth),An.endDecimal(n)}visitDate(e,n){return Ar.startDate(n),Ar.addUnit(n,e.unit),Ar.endDate(n)}visitTime(e,n){return Qn.startTime(n),Qn.addUnit(n,e.unit),Qn.addBitWidth(n,e.bitWidth),Qn.endTime(n)}visitTimestamp(e,n){let r=e.timezone&&n.createString(e.timezone)||void 0;return Gn.startTimestamp(n),Gn.addUnit(n,e.unit),r!==void 0&&Gn.addTimezone(n,r),Gn.endTimestamp(n)}visitInterval(e,n){return Rr.startInterval(n),Rr.addUnit(n,e.unit),Rr.endInterval(n)}visitDuration(e,n){return Mr.startDuration(n),Mr.addUnit(n,e.unit),Mr.endDuration(n)}visitList(e,n){return wo.startList(n),wo.endList(n)}visitStruct(e,n){return bo.startStruct_(n),bo.endStruct_(n)}visitUnion(e,n){cn.startTypeIdsVector(n,e.typeIds.length);let r=cn.createTypeIdsVector(n,e.typeIds);return cn.startUnion(n),cn.addMode(n,e.mode),cn.addTypeIds(n,r),cn.endUnion(n)}visitDictionary(e,n){let r=this.visit(e.indices,n);return kn.startDictionaryEncoding(n),kn.addId(n,BigInt(e.id)),kn.addIsOrdered(n,e.isOrdered),r!==void 0&&kn.addIndexType(n,r),kn.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return Lr.startFixedSizeBinary(n),Lr.addByteWidth(n,e.byteWidth),Lr.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return Cr.startFixedSizeList(n),Cr.addListSize(n,e.listSize),Cr.endFixedSizeList(n)}visitMap(e,n){return Pr.startMap(n),Pr.addKeysSorted(n,e.keysSorted),Pr.endMap(n)}},vu=new Jf;function wy(t,e=new Map){return new ae(sb(t,e),_u(t.metadata),e)}function qf(t){return new Ze(t.count,by(t.columns),xy(t.columns))}function Sy(t){return new bt(qf(t.data),t.id,t.isDelta)}function sb(t,e){return(t.fields||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function gy(t,e){return(t.children||[]).filter(Boolean).map(n=>q.fromJSON(n,e))}function by(t){return(t||[]).reduce((e,n)=>[...e,new Xt(n.count,ob(n.VALIDITY)),...by(n.children)],[])}function xy(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function Iy(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=_y(t,gy(t,e)),i=new q(t.name,o,t.nullable,_u(t.metadata))):e.has(n=s.id)?(r=(r=s.indexType)?vy(r):new Mn,a=new Mt(e.get(n),r,n,s.isOrdered),i=new q(t.name,a,t.nullable,_u(t.metadata))):(r=(r=s.indexType)?vy(r):new Mn,e.set(n,o=_y(t,gy(t,e))),a=new Mt(o,r,n,s.isOrdered),i=new q(t.name,a,t.nullable,_u(t.metadata))),i||null}function _u(t=[]){return new Map(t.map(({key:e,value:n})=>[e,n]))}function vy(t){return new ze(t.isSigned,t.bitWidth)}function _y(t,e){let n=t.type.name;switch(n){case"NONE":return new dt;case"null":return new dt;case"binary":return new Xn;case"largebinary":return new Zn;case"utf8":return new Jn;case"largeutf8":return new qn;case"bool":return new er;case"list":return new pn((e||[])[0]);case"struct":return new me(e||[]);case"struct_":return new me(e||[])}switch(n){case"int":{let r=t.type;return new ze(r.isSigned,r.bitWidth)}case"floatingpoint":{let r=t.type;return new Kt(ce[r.precision])}case"decimal":{let r=t.type;return new tr(r.scale,r.precision,r.bitWidth)}case"date":{let r=t.type;return new nr(ke[r.unit])}case"time":{let r=t.type;return new rr(k[r.unit],r.bitWidth)}case"timestamp":{let r=t.type;return new ir(k[r.unit],r.timezone)}case"interval":{let r=t.type;return new sr(He[r.unit])}case"duration":{let r=t.type;return new or(k[r.unit])}case"union":{let r=t.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new mn(pe[o],r.typeIds||[],e||[])}case"fixedsizebinary":{let r=t.type;return new ar(r.byteWidth)}case"fixedsizelist":{let r=t.type;return new yn(r.listSize,(e||[])[0])}case"map":{let r=t.type;return new gn((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var ab=hi,lb=kt,xt=class t{static fromJSON(e,n){let r=new t(0,le.V5,n);return r._createHeader=ub(e,n),r}static decode(e){e=new lb($(e));let n=wn.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new t(r,i,s);return o._createHeader=cb(n,s),o}static encode(e){let n=new ab,r=-1;return e.isSchema()?r=ae.encode(n,e.header()):e.isRecordBatch()?r=Ze.encode(n,e.header()):e.isDictionaryBatch()&&(r=bt.encode(n,e.header())),wn.startMessage(n),wn.addVersion(n,le.V5),wn.addHeader(n,r),wn.addHeaderType(n,e.headerType),wn.addBodyLength(n,BigInt(e.bodyLength)),wn.finishMessageBuffer(n,wn.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof ae)return new t(0,le.V5,ee.Schema,e);if(e instanceof Ze)return new t(n,le.V5,ee.RecordBatch,e);if(e instanceof bt)return new t(n,le.V5,ee.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===ee.Schema}isRecordBatch(){return this.headerType===ee.RecordBatch}isDictionaryBatch(){return this.headerType===ee.DictionaryBatch}constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ne(e)}},Ze=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=ne(e)}},bt=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=ne(n)}},St=class{constructor(e,n){this.offset=ne(e),this.length=ne(n)}},Xt=class{constructor(e,n){this.length=ne(e),this.nullCount=ne(n)}};function ub(t,e){return(()=>{switch(e){case ee.Schema:return ae.fromJSON(t);case ee.RecordBatch:return Ze.fromJSON(t);case ee.DictionaryBatch:return bt.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}function cb(t,e){return(()=>{switch(e){case ee.Schema:return ae.decode(t.header(new vt),new Map,t.version());case ee.RecordBatch:return Ze.decode(t.header(new At),t.version());case ee.DictionaryBatch:return bt.decode(t.header(new Kn),t.version())}throw new Error(`Unrecognized Message type: { name: ${ee[e]}, type: ${e} }`)})}q.encode=Sb;q.decode=_b;q.fromJSON=Iy;ae.encode=wb;ae.decode=fb;ae.fromJSON=wy;Ze.encode=bb;Ze.decode=db;Ze.fromJSON=qf;bt.encode=xb;bt.decode=hb;bt.fromJSON=Sy;Xt.encode=Ib;Xt.decode=mb;St.encode=Bb;St.decode=pb;function fb(t,e=new Map,n=le.V5){let r=vb(t,e);return new ae(r,wu(t),e,n)}function db(t,e=le.V5){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new Ze(t.length(),yb(t),gb(t,e))}function hb(t,e=le.V5){return new bt(Ze.decode(t.data(),e),t.id(),t.isDelta())}function pb(t){return new St(t.offset(),t.length())}function mb(t){return new Xt(t.length(),t.nullCount())}function yb(t){let e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++rq.encode(t,s));vt.startFieldsVector(t,n.length);let r=vt.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?vt.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{let a=t.createString(`${s}`),l=t.createString(`${o}`);return je.startKeyValue(t),je.addKey(t,a),je.addValue(t,l),je.endKeyValue(t)})):-1;return vt.startSchema(t),vt.addFields(t,r),vt.addEndianness(t,Db?kr.Little:kr.Big),i!==-1&&vt.addCustomMetadata(t,i),vt.endSchema(t)}function Sb(t,e){let n=-1,r=-1,i=-1,s=e.type,o=e.typeId;O.isDictionary(s)?(o=s.dictionary.typeId,i=vu.visit(s,t),r=vu.visit(s.dictionary,t)):r=vu.visit(s,t);let a=(s.children||[]).map(c=>q.encode(t,c)),l=nt.createChildrenVector(t,a),u=e.metadata&&e.metadata.size>0?nt.createCustomMetadataVector(t,[...e.metadata].map(([c,f])=>{let y=t.createString(`${c}`),v=t.createString(`${f}`);return je.startKeyValue(t),je.addKey(t,y),je.addValue(t,v),je.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),nt.startField(t),nt.addType(t,r),nt.addTypeType(t,o),nt.addChildren(t,l),nt.addNullable(t,!!e.nullable),n!==-1&&nt.addName(t,n),i!==-1&&nt.addDictionary(t,i),u!==-1&&nt.addCustomMetadata(t,u),nt.endField(t)}function bb(t,e){let n=e.nodes||[],r=e.buffers||[];At.startNodesVector(t,n.length);for(let o of n.slice().reverse())Xt.encode(t,o);let i=t.endVector();At.startBuffersVector(t,r.length);for(let o of r.slice().reverse())St.encode(t,o);let s=t.endVector();return At.startRecordBatch(t),At.addLength(t,BigInt(e.length)),At.addNodes(t,i),At.addBuffers(t,s),At.endRecordBatch(t)}function xb(t,e){let n=Ze.encode(t,e.data);return Kn.startDictionaryBatch(t),Kn.addId(t,BigInt(e.id)),Kn.addIsDelta(t,e.isDelta),Kn.addData(t,n),Kn.endDictionaryBatch(t)}function Ib(t,e){return is.createFieldNode(t,BigInt(e.length),BigInt(e.nullCount))}function Bb(t,e){return rs.createBuffer(t,BigInt(e.offset),BigInt(e.length))}var Db=(()=>{let t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})();var td=t=>`Expected ${ee[t]} Message in stream, but was null or length 0.`,nd=t=>`Header pointer of flatbuffer-encoded ${ee[t]} Message is null or length 0.`,Ty=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,Oy=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`,bs=class{constructor(e){this.source=e instanceof Un?e:new Un(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done?ye:e.value===-1&&(e=this.readMetadataLength()).done?ye:(e=this.readMetadata(e.value)).done?ye:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);let n=$(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(td(e));return n.value}readSchema(){let e=ee.Schema,n=this.readMessage(e),r=n?.header();if(!n||!r)throw new Error(nd(e));return r}},Su=4,ed="ARROW1",xs=new Uint8Array(ed.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ge.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ge.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof t?e:Ja(e)?Tb(e):el(e)?Fb(e):Et(e)?T(this,void 0,void 0,function*(){return yield t.from(yield e)}):tl(e)||uo(e)||rl(e)||Ht(e)?Eb(new Qt(e)):Ob(new Un(e))}static readAll(e){return e instanceof t?e.isSync()?Fy(e):ky(e):Ja(e)||ArrayBuffer.isView(e)||on(e)||qa(e)?Fy(e):ky(e)}},vr=class extends Ut{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ot(this,arguments,function*(){yield Z(yield*ts(sn(this[Symbol.iterator]())))})}},Ti=class extends Ut{constructor(e){super(e),this._impl=e}readAll(){return T(this,void 0,void 0,function*(){var e,n,r,i;let s=new Array;try{for(var o=!0,a=sn(this),l;l=yield a.next(),e=l.done,!e;o=!0){i=l.value,o=!1;let u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!o&&!e&&(r=a.return)&&(yield r.call(a))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Oi=class extends vr{constructor(e){super(e),this._impl=e}},xu=class extends Ti{constructor(e){super(e),this._impl=e}},Iu=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){let r=this._loadVectors(e,n,this.schema.fields),i=G({type:new me(this.schema.fields),length:e.length,children:r});return new Oe(this.schema,i)}_loadDictionaryBatch(e,n){let{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r),l=o.dictionaries.get(r),u=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new te(u)):new te(u)).memoize()}_loadVectors(e,n,r){return new Lo(n,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}},Bs=class extends Iu{constructor(e,n){super(n),this._reader=Ja(e)?new oa(this._handle=e):new bs(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=Ay(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):ye}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):ye}next(){if(this.closed)return ye;let e,{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Ds=class extends Iu{constructor(e,n){super(n),this._reader=new sa(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return T(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return T(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ay(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return T(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):ye})}return(e){return T(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):ye})}next(){return T(this,void 0,void 0,function*(){if(this.closed)return ye;let e,{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Ni(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return T(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},Bu=class extends Bs{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,n){super(e instanceof ko?e:new ko(e),n)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){let i=this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:e}=this,n=e.size-rd,r=e.readInt32(n),i=e.readAt(n-r,r);return cr.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return T(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return T(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());let r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){return T(this,void 0,void 0,function*(){var n;let r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){let i=yield this._reader.readMessage(ee.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return T(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let n=e.size-rd,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return cr.decode(i)})}_readNextMessageAndValidate(e){return T(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?bu(e)?new Oi(new Bu(t.read())):new vr(new Bs(t)):new vr(new Bs((function*(){})()))}function Eb(t){return T(this,void 0,void 0,function*(){let e=yield t.peek(Is+7&-8);return e&&e.byteLength>=4?bu(e)?new Oi(new Bu(yield t.read())):new Ti(new Ds(t)):new Ti(new Ds((function(){return Ot(this,arguments,function*(){})})()))})}function Fb(t){return T(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new Wr(t,e);return e>=Ey&&bu(yield n.readAt(0,Is+7&-8))?new xu(new id(n)):new Ti(new Ds(n))})}var be=class t extends U{static assemble(...e){let n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Oe?s.data.children:s.data),r=new t;return r.visitMany(n(e)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof te)return this.visitMany(e.data),this;let{type:n}=e;if(!O.isDictionary(n)){let{length:r}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(O.isUnion(n))this.nodes.push(new Xt(r,0));else{let{nullCount:i}=e;O.isNull(n)||Sn.call(this,i<=0?new Uint8Array(0):yi(e.offset,r,e.nullBitmap)),this.nodes.push(new Xt(r,i))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Sn(t){let e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new St(this._byteLength,e)),this._byteLength+=e,this}function kb(t){var e;let{type:n,length:r,typeIds:i,valueOffsets:s}=t;if(Sn.call(this,i),n.mode===pe.Sparse)return od.call(this,t);if(n.mode===pe.Dense){if(t.offset<=0)return Sn.call(this,s),od.call(this,t);{let o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let u,c,f=-1;++f{let f=n.typeIds[c],y=a[f],v=l[f];return u.slice(y,Math.min(r,v))}))}}return this}function Ab(t){let e;return t.nullCount>=t.length?Sn.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Sn.call(this,yi(t.offset,t.length,e)):Sn.call(this,gi(t.values))}function _r(t){return Sn.call(this,t.values.subarray(0,t.length*t.stride))}function Du(t){let{length:e,values:n,valueOffsets:r}=t,i=ne(r[0]),s=ne(r[e]),o=Math.min(s-i,n.byteLength-i);return Sn.call(this,sl(-i,e+1,r)),Sn.call(this,n.subarray(i,i+o)),this}function ad(t){let{length:e,valueOffsets:n}=t;if(n){let{[0]:r,[e]:i}=n;return Sn.call(this,sl(-r,e+1,n)),this.visit(t.children[0].slice(r,i-r))}return this.visit(t.children[0])}function od(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}be.prototype.visitBool=Ab;be.prototype.visitInt=_r;be.prototype.visitFloat=_r;be.prototype.visitUtf8=Du;be.prototype.visitLargeUtf8=Du;be.prototype.visitBinary=Du;be.prototype.visitLargeBinary=Du;be.prototype.visitFixedSizeBinary=_r;be.prototype.visitDate=_r;be.prototype.visitTimestamp=_r;be.prototype.visitTime=_r;be.prototype.visitDecimal=_r;be.prototype.visitList=ad;be.prototype.visitStruct=od;be.prototype.visitUnion=kb;be.prototype.visitInterval=_r;be.prototype.visitDuration=_r;be.prototype.visitFixedSizeList=ad;be.prototype.visitMap=ad;var Ei=class extends wi{static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Cn,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ft(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Et(e)?e.then(n=>this.writeAll(n)):Ht(e)?ud(this,e):ld(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Cn?this._sink=e:(this._sink=new Cn,e&&Gp(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&Xp(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Di(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof wt&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof Oe&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Di(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof Oe?e instanceof Ni||this._writeRecordBatch(e):e instanceof wt?this.writeAll(e.batches):on(e)&&this.writeAll(e)}_writeMessage(e,n=8){let r=n-1,i=xt.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===ee.RecordBatch?this._recordBatchBlocks.push(new fr(a,e.bodyLength,this._position)):e.headerType===ee.DictionaryBatch&&this._dictionaryBlocks.push(new fr(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){let n=$(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(xt.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(xs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=be.assemble(e),o=new Ze(e.numRows,r,i),a=xt.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=be.assemble(new te([e])),l=new Ze(e.length,s,o),u=new bt(l,n,r),c=xt.from(u,i);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){var n,r;for(let[i,s]of e.dictionaries){let o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(let[u,c]of o.entries())this._writeDictionaryBatch(c,i,u>0);else if(lr.writeAll(i)):Ht(e)?ud(r,e):ld(r,e)}},la=class t extends Ei{static writeAll(e){let n=new t;return Et(e)?e.then(r=>n.writeAll(r)):Ht(e)?ud(n,e):ld(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(e,n,r)}_writeFooter(e){let n=cr.encode(new cr(e,le.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}};function ld(t,e){let n=e;e instanceof wt&&(n=e.batches,t.reset(void 0,e.schema));for(let r of n)t.write(r);return t.finish()}function ud(t,e){return T(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=sn(e);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;let u=l;t.write(u)}}catch(u){o={error:u}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return t.finish()})}function My(t,e){if(Ht(t))return Lb(t,e);if(on(t))return Mb(t,e);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Mb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){s(o,n||(n=t[Symbol.iterator]()))},pull(o){n?s(o,n):o.close()},cancel(){(n?.return&&n.return()||!0)&&(n=null)}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){let l,u=null,c=o.desiredSize||null;for(;!(u=a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=$(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()}}function Lb(t,e){let n=null,r=e?.type==="bytes"||!1,i=e?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},e),{start(o){return T(this,void 0,void 0,function*(){yield s(o,n||(n=t[Symbol.asyncIterator]()))})},pull(o){return T(this,void 0,void 0,function*(){n?yield s(o,n):o.close()})},cancel(){return T(this,void 0,void 0,function*(){(n?.return&&(yield n.return())||!0)&&(n=null)})}}),Object.assign({highWaterMark:r?i:void 0},e));function s(o,a){return T(this,void 0,void 0,function*(){let l,u=null,c=o.desiredSize||null;for(;!(u=yield a.next(r?c:null)).done;)if(ArrayBuffer.isView(u.value)&&(l=$(u.value))&&(c!=null&&r&&(c=c-l.byteLength+1),u.value=l),o.enqueue(u.value),c!=null&&--c<=0)return;o.close()})}}function Uy(t){return new cd(t)}var cd=class{constructor(e){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:n,["writableStrategy"]:r,["queueingStrategy"]:i="count"}=e,s=Kp(e,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=bi(s),this._getSize=i!=="bytes"?Ly:Cy;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},r);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ly:Cy}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:l=>this._writeValueAndReturnChunkSize(l)})}_writeValueAndReturnChunkSize(e){let n=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(e)),this._bufferedSize-n}_maybeFlush(e,n){n!=null&&(this._bufferedSize>=n.desiredSize&&++this._numChunks&&this._enqueue(n,e.toVector()),e.finished&&((e.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(n,e.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(n,null)))}_enqueue(e,n){this._bufferedSize=0,this._controller=null,n==null?e.close():e.enqueue(n)}},Ly=t=>{var e;return(e=t?.length)!==null&&e!==void 0?e:0},Cy=t=>{var e;return(e=t?.byteLength)!==null&&e!==void 0?e:0};function Nu(t,e){let n=new Cn,r=null,i=new ReadableStream({cancel(){return T(this,void 0,void 0,function*(){yield n.close()})},start(a){return T(this,void 0,void 0,function*(){yield o(a,r||(r=yield s()))})},pull(a){return T(this,void 0,void 0,function*(){r?yield o(a,r):a.close()})}});return{writable:new WritableStream(n,Object.assign({highWaterMark:Math.pow(2,14)},t)),readable:i};function s(){return T(this,void 0,void 0,function*(){return yield(yield Ut.from(n)).open(e)})}function o(a,l){return T(this,void 0,void 0,function*(){let u=a.desiredSize,c=null;for(;!(c=yield l.next()).done;)if(a.enqueue(c.value),u!=null&&--u<=0)return;a.close()})}}function Tu(t,e){let n=new this(t),r=new Qt(n),i=new ReadableStream({cancel(){return T(this,void 0,void 0,function*(){yield r.cancel()})},pull(o){return T(this,void 0,void 0,function*(){yield s(o)})},start(o){return T(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},e));return{writable:new WritableStream(n,t),readable:i};function s(o){return T(this,void 0,void 0,function*(){let a=null,l=o.desiredSize;for(;a=yield r.read(l||null);)if(o.enqueue(a),l!=null&&(l-=a.byteLength)<=0)return;o.close()})}}function ua(t){let e=Ut.from(t);return Et(e)?e.then(n=>ua(n)):e.isAsync()?e.readAll().then(n=>new wt(n)):new wt(e.readAll())}var Ub=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},bf),Kf),Rf),xf),mf),Uf),vf),{compareSchemas:Di,compareFields:fy,compareTypes:dy});Ge.toDOMStream=My;ve.throughDOM=Uy;Ut.throughDOM=Nu;Oi.throughDOM=Nu;vr.throughDOM=Nu;Ei.throughDOM=Tu;la.throughDOM=Tu;aa.throughDOM=Tu;var Rb=Object.create,Pb=Object.getPrototypeOf,Vd=Object.defineProperty,jb=Object.getOwnPropertyNames,zb=Object.prototype.hasOwnProperty;function Vb(t){return this[t]}var $b,Wb,de=(t,e,n)=>{var r=t!=null&&typeof t=="object";if(r){var i=e?$b??=new WeakMap:Wb??=new WeakMap,s=i.get(t);if(s)return s}n=t!=null?Rb(Pb(t)):{};let o=e||!t||!t.__esModule?Vd(n,"default",{value:t,enumerable:!0}):n;if(t&&typeof t=="object"||typeof t=="function")for(let a of jb(t))zb.call(o,a)||Vd(o,a,{get:Vb.bind(t,a),enumerable:!0});return r&&i.set(t,o),o},oo=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Hb=t=>t;function Yb(t,e){this[t]=Hb.bind(null,e)}var Qh=(t,e)=>{for(var n in e)Vd(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Yb.bind(e,n)})},Gh=(t,e)=>()=>(t&&(e=t(t=0)),e),Iv={};Qh(Iv,{Children:()=>kv,Component:()=>Av,Fragment:()=>Mv,Profiler:()=>Lv,PureComponent:()=>Cv,StrictMode:()=>Uv,Suspense:()=>Rv,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Pv,act:()=>jv,cloneElement:()=>Zb,createContext:()=>Jb,createElement:()=>zv,createFactory:()=>qb,createRef:()=>ex,forwardRef:()=>tx,isValidElement:()=>Vv,lazy:()=>nx,memo:()=>rx,startTransition:()=>ix,unstable_act:()=>$v,useCallback:()=>sx,useContext:()=>ox,useDebugValue:()=>ax,useDeferredValue:()=>lx,useEffect:()=>ux,useId:()=>cx,useImperativeHandle:()=>fx,useInsertionEffect:()=>dx,useLayoutEffect:()=>hx,useMemo:()=>px,useReducer:()=>mx,useRef:()=>yx,useState:()=>gx,useSyncExternalStore:()=>vx,useTransition:()=>_x,version:()=>wx});function Kb(t){return t===null||typeof t!="object"?null:(t=Wd&&t[Wd]||t["@@iterator"],typeof t=="function"?t:null)}function Ns(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Ry(){}function fd(t,e,n){this.props=t,this.context=e,this.refs=Zh,this.updater=n||Xh}function Bv(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)Jh.call(e,r)&&!qh.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{ao=Symbol.for("react.element"),Dv=Symbol.for("react.portal"),jy=Symbol.for("react.fragment"),zy=Symbol.for("react.strict_mode"),Vy=Symbol.for("react.profiler"),Nv=Symbol.for("react.provider"),Tv=Symbol.for("react.context"),Ov=Symbol.for("react.forward_ref"),$y=Symbol.for("react.suspense"),Ev=Symbol.for("react.memo"),Fv=Symbol.for("react.lazy"),Wd=Symbol.iterator,Xh={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hd=Object.assign,Zh={},Ns.prototype.isReactComponent={},Ns.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")},Ns.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},Ry.prototype=Ns.prototype,Eu=fd.prototype=new Ry,Eu.constructor=fd,Hd(Eu,Ns.prototype),Eu.isPureReactComponent=!0,Yd=Array.isArray,Jh=Object.prototype.hasOwnProperty,fc={current:null},qh={key:!0,ref:!0,__self:!0,__source:!0},Kd=/\/+/g,ut={current:null},Ba={transition:null},Wy={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Ba,ReactCurrentOwner:fc},kv={map:Ou,forEach:function(t,e,n){Ou(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Ou(t,function(){e++}),e},toArray:function(t){return Ou(t,function(e){return e})||[]},only:function(t){if(!$d(t))throw Error("React.Children.only expected to receive a single React element child.");return t}},Av=Ns,Mv=jy,Lv=Vy,Cv=fd,Uv=zy,Rv=$y,Pv=Wy,jv=Py,zv=Bv,Vv=$d,$v=Py}),Wt=oo(function(t,e){Sx(),e.exports=Iv}),bx=oo(function(t){function e(N,C){var I=N.length;N.push(C);e:for(;0>>1,F=N[M];if(0>>1;Mi(es,I))cii(Za,es)?(N[M]=Za,N[ci]=I,M=ci):(N[M]=es,N[ct]=I,M=ct);else if(cii(Za,I))N[M]=Za,N[ci]=I,M=ci;else break e}}return C}function i(N,C){var I=N.sortIndex-C.sortIndex;return I!==0?I:N.id-C.id}typeof performance=="object"&&typeof performance.now=="function"?(s=performance,t.unstable_now=function(){return s.now()}):(o=Date,a=o.now(),t.unstable_now=function(){return o.now()-a});var s,o,a,l=[],u=[],c=1,f=null,y=3,v=!1,_=!1,b=!1,K=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(N){for(var C=n(u);C!==null;){if(C.callback===null)r(u);else if(C.startTime<=N)r(u),C.sortIndex=C.expirationTime,e(l,C);else break;C=n(u)}}function g(N){if(b=!1,m(N),!_)if(n(l)!==null)_=!0,Le(w);else{var C=n(u);C!==null&&Yn(g,C.startTime-N)}}function w(N,C){_=!1,b&&(b=!1,h(S),S=-1),v=!0;var I=y;try{for(m(C),f=n(l);f!==null&&(!(f.expirationTime>C)||N&&!he());){var M=f.callback;if(typeof M=="function"){f.callback=null,y=f.priorityLevel;var F=M(f.expirationTime<=C);C=t.unstable_now(),typeof F=="function"?f.callback=F:f===n(l)&&r(l),m(C)}else r(l);f=n(l)}if(f!==null)var ie=!0;else{var ct=n(u);ct!==null&&Yn(g,ct.startTime-C),ie=!1}return ie}finally{f=null,y=I,v=!1}}var D=!1,B=null,S=-1,Q=5,L=-1;function he(){return!(t.unstable_now()-LN||125M?(N.sortIndex=I,e(u,N),n(l)===null&&N===n(u)&&(b?(h(S),S=-1):b=!0,Yn(g,I-M))):(N.sortIndex=F,e(l,N),_||v||(_=!0,Le(w))),N},t.unstable_shouldYield=he,t.unstable_wrapCallback=function(N){var C=y;return function(){var I=y;y=C;try{return N.apply(this,arguments)}finally{y=I}}}}),xx=oo(function(t,e){var n=de(bx());e.exports=n}),Wv={};Qh(Wv,{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Z_,createPortal:()=>B1,createRoot:()=>D1,findDOMNode:()=>N1,flushSync:()=>T1,hydrate:()=>O1,hydrateRoot:()=>E1,render:()=>F1,unmountComponentAtNode:()=>k1,unstable_batchedUpdates:()=>J_,unstable_renderSubtreeIntoContainer:()=>A1,version:()=>M1});function x(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||Bx(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function pt(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}function hd(t){return t[1].toUpperCase()}function ep(t,e,n,r){var i=Ye.hasOwnProperty(e)?Ye[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ed=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?va(t):""}function Dx(t){switch(t.tag){case 5:return va(t.type);case 16:return va("Lazy");case 13:return va("Suspense");case 19:return va("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Ic:return"Profiler";case Jc:return"StrictMode";case Bc:return"Suspense";case Dc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case qc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ef:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case Sr:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Nx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===Jc?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ai(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function $v(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Tx(t){var e=$v(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Eu(t){t._valueTracker||(t._valueTracker=Tx(t))}function Wv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=$v(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function fc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return Se({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Wy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ai(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Hv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Hv(t,e);var n=ai(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,ai(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Hy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||fc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function $s(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(c_(t)/f_|0)|0}function _a(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function dc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=_a(a):(s&=o,s!==0&&(r=_a(s)))}else o=n&~i,o!==0?r=_a(o):s!==0&&(r=_a(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Qa(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-tn(e),t[e]=n}function Ux(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tg(n)}}function h0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?h0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function p0(){for(var t=window,e=fc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=fc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Jx(t){var e=p0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&h0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=ng(n,s);var o=ng(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;nPs||(t.current=Lc[Ps],Lc[Ps]=null,Ps--)}function ye(t,e){Ps++,Lc[Ps]=t.current,t.current=e}function Gs(t,e){var n=t.type.contextTypes;if(!n)return Tr;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Dt(t){return t=t.childContextTypes,t!=null}function yc(){_e(yt),_e(tt)}function lg(t,e,n){if(tt.current!==Tr)throw Error(x(168));ye(tt,e),ye(yt,n)}function g0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Nx(t)||"Unknown",i));return Se({},n,r)}function gc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Tr,li=tt.current,ye(tt,t),ye(yt,yt.current),!0}function ug(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=g0(t,e,li),r.__reactInternalMemoizedMergedChildContext=t,_e(yt),_e(tt),ye(tt,t)):_e(yt),ye(yt,n)}function v0(t){br===null?br=[t]:br.push(t)}function e1(t){sf=!0,v0(t)}function ui(){if(!Rd&&br!==null){Rd=!0;var t=0,e=le;try{var n=br;for(le=1;t>=o,i-=o,Br=1<<32-tn(e)+i|n<S?(K=N,N=null):K=N.sibling;var L=y(h,N,m[S],g);if(L===null){N===null&&(N=K);break}t&&N&&L.alternate===null&&e(h,N),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L,N=K}if(S===m.length)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;SS?(K=N,N=null):K=N.sibling;var ue=y(h,N,L.value,g);if(ue===null){N===null&&(N=K);break}t&&N&&ue.alternate===null&&e(h,N),f=s(ue,f,S),D===null?_=ue:D.sibling=ue,D=ue,N=K}if(L.done)return n(h,N),xe&&Li(h,S),_;if(N===null){for(;!L.done;S++,L=m.next())L=d(h,L.value,g),L!==null&&(f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return xe&&Li(h,S),_}for(N=r(h,N);!L.done;S++,L=m.next())L=v(N,h,S,L.value,g),L!==null&&(t&&L.alternate!==null&&N.delete(L.key===null?S:L.key),f=s(L,f,S),D===null?_=L:D.sibling=L,D=L);return t&&N.forEach(function(Te){return e(h,Te)}),xe&&Li(h,S),_}function Y(h,f,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Sa:e:{for(var _=m.key,D=f;D!==null;){if(D.key===_){if(_=m.type,_===ji){if(D.tag===7){n(h,D.sibling),f=i(D,m.props.children),f.return=h,h=f;break e}}else if(D.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Sr&&dg(_)===D.type){n(h,D.sibling),f=i(D,m.props),f.ref=da(h,D,m),f.return=h,h=f;break e}n(h,D);break}else e(h,D);D=D.sibling}m.type===ji?(f=Yi(m.props.children,h.mode,g,m.key),f.return=h,h=f):(g=tc(m.type,m.key,m.props,null,h.mode,g),g.ref=da(h,f,m),g.return=h,h=g)}return o(h);case Pi:e:{for(D=m.key;f!==null;){if(f.key===D)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){n(h,f.sibling),f=i(f,m.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else e(h,f);f=f.sibling}f=Nd(m,h.mode,g),f.return=h,h=f}return o(h);case Sr:return D=m._init,Y(h,f,D(m._payload),g)}if(Ls(m))return w(h,f,m,g);if(ua(m))return I(h,f,m,g);Cu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,f!==null&&f.tag===6?(n(h,f.sibling),f=i(f,m),f.return=h,h=f):(n(h,f),f=Dd(m,h.mode,g),f.return=h,h=f),o(h)):n(h,f)}return Y}function lp(){Cp=zs=Uc=null}function up(t){var e=Va.current;_e(Va),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Ws(t,e){Uc=t,Cp=zs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Bt=!0),t.firstContext=null)}function Xt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},zs===null){if(Uc===null)throw Error(x(308));zs=t,Uc.dependencies={lanes:0,firstContext:t}}else zs=zs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function b0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Nr(t,r)}function Nr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function x0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ir(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ti(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Nr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Nr(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function pg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=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};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function vc(t,e,n,r){var i=t.updateQueue;Qr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=t,I=a;switch(y=e,v=n,I.tag){case 1:if(w=I.payload,typeof w=="function"){d=w.call(v,d,y);break e}d=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=I.payload,y=typeof w=="function"?w.call(v,d,y):w,y==null)break e;d=Se({},d,y);break e;case 2:Qr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=d):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=d}}function mg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=ac.transition;ac.transition={};try{t(!1),e()}finally{le=n,ac.transition=r}}function Ng(){return qt().memoizedState}function n1(t,e,n){var r=Zr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},F0(t))k0(e,n);else if(n=b0(t,e,n,r),n!==null){var i=mt();In(n,t,r,i),A0(n,e,r)}}function r1(t,e,n){var r=Zr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(F0(t))k0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,nn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=b0(t,e,i,r),n!==null&&(i=mt(),In(n,t,r,i),A0(n,e,r))}}function F0(t){var e=t.alternate;return t===Ne||e!==null&&e===Ne}function k0(t,e){Ea=Rc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function A0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function bn(t,e){if(t&&t.defaultProps){e=Se({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:Se({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Tg(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ca(n,r)||!Ca(i,s):!0}function L0(t,e,n){var r=!1,i=Tr,s=e.contextType;return typeof s=="object"&&s!==null?s=Xt(s):(i=Dt(e)?li:tt.current,r=e.contextTypes,s=(r=r!=null)?Gs(t,i):Tr),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ha,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Og(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ha.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Xt(s):(s=Dt(e)?li:tt.current,i.context=Gs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ha.enqueueReplaceState(i,i.state,null),vc(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function Js(t,e){try{var n="",r=e;do n+=Dx(r),r=r.return;while(r);var i=n}catch(s){i=` +`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{Ed=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?_a(t):""}function Nx(t){switch(t.tag){case 5:return _a(t.type);case 16:return _a("Lazy");case 13:return _a("Suspense");case 19:return _a("SuspenseList");case 0:case 2:case 15:return t=pd(t.type,!1),t;case 11:return t=pd(t.type.render,!1),t;case 1:return t=pd(t.type,!0),t;default:return""}}function Qd(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ji:return"Fragment";case Pi:return"Portal";case Bc:return"Profiler";case qc:return"StrictMode";case Dc:return"Suspense";case Nc:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Dp:return(t.displayName||"Context")+".Consumer";case Bp:return(t._context.displayName||"Context")+".Provider";case ef:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case tf:return e=t.displayName||null,e!==null?e:Qd(t.type)||"Memo";case br:e=t._payload,t=t._init;try{return Qd(t(e))}catch{}}return null}function Tx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qd(e);case 8:return e===qc?"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 e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function ai(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Hv(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Ox(t){var e=Hv(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var{get:i,set:s}=n;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Fu(t){t._valueTracker||(t._valueTracker=Ox(t))}function Yv(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=Hv(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function dc(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gd(t,e){var n=e.checked;return xe({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Hy(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ai(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Kv(t,e){e=e.checked,e!=null&&ep(t,"checked",e,!1)}function Xd(t,e){Kv(t,e);var n=ai(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zd(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zd(t,e.type,ai(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Yy(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zd(t,e,n){(e!=="number"||dc(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}function Ws(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i>>=0,t===0?32:31-(d_(t)/h_|0)|0}function wa(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function hc(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=wa(a):(s&=o,s!==0&&(r=wa(s)))}else o=n&~i,o!==0?r=wa(o):s!==0&&(r=wa(s));if(r===0)return 0;if(e!==0&&e!==r&&(e&i)===0&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if((r&4)!==0&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Ga(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-nn(e),t[e]=n}function Rx(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ng(n)}}function m0(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?m0(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function y0(){for(var t=window,e=dc();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=dc(t.document)}return e}function ip(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function qx(t){var e=y0(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&m0(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=rg(n,s);var o=rg(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;njs||(t.current=Lc[js],Lc[js]=null,js--)}function ge(t,e){js++,Lc[js]=t.current,t.current=e}function Xs(t,e){var n=t.type.contextTypes;if(!n)return Or;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Nt(t){return t=t.childContextTypes,t!=null}function gc(){we(gt),we(tt)}function ug(t,e,n){if(tt.current!==Or)throw Error(x(168));ge(tt,e),ge(gt,n)}function _0(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,Tx(t)||"Unknown",i));return xe({},n,r)}function vc(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Or,li=tt.current,ge(tt,t),ge(gt,gt.current),!0}function cg(t,e,n){var r=t.stateNode;if(!r)throw Error(x(169));n?(t=_0(t,e,li),r.__reactInternalMemoizedMergedChildContext=t,we(gt),we(tt),ge(tt,t)):we(gt),ge(gt,n)}function w0(t){xr===null?xr=[t]:xr.push(t)}function t1(t){of=!0,w0(t)}function ui(){if(!Rd&&xr!==null){Rd=!0;var t=0,e=ue;try{var n=xr;for(ue=1;t>=o,i-=o,Dr=1<<32-nn(e)+i|n<S?(Q=B,B=null):Q=B.sibling;var L=y(h,B,m[S],g);if(L===null){B===null&&(B=Q);break}t&&B&&L.alternate===null&&e(h,B),d=s(L,d,S),D===null?w=L:D.sibling=L,D=L,B=Q}if(S===m.length)return n(h,B),Be&&Mi(h,S),w;if(B===null){for(;SS?(Q=B,B=null):Q=B.sibling;var he=y(h,B,L.value,g);if(he===null){B===null&&(B=Q);break}t&&B&&he.alternate===null&&e(h,B),d=s(he,d,S),D===null?w=he:D.sibling=he,D=he,B=Q}if(L.done)return n(h,B),Be&&Mi(h,S),w;if(B===null){for(;!L.done;S++,L=m.next())L=f(h,L.value,g),L!==null&&(d=s(L,d,S),D===null?w=L:D.sibling=L,D=L);return Be&&Mi(h,S),w}for(B=r(h,B);!L.done;S++,L=m.next())L=v(B,h,S,L.value,g),L!==null&&(t&&L.alternate!==null&&B.delete(L.key===null?S:L.key),d=s(L,d,S),D===null?w=L:D.sibling=L,D=L);return t&&B.forEach(function(We){return e(h,We)}),Be&&Mi(h,S),w}function K(h,d,m,g){if(typeof m=="object"&&m!==null&&m.type===ji&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case ba:e:{for(var w=m.key,D=d;D!==null;){if(D.key===w){if(w=m.type,w===ji){if(D.tag===7){n(h,D.sibling),d=i(D,m.props.children),d.return=h,h=d;break e}}else if(D.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===br&&hg(w)===D.type){n(h,D.sibling),d=i(D,m.props),d.ref=ha(h,D,m),d.return=h,h=d;break e}n(h,D);break}else e(h,D);D=D.sibling}m.type===ji?(d=Yi(m.props.children,h.mode,g,m.key),d.return=h,h=d):(g=nc(m.type,m.key,m.props,null,h.mode,g),g.ref=ha(h,d,m),g.return=h,h=g)}return o(h);case Pi:e:{for(D=m.key;d!==null;){if(d.key===D)if(d.tag===4&&d.stateNode.containerInfo===m.containerInfo&&d.stateNode.implementation===m.implementation){n(h,d.sibling),d=i(d,m.children||[]),d.return=h,h=d;break e}else{n(h,d);break}else e(h,d);d=d.sibling}d=Nd(m,h.mode,g),d.return=h,h=d}return o(h);case br:return D=m._init,K(h,d,D(m._payload),g)}if(Ls(m))return _(h,d,m,g);if(ca(m))return b(h,d,m,g);Uu(h,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,d!==null&&d.tag===6?(n(h,d.sibling),d=i(d,m),d.return=h,h=d):(n(h,d),d=Dd(m,h.mode,g),d.return=h,h=d),o(h)):n(h,d)}return K}function lp(){Cp=Vs=Rc=null}function up(t){var e=$a.current;we($a),t._currentValue=e}function ah(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function Hs(t,e){Rc=t,Cp=Vs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&e)!==0&&(Dt=!0),t.firstContext=null)}function Zt(t){var e=t._currentValue;if(Cp!==t)if(t={context:t,memoizedValue:e,next:null},Vs===null){if(Rc===null)throw Error(x(308));Vs=t,Rc.dependencies={lanes:0,firstContext:t}}else Vs=Vs.next=t;return e}function cp(t){Vi===null?Vi=[t]:Vi.push(t)}function I0(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cp(e)):(n.next=i.next,i.next=n),e.interleaved=n,Tr(t,r)}function Tr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}function fp(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function B0(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Br(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ti(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Tr(t,n)}return i=r.interleaved,i===null?(e.next=e,cp(r)):(e.next=i.next,i.next=e),r.interleaved=e,Tr(t,n)}function qu(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function mg(t,e){var{updateQueue:n,alternate:r}=t;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=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};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function _c(t,e,n,r){var i=t.updateQueue;Qr=!1;var{firstBaseUpdate:s,lastBaseUpdate:o}=i,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,o===null?s=u:o.next=u,o=l;var c=t.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==o&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(s!==null){var f=i.baseState;o=0,c=u=l=null,a=s;do{var{lane:y,eventTime:v}=a;if((r&y)===y){c!==null&&(c=c.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=t,b=a;switch(y=e,v=n,b.tag){case 1:if(_=b.payload,typeof _=="function"){f=_.call(v,f,y);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=b.payload,y=typeof _=="function"?_.call(v,f,y):_,y==null)break e;f=xe({},f,y);break e;case 2:Qr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,y=i.effects,y===null?i.effects=[a]:y.push(a))}else v={eventTime:v,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=v,l=f):c=c.next=v,o|=y;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;y=a,a=y.next,y.next=null,i.lastBaseUpdate=y,i.shared.pending=null}}while(!0);if(c===null&&(l=f),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zi|=o,t.lanes=o,t.memoizedState=f}}function yg(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=lc.transition;lc.transition={};try{t(!1),e()}finally{ue=n,lc.transition=r}}function Tg(){return en().memoizedState}function r1(t,e,n){var r=Zr(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},A0(t))M0(e,n);else if(n=I0(t,e,n,r),n!==null){var i=yt();Bn(n,t,r,i),L0(n,e,r)}}function i1(t,e,n){var r=Zr(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(A0(t))M0(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,rn(a,o)){var l=e.interleaved;l===null?(i.next=i,cp(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}n=I0(t,e,i,r),n!==null&&(i=yt(),Bn(n,t,r,i),L0(n,e,r))}}function A0(t){var e=t.alternate;return t===Ne||e!==null&&e===Ne}function M0(t,e){Fa=Pc=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function L0(t,e,n){if((n&4194240)!==0){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,np(t,n)}}function xn(t,e){if(t&&t.defaultProps){e=xe({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function uh(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:xe({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}function Og(t,e,n,r,i,s,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,s,o):e.prototype&&e.prototype.isPureReactComponent?!Ua(n,r)||!Ua(i,s):!0}function C0(t,e,n){var r=!1,i=Or,s=e.contextType;return typeof s=="object"&&s!==null?s=Zt(s):(i=Nt(e)?li:tt.current,r=e.contextTypes,s=(r=r!=null)?Xs(t,i):Or),e=new e(n,s),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=Ya,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=s),e}function Eg(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&Ya.enqueueReplaceState(e,e.state,null)}function ch(t,e,n,r){var i=t.stateNode;i.props=n,i.state=t.memoizedState,i.refs={},fp(t);var s=e.contextType;typeof s=="object"&&s!==null?i.context=Zt(s):(s=Nt(e)?li:tt.current,i.context=Xs(t,s)),i.state=t.memoizedState,s=e.getDerivedStateFromProps,typeof s=="function"&&(uh(t,e,s,n),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&Ya.enqueueReplaceState(i,i.state,null),_c(t,n,i,r),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function qs(t,e){try{var n="",r=e;do n+=Nx(r),r=r.return;while(r);var i=n}catch(s){i=` Error generating stack: `+s.message+` -`+s.stack}return{value:t,source:e,stack:i,digest:null}}function xd(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function fh(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}function M0(t,e,n){n=Ir(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){jc||(jc=!0,Yh=r),fh(t,e)},n}function C0(t,e,n){n=Ir(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){fh(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){fh(t,e),typeof r!="function"&&(oi===null?oi=new Set([this]):oi.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Eg(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new z_;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=p1.bind(null,t,e,n),e.then(t,t))}function Fg(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function kg(t,e,n,r,i){return(t.mode&1)===0?(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ir(-1,1),e.tag=2,ti(n,e,1))),n.lanes|=1),t):(t.flags|=65536,t.lanes=i,t)}function pt(t,e,n,r){e.child=t===null?Wh(e,null,n,r):Gi(e,t.child,n,r)}function Ag(t,e,n,r,i){n=n.render;var s=e.ref;return Ws(e,i),r=yp(t,e,n,r,s,i),n=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Or(t,e,i)):(xe&&n&&sp(e),e.flags|=1,pt(t,e,r,i),e.child)}function Lg(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!Sp(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,U0(t,e,s,r,i)):(t=tc(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,(t.lanes&i)===0){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:Ca,n(o,r)&&t.ref===e.ref)return Or(t,e,i)}return e.flags|=1,t=ni(s,r),t.ref=e.ref,t.return=e,e.child=t}function U0(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(Ca(s,r)&&t.ref===e.ref)if(Bt=!1,e.pendingProps=r=s,(t.lanes&i)!==0)(t.flags&131072)!==0&&(Bt=!0);else return e.lanes=t.lanes,Or(t,e,i)}return dh(t,e,n,r,i)}function R0(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if((e.mode&1)===0)e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ye($i,Rt),Rt|=n;else{if((n&1073741824)===0)return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,ye($i,Rt),Rt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ye($i,Rt),Rt|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,ye($i,Rt),Rt|=r;return pt(t,e,i,n),e.child}function P0(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function dh(t,e,n,r,i){var s=Dt(n)?li:tt.current;return s=Gs(e,s),Ws(e,i),n=yp(t,e,n,r,s,i),r=gp(),t!==null&&!Bt?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Or(t,e,i)):(xe&&r&&sp(e),e.flags|=1,pt(t,e,n,i),e.child)}function Mg(t,e,n,r,i){if(Dt(n)){var s=!0;gc(e)}else s=!1;if(Ws(e,i),e.stateNode===null)ec(t,e),L0(e,n,r),ch(e,n,r,i),r=!0;else if(t===null){var{stateNode:o,memoizedProps:a}=e;o.props=a;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Xt(u):(u=Dt(n)?li:tt.current,u=Gs(e,u));var c=n.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==u)&&Og(e,o,r,u),Qr=!1;var y=e.memoizedState;o.state=y,vc(e,r,o,i),l=e.memoizedState,a!==r||y!==l||yt.current||Qr?(typeof c=="function"&&(uh(e,n,c,r),l=e.memoizedState),(a=Qr||Tg(e,n,a,r,y,l,u))?(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"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=u,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,x0(t,e),a=e.memoizedProps,u=e.type===e.elementType?a:bn(e.type,a),o.props=u,d=e.pendingProps,y=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=Xt(l):(l=Dt(n)?li:tt.current,l=Gs(e,l));var v=n.getDerivedStateFromProps;(c=typeof v=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==d||y!==l)&&Og(e,o,r,l),Qr=!1,y=e.memoizedState,o.state=y,vc(e,r,o,i);var w=e.memoizedState;a!==d||y!==w||yt.current||Qr?(typeof v=="function"&&(uh(e,n,v,r),w=e.memoizedState),(u=Qr||Tg(e,n,u,r,y,w,l)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=w),o.props=r,o.state=w,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),r=!1)}return hh(t,e,n,r,s,i)}function hh(t,e,n,r,i,s){P0(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&ug(e,n,!1),Or(t,e,s);r=e.stateNode,V_.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Gi(e,t.child,null,s),e.child=Gi(e,null,a,s)):pt(t,e,a,s),e.memoizedState=r.state,i&&ug(e,n,!0),e.child}function j0(t){var e=t.stateNode;e.pendingContext?lg(t,e.pendingContext,e.pendingContext!==e.context):e.context&&lg(t,e.context,!1),dp(t,e.containerInfo)}function Cg(t,e,n,r,i){return Xs(),ap(i),e.flags|=256,pt(t,e,n,r),e.child}function ph(t){return{baseLanes:t,cachePool:null,transitions:null}}function z0(t,e,n){var r=e.pendingProps,i=be.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),ye(be,i&1),t===null)return oh(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((e.mode&1)===0?e.lanes=1:t.data==="$!"?e.lanes=8:e.lanes=1073741824,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},(r&1)===0&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Gc(o,r,0,null),t=Yi(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=ph(n),e.memoizedState=Pc,t):vp(e,o));if(i=t.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return i1(t,e,o,r,a,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,a=i.sibling;var l={mode:"hidden",children:r.children};return(o&1)===0&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=ni(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=ni(a,s):(s=Yi(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?ph(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=Pc,r}return s=t.child,t=s.sibling,r=ni(s,{mode:"visible",children:r.children}),(e.mode&1)===0&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function vp(t,e){return e=Gc({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Uu(t,e,n,r){return r!==null&&ap(r),Gi(e,t.child,null,n),t=vp(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function i1(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=xd(Error(x(422))),Uu(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=Gc({mode:"visible",children:r.children},i,0,null),s=Yi(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,(e.mode&1)!==0&&Gi(e,t.child,null,o),e.child.memoizedState=ph(o),e.memoizedState=Pc,s);if((e.mode&1)===0)return Uu(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(x(419)),r=xd(s,r,void 0),Uu(t,e,o,r)}if(a=(o&t.childLanes)!==0,Bt||a){if(r=Qe,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=(i&(r.suspendedLanes|o))!==0?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Nr(t,i),In(r,t,i,-1))}return wp(),r=xd(Error(x(421))),Uu(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=m1.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,jt=ei(i.nextSibling),zt=e,xe=!0,Bn=null,t!==null&&(Pt[Zt++]=Br,Pt[Zt++]=Dr,Pt[Zt++]=Qi,Br=t.id,Dr=t.overflow,Qi=e),e=vp(e,r.children),e.flags|=4096,e)}function Ug(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),ah(t.return,e,n)}function Id(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function V0(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(pt(t,e,r.children,n),r=be.current,(r&2)!==0)r=r&1|2,e.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Ug(t,n,e);else if(t.tag===19)Ug(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(ye(be,r),(e.mode&1)===0)e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&_c(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Id(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&_c(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Id(e,!0,n,null,s);break;case"together":Id(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ec(t,e){(e.mode&1)===0&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Or(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Zi|=e.lanes,(n&e.childLanes)===0)return null;if(t!==null&&e.child!==t.child)throw Error(x(153));if(e.child!==null){for(t=e.child,n=ni(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ni(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function s1(t,e,n){switch(e.tag){case 3:j0(e),Xs();break;case 5:I0(e);break;case 1:Dt(e.type)&&gc(e);break;case 4:dp(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;ye(Va,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(ye(be,be.current&1),e.flags|=128,null):(n&e.child.childLanes)!==0?z0(t,e,n):(ye(be,be.current&1),t=Or(t,e,n),t!==null?t.sibling:null);ye(be,be.current&1);break;case 19:if(r=(n&e.childLanes)!==0,(t.flags&128)!==0){if(r)return V0(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ye(be,be.current),r)break;return null;case 22:case 23:return e.lanes=0,R0(t,e,n)}return Or(t,e,n)}function ha(t,e){if(!xe)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function it(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function o1(t,e,n){var r=e.pendingProps;switch(op(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return it(e),null;case 1:return Dt(e.type)&&yc(),it(e),null;case 3:return r=e.stateNode,Zs(),_e(yt),_e(tt),pp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Mu(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&(e.flags&256)===0||(e.flags|=1024,Bn!==null&&(wh(Bn),Bn=null))),Hh(t,e),it(e),null;case 5:hp(e);var i=Ri(ro.current);if(n=e.type,t!==null&&e.stateNode!=null)W_(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(x(166));return it(e),null}if(t=Ri(Nn.current),Mu(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Dn]=e,r[to]=s,t=(e.mode&1)!==0,n){case"dialog":ve("cancel",r),ve("close",r);break;case"iframe":case"object":case"embed":ve("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Dn]=e,t[to]=r,$_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":ve("cancel",t),ve("close",t),i=r;break;case"iframe":case"object":case"embed":ve("load",t),i=r;break;case"video":case"audio":for(i=0;iio&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304)}else{if(!r)if(t=_c(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ha(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!xe)return it(e),null}else 2*Fe()-s.renderingStartTime>io&&n!==1073741824&&(e.flags|=128,r=!0,ha(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Fe(),e.sibling=null,n=be.current,ye(be,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Rt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function a1(t,e){switch(op(e),e.tag){case 1:return Dt(e.type)&&yc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Zs(),_e(yt),_e(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(_e(be),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Xs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return _e(be),null;case 4:return Zs(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function As(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Ee(t,e,r)}}function l1(t,e){if(Vh=Oc,t=p0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,d=t,y=null;t:for(;;){for(var v;d!==n||i!==0&&d.nodeType!==3||(a=o+i),d!==s||r!==0&&d.nodeType!==3||(l=o+r),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)y=d,d=v;for(;;){if(d===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=d.nextSibling)!==null)break;d=y,y=d.parentNode}d=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Oc=!1,F=e;F!==null;)if(e=F,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,F=t;else for(;F!==null;){e=F;try{var w=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var{memoizedProps:I,memoizedState:Y}=w,h=e.stateNode,f=h.getSnapshotBeforeUpdate(e.elementType===e.type?I:bn(e.type,I),Y);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Ee(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,F=t;break}F=e.return}return w=fv,fv=!1,w}function Ba(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Qc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function $0(t){var e=t.alternate;e!==null&&(t.alternate=null,$0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Dn],delete e[to],delete e[Ac],delete e[M_],delete e[C_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function W0(t){return t.tag===5||t.tag===3||t.tag===4}function Rg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||W0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=pc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Kr(t,e,n){for(n=n.child;n!==null;)H0(t,e,n),n=n.sibling}function H0(t,e,n){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(nf,n)}catch{}switch(n.tag){case 5:lt||As(n,e);case 6:var r=qe,i=xn;qe=null,Kr(t,e,n),qe=r,xn=i,qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(xn?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ma(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=xn,qe=n.stateNode.containerInfo,xn=!0,Kr(t,e,n),qe=r,xn=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Kr(t,e,n);break;case 1:if(!lt&&(As(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ee(n,e,a)}Kr(t,e,n);break;case 21:Kr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Kr(t,e,n),lt=r):Kr(t,e,n);break;default:Kr(t,e,n)}}function Pg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Y_),e.forEach(function(r){var i=y1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Sn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*K_(r/1960))-r,10t?16:t,qr===null)var r=!1;else{if(t=qr,qr=null,zc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,F=t.current;F!==null;){var s=F,o=s.child;if((F.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lFe()-Rp?Hi(t,0):Up|=n),Nt(t,e)}function q0(t,e){e===0&&((t.mode&1)===0?e=1:(e=zu,zu<<=1,(zu&130023424)===0&&(zu=4194304)));var n=mt();t=Nr(t,e),t!==null&&(Qa(t,e,n),Nt(t,n))}function m1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),q0(t,n)}function y1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),q0(t,n)}function e_(t,e){return Op(t,e)}function g1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 en(t,e,n,r){return new g1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function v1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qc)return 11;if(t===ef)return 14}return 2}function ni(t,e){var n=t.alternate;return n===null?(n=en(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case Jc:o=8,i|=8;break;case Ic:return t=en(12,n,e,i|2),t.elementType=Ic,t.lanes=s,t;case Bc:return t=en(13,n,e,i),t.elementType=Bc,t.lanes=s,t;case Dc:return t=en(19,n,e,i),t.elementType=Dc,t.lanes=s,t;case Np:return Gc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case qc:o=11;break e;case ef:o=14;break e;case Sr:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=en(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=en(7,t,r,e),t.lanes=n,t}function Gc(t,e,n,r){return t=en(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=en(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=en(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new _1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=en(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function w1(t,e,n){var r=3{if(Kg=he($t(),1),xt=he(bx(),1),Ip=new Set,Ys={},jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xc=Object.prototype.hasOwnProperty,r_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},Ye={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ye[t]=new ht(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ye[e]=new ht(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ye[t]=new ht(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ye[t]=new ht(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ye[t]=new ht(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Ye[t]=new ht(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Ye[t]=new ht(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Ye[t]=new ht(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Ye[t]=new ht(t,5,!1,t.toLowerCase(),null,!1,!1)}),Ru=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ru,hd);Ye[e]=new ht(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!1,!1)}),Ye.xlinkHref=new ht("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){Ye[t]=new ht(t,1,!1,t.toLowerCase(),null,!0,!0)}),zn=Kg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sa=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),Jc=Symbol.for("react.strict_mode"),Ic=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),qc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Dc=Symbol.for("react.suspense_list"),ef=Symbol.for("react.memo"),Sr=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,Se=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Pu=Pu||document.createElement("div"),Pu.innerHTML=""+e.valueOf().toString()+"",e=Pu.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Ms={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},Qg=["Webkit","ms","Moz","O"],Object.keys(Ms).forEach(function(t){Qg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ms[e]=Ms[t]})}),i_=Se({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}),jn)try{Ts={},Object.defineProperty(Ts,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Nh=!1}for(s_={onError:function(t){Da=!0,Nc=t}},Op=xt.unstable_scheduleCallback,Oh=xt.unstable_cancelCallback,o_=xt.unstable_shouldYield,a_=xt.unstable_requestPaint,Fe=xt.unstable_now,l_=xt.unstable_getCurrentPriorityLevel,tf=xt.unstable_ImmediatePriority,Ep=xt.unstable_UserBlockingPriority,ja=xt.unstable_NormalPriority,u_=xt.unstable_LowPriority,Fp=xt.unstable_IdlePriority,tn=Math.clz32?Math.clz32:Lx,c_=Math.log,f_=Math.LN2,ba=[],qs=new Map,eo=new Map,xr=[],m_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=zn.ReactCurrentBatchConfig,Fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rf=Ut(Fi),Os=Se({},Fi,{view:0,detail:0}),y_=Ut(Os),ma=Se({},Os,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==pa&&(pa&&t.type==="mousemove"?(kd=t.screenX-pa.screenX,Ad=t.screenY-pa.screenY):Ad=kd=0,pa=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Fh=Ut(ma),Xg=Se({},ma,{dataTransfer:0}),g_=Ut(Xg),Zg=Se({},Os,{relatedTarget:0}),ic=Ut(Zg),Jg=Se({},Fi,{animationName:0,elapsedTime:0,pseudoElement:0}),v_=Ut(Jg),qg=Se({},Fi,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),__=Ut(qg),ev=Se({},Fi,{data:0}),kh=Ut(ev),tv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},rv=Se({},Os,{key:function(t){if(t.key){var e=tv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Zu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?nv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Zu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),S_=Ut(rv),iv=Se({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Ut(iv),sv=Se({},Os,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),b_=Ut(sv),ov=Se({},Fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),x_=Ut(ov),av=Se({},ma,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),I_=Ut(av),B_=[9,13,27,32],Fc=jn&&("CompositionEvent"in window),jn&&("documentMode"in document)&&(ya=document.documentMode),D_=jn&&("TextEvent"in window)&&!ya,Lp=jn&&(!Fc||ya&&8=ya),Lh=" ",N_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},jn&&(jn?(Vu="oninput"in document,Vu||(Md=document.createElement("div"),Md.setAttribute("oninput","return;"),Vu=typeof Md.oninput=="function"),Ld=Vu):Ld=!1,T_=Ld&&(!document.documentMode||9=document.documentMode,Ci={animationend:ku("Animation","AnimationEnd"),animationiteration:ku("Animation","AnimationIteration"),animationstart:ku("Animation","AnimationStart"),transitionend:ku("Transition","TransitionEnd")},sc={},Uh={},jn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Au("animationend"),Ph=Au("animationiteration"),jh=Au("animationstart"),zh=Au("transitionend"),Mp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Wu=0;Wu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Vv}),M1=so(function(t){var e=he(Z_());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),J_={};Qh(J_,{Fragment:()=>rw,jsx:()=>iw,jsxs:()=>sw});function pv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)ew.call(e,r)&&!nw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:q_,type:t,key:s,ref:o,props:i,_owner:tw.current}}var mv,q_,yv,ew,tw,nw,rw,iw,sw,C1=Gh(()=>{mv=he($t(),1),q_=Symbol.for("react.element"),yv=Symbol.for("react.fragment"),ew=Object.prototype.hasOwnProperty,tw=mv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nw={key:!0,ref:!0,__self:!0,__source:!0},rw=yv,iw=pv,sw=pv}),Er=so(function(t,e){C1(),e.exports=J_}),Jt=he($t(),1),U1=he(M1(),1),R1=he(Z_(),1),dL=he($t(),1);function Vc(t){return String(t||"").split(".").at(-1)}function jp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").trim().toLowerCase(),i=e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||!r&&!e.style&&!e.currency&&e.type==="ratio",s=r.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),o=r.match(/^(?:decimal|percent|usd)_(\d+)$/),a=s?(s[1]||"").length:o?Number(o[1]):void 0,l=e.maximumFractionDigits??(a===void 0?i||e.compact?1:2:Math.min(a,20)),u=a===void 0?void 0:Math.min(s?(s[1]||"").replaceAll("#","").length:a,l);if(i)return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:l,minimumFractionDigits:u,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let c=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:l,minimumFractionDigits:u,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function Ji(t){return String(t??"")}function ow(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function aw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var hL=he(Er(),1);var P1=he($t(),1);function j1(t){return t.split(".").at(-1)||t}var $c="\0__null__";function Wc(t){return t===$c||t===""?"\u2014":t}function Pd(t,e={}){return jp(t,e)}function zp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${zp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Wc(e[0])}`:e.length<=2?`${n} ${e.map(Wc).join(", ")}`:`${n} ${e.length} values`}var at=he($t(),1);function V1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var $1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Ku(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Qu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function W1(t,e){let n=t.split("__").at(-1);return n&&$1.has(n)?n:e}function H1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function Y1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function K1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Ku(i.query.dimensions),o=Ku(i.query.metrics),a=o.map(g=>t.graphMetrics.find(_=>_.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...V1(t,u.name)],d=o.map(g=>c.find(_=>_.ref===g)).filter(g=>!!g),y=s.map(g=>Qu(t,g)).filter((g,_,D)=>!!g&&D.findIndex(N=>N?.ref===g?.ref)===_),v=i.encoding?.y,I=(Array.isArray(v)?v:v?[v]:[]).find(g=>d.some(_=>_.ref===g))??d[0]?.ref??u.metrics[0]?.ref??"",Y=i.encoding?.x,h=(Y&&Qu(t,Y)?.type==="time"?Y:void 0)??s.find(g=>Qu(t,g)?.type==="time"),f=u.defaultGrain??"month",m=h?Qu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:d.length?d:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:I,grain:h?W1(h,f):f,filters:Ku(i.query.filters),segments:Ku(i.query.segments),usePreaggregations:Y1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??H1(e)}}var Q1=["second","minute","hour","day","week","month","quarter","year"];function G1(t){return t.toISOString().slice(0,10)}function X1(t){return t.slice(0,10)}function Z1(t){return new Date(`${X1(t)}T00:00:00Z`)}function J1(t,e){let n=Z1(t);return n.setUTCDate(n.getUTCDate()+e),G1(n)}function q1(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${J1(e.to,1)}' as date)`]}function eI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function tI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function nI(t){return tI(t.models.flatMap(e=>e.dimensions))}function gv(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return zp(t,n)}function rI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function lw(t,e,n){let r=zp(`%${rI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function iI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes($c),o=e.values.filter(l=>l!==$c),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${gv(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>gv(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function sI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||eI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(lw(r,i.pattern??"",e.dialect));continue}let o=iI(r,i,s,e.dialect);o&&n.push(o)}return n}function oI(t,e={}){let n=sI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...q1(e.timeRef,e.range)),n}function aI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var uw=he($t(),1),pL=new Set(Q1);var lI=uw.createContext(null);function uI(){let t=uw.useContext(lI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=he($t(),1),mL=he($t(),1),Hc={active:0,listeners:new Set};function cw(){for(let t of Hc.listeners)t()}function cI(){Hc.active+=1,cw()}function fI(){Hc.active=Math.max(0,Hc.active-1),cw()}var dI=80;function hI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{cI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>fI())},dI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var pI=he($t(),1);function mI(t,e=!0){pI.useLayoutEffect(()=>{let n=t.current,r=n?.parentElement;if(!e||!n||!r)return;function i(){if(!n||!r)return;let o=r.getBoundingClientRect(),a=8,l=Math.max(a,Math.min(o.left,window.innerWidth-n.offsetWidth-a));n.style.left=`${l-o.left}px`,n.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-o.bottom-a-4)}px`)}i();let s=new ResizeObserver(i);return s.observe(n),s.observe(r),r.parentElement&&s.observe(r.parentElement),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{s.disconnect(),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}})}var Le=he(Er(),1),yI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],gI=50,vv=200;function _v(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function vI({dim:t,model:e,onClose:n}){let{state:r,dispatch:i,backend:s,catalog:o,dashboard:a}=uI(),l=at.useMemo(()=>K1(o,a,r.dashboardTab),[o,a,r.dashboardTab]),u=r.filters[t.ref],[c,d]=at.useState(u?.mode??"include"),y=at.useMemo(()=>new Set(u?.mode!=="contains"?u?.values??[]:[]),[u]),v=at.useRef(null);mI(v);let w=at.useRef(null),I=at.useId(),[Y,h]=at.useState(""),f=_v(Y,vv),m=u?.mode==="contains"?u.pattern??"":"",[g,_]=at.useState(m),D=_v(g,vv);at.useEffect(()=>{let b=document.activeElement;return w.current?.focus(),()=>b?.focus?.()},[]),at.useEffect(()=>{function b(Be){Be.key==="Escape"&&(Be.stopPropagation(),n())}function X(Be){v.current&&!v.current.contains(Be.target)&&n()}return document.addEventListener("keydown",b,!0),document.addEventListener("mousedown",X,!0),()=>{document.removeEventListener("keydown",b,!0),document.removeEventListener("mousedown",X,!0)}},[n]),at.useEffect(()=>{c==="contains"&&D!==m&&i({type:"setFilterPattern",dim:t.ref,pattern:D})},[D,c,t.ref,i]);let N=o.models.find(b=>b.name===r.model)??e,S=l?.timeDimension?.ref??N.timeDimension?.ref,K=at.useMemo(()=>nI(o),[o]),L=at.useMemo(()=>{let b=[...l?.filters??[],...oI(r.filters,{timeRef:S,range:r.dateRange,excludeDim:t.ref,types:K,dialect:o.dialect})];return f.trim()&&b.push(lw(t.ref,f.trim(),o.dialect)),b},[l,r.filters,S,r.dateRange,t.ref,f,K,o.dialect]),ue=c!=="contains",{result:Te,loading:Re,error:Ie}=hI(s,ue?aI(t.ref,L,gI,l?.segments,l?.usePreaggregations):null),ke=j1(t.ref),Pe=at.useMemo(()=>Te?Te.rows.map(b=>{let X=b[ke];return X==null?$c:String(X)}):[],[Te,ke]),Fr=!!Te&&Te.rows.length>0&&!Te.columns.includes(ke),T=ue&&(Re||Fr);function M(b){d(b),u&&i({type:"setFilterMode",dim:t.ref,mode:b}),b==="contains"&&_(m)}function B(b){if(b.key!=="Tab")return;let X=v.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!X||X.length===0)return;let Be=X[0],Tn=X[X.length-1];b.shiftKey&&document.activeElement===Be?(b.preventDefault(),Tn.focus()):!b.shiftKey&&document.activeElement===Tn&&(b.preventDefault(),Be.focus())}return Le.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":I,onKeyDown:B,className:"absolute left-0 top-full z-50 mt-1 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[Le.jsxs("div",{id:I,className:"mb-2 flex items-baseline justify-between gap-2",children:[Le.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:t.label}),Le.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:n,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Le.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:yI.map(({mode:b,label:X})=>Le.jsx("button",{type:"button","aria-pressed":c===b,onClick:()=>M(b),className:`px-1.5 py-1 text-center ${c===b?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:X},b))}),c==="contains"?Le.jsx("input",{ref:w,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:g,onChange:b=>_(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Le.jsxs(Le.Fragment,{children:[Le.jsx("input",{ref:w,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:Y,onChange:b=>h(b.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Le.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:Ie?Le.jsx("p",{className:"px-1 py-2 text-danger",children:Ie}):T?Le.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(b=>Le.jsx("div",{className:"skeleton h-4 w-full"},b))}):Pe.length===0?Le.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Pe.map(b=>{let X=y.has(b);return Le.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Le.jsx("input",{type:"checkbox",checked:X,onChange:()=>i({type:"toggleFilter",dim:t.ref,value:b,mode:c}),className:"size-3 shrink-0 accent-[var(--accent)]"}),Le.jsx("span",{className:"min-w-0 break-words text-ink",children:Wc(b)})]},b)})})]}),Le.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Le.jsx("button",{type:"button",onClick:()=>i({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Le.jsx("button",{type:"button",onClick:n,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]})}var Vn=he(Er(),1);function wv(t){let[e,n]=P1.useState(!1);if(!("dim"in t))return Vn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("span",{className:"truncate",children:[Vn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?Vn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:r,model:i,filter:s,onRemove:o}=t;return Vn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":r.ref,"data-mode":s.mode,children:[Vn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("button",{type:"button","aria-label":`Edit filter ${r.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(a=>!a),className:"min-w-0 truncate text-left hover:text-ink",children:[Vn.jsx("span",{className:"text-faint",children:r.label})," ",z1(s)]}),Vn.jsx("button",{type:"button","aria-label":`Remove filter ${r.label}`,onClick:o,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?Vn.jsx(vI,{dim:r,model:i,onClose:()=>n(!1)}):null]})}var Je=he(Er(),1),_I={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function wI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:d=6,expanded:y=!1,onExpandedChange:v,containerRef:w}){let I=new Set(i),Y=y?r:r.slice(0,d),h=Math.max(1,...Y.map(_=>Math.abs(_.metric))),f=y||r.length>d,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:w,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(_=>Je.jsx("button",{type:"button",title:_.title,"aria-pressed":l===_.key,"data-context":_.key,"data-active":l===_.key||void 0,onClick:()=>c(_.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:_.label},_.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(_=>Je.jsx("div",{className:"skeleton h-5 w-full"},_))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):Y.map(_=>{let D=_.metric<0?"negative":"positive",N=I.has(_.value),S=`${Math.round(Math.abs(_.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":_.value,"data-selected":N||void 0,"data-tone":D,onClick:()=>a?.(_.value),"aria-pressed":N,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${D==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:S}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Wc(_.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(_.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":_.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${_I[_.context?.tone??"neutral"]}`,children:_.context?.label??"\u2014"}):null]},`${t}:${_.value}`)})}),f&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var SI=he($t(),1),_r=he($t(),1),yL=he($t(),1),bI=he(Er(),1);function xI({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?bI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=he(Er(),1);function II({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=_r.useRef(null),l=_r.useId(),u=_r.useRef(null),c=_r.useRef(null),[d,y]=_r.useState(200),[v,w]=_r.useState(null),[I,Y]=_r.useState(null),[h,f]=_r.useState(null);_r.useEffect(()=>{let B=a.current;if(!B||typeof ResizeObserver>"u")return;let b=new ResizeObserver(X=>{for(let Be of X)y(Math.max(40,Be.contentRect.width))});return b.observe(B),()=>b.disconnect()},[]);let m=t.map((B,b)=>({index:b,value:B})).filter(B=>Number.isFinite(B.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${d} ${n}`});let g=3,_=Math.min(...m.map(B=>B.value)),N=Math.max(...m.map(B=>B.value))-_||1,S=m.map((B,b)=>({...B,x:g+b/(m.length-1)*(d-g*2),y:g+(1-(B.value-_)/N)*(n-g*2)})),K=S.map(({x:B,y:b})=>`${B.toFixed(1)},${b.toFixed(1)}`).join(" L "),L=`M ${S[0].x.toFixed(1)},${n-g} L ${K} L ${S.at(-1).x.toFixed(1)},${n-g} Z`,ue=S.at(-1),Te=r||`Trend of ${m.length} points, latest ${i(ue.value)}`;function Re(B){let b=u.current?.getBoundingClientRect();return b?Math.max(g,Math.min(d-g,(B.clientX-b.left)/b.width*d)):g}function Ie(B){return Math.max(0,Math.min(S.length-1,Math.round((B-g)/(d-g*2)*(S.length-1))))}function ke(B){let b=Re(B),X=Ie(b),Be=S[X];w(X),f({content:`${e?.[Be.index]?`${e[Be.index]}: `:""}${i(Be.value)}`,x:B.clientX,y:B.clientY}),s?.({index:Be.index,label:e?.[Be.index],value:Be.value}),c.current!==null&&Y({a:c.current,b})}function Pe(B){if(!o||!e?.length)return;B.currentTarget.setPointerCapture(B.pointerId);let b=Re(B);c.current=b,Y({a:b,b})}function Fr(B){if(c.current===null||!o||!e?.length)return;B.currentTarget.hasPointerCapture(B.pointerId)&&B.currentTarget.releasePointerCapture(B.pointerId);let b=Re(B);if(Math.abs(b-c.current)>6){let X=S[Ie(Math.min(c.current,b))],Be=S[Ie(Math.max(c.current,b))];o({from:e[X.index],to:e[Be.index]})}c.current=null,Y(null)}function T(){w(null),f(null),s?.(null),c.current===null&&Y(null)}let M=v===null?null:S[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":Te,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${d} ${n}`,preserveAspectRatio:"none",onPointerMove:ke,onPointerDown:Pe,onPointerUp:Fr,onPointerCancel:T,onPointerLeave:T,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${K}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),I?st.jsx("rect",{x:Math.min(I.a,I.b),y:0,width:Math.abs(I.b-I.a),height:n,fill:"currentColor",opacity:.12}):null,M?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:M.x,x2:M.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:M.x,cy:M.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:ue.x,cy:ue.y,r:2.25,fill:"currentColor"})]}),st.jsx(xI,{tip:h})]})}var ot=he(Er(),1),BI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},DI={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function NI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:d,onSparkHover:y,onSparkBrush:v}){let[w,I]=SI.useState(null),Y=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),w?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:w.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):w?Pd(w.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${BI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:DI[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",f=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(II,{values:a,labels:l,onHover:m=>{I(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return d?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>d(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:Y}),f]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[Y,f]})}var gL=he(Er(),1);var Xr=he(Er(),1);function Vp({tone:t,title:e,message:n}){let r=t==="danger";return Xr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Xr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Xr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Xr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Xr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function TI({title:t="Loading",message:e="Loading metrics\u2026"}){return Xr.jsx(Vp,{tone:"loading",title:t,message:e})}function OI({title:t="No results",message:e}){return Xr.jsx(Vp,{tone:"muted",title:t,message:e})}function EI({title:t="Query failed",message:e}){return Xr.jsx(Vp,{tone:"danger",title:t,message:e})}var Sv=new WeakMap;function lf(t,e){let n=Sv.get(t);n||(t.replaceChildren(),n=U1.createRoot(t),Sv.set(t,n)),R1.flushSync(()=>n.render(e))}function FI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??Vc(e)}function fw(t,e){return typeof t=="function"?t(e):t}function kI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function AI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:kI(n)}}function dw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];lf(t,Jt.createElement(Jt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=Vc(s);return Jt.createElement(NI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:fw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function $p(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;lf(t,Jt.createElement(Jt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=AI({dimensions:[o],metrics:[n.metricRef],result:a}),u=FI(l),c=r===o;return Jt.createElement(wI,{key:o,dimension:o,title:s.label??Vc(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??Vc(n.metricRef),rows:u.map(d=>({value:Ji(d[zd(l,o)]),metric:Number(d[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:d=>jp(d,fw(n.valueFormat,{metric:n.metricRef,value:d})),onToggle:n.onSelect?d=>n.onSelect({dimension:o,value:d,row:u.find(y=>Ji(y[zd(l,o)])===d)}):void 0,onExpandedChange:n.expandable===!1?void 0:d=>{t.__sdmExpandedDim=d?o:void 0,$p(t,e,n)}})})))}function hw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return Jt.createElement(wv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(Jt.createElement(wv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));lf(t,i.length?Jt.createElement(Jt.Fragment,null,...i):r.emptyLabel?Jt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function pw(t,e){let n=e.kind==="error"?EI:e.kind==="loading"?TI:OI;lf(t,Jt.createElement(n,{message:e.message}))}function Wp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function mw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function yw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function gw(t,e){let n=mw(t),r=mw(e);if(!n||!r){let a=Wp(t),l=Wp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=yw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=yw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function LI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Nn]=e,t[no]=r,H_(t,e,!1,!1),e.stateNode=t;e:{switch(o=th(n,r),n){case"dialog":_e("cancel",t),_e("close",t),i=r;break;case"iframe":case"object":case"embed":_e("load",t),i=r;break;case"video":case"audio":for(i=0;iso&&(e.flags|=128,r=!0,pa(s,!1),e.lanes=4194304)}else{if(!r)if(t=wc(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),pa(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Be)return it(e),null}else 2*Fe()-s.renderingStartTime>so&&n!==1073741824&&(e.flags|=128,r=!0,pa(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Fe(),e.sibling=null,n=Ie.current,ge(Ie,r?n&1|2:n&1),e):(it(e),null);case 22:case 23:return _p(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&(e.mode&1)!==0?(Pt&1073741824)!==0&&(it(e),e.subtreeFlags&6&&(e.flags|=8192)):it(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function l1(t,e){switch(op(e),e.tag){case 1:return Nt(e.type)&&gc(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Js(),we(gt),we(tt),pp(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 5:return hp(e),null;case 13:if(we(Ie),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(x(340));Zs()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return we(Ie),null;case 4:return Js(),null;case 10:return up(e.type._context),null;case 22:case 23:return _p(),null;case 24:return null;default:return null}}function Ms(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(t,e,r)}else n.current=null}function mh(t,e,n){try{n()}catch(r){Ee(t,e,r)}}function u1(t,e){if(Vh=Ec,t=y0(),ip(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var{anchorOffset:i,focusNode:s}=r;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,u=0,c=0,f=t,y=null;t:for(;;){for(var v;f!==n||i!==0&&f.nodeType!==3||(a=o+i),f!==s||r!==0&&f.nodeType!==3||(l=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(v=f.firstChild)!==null;)y=f,f=v;for(;;){if(f===t)break t;if(y===n&&++u===i&&(a=o),y===s&&++c===r&&(l=o),(v=f.nextSibling)!==null)break;f=y,y=f.parentNode}f=v}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($h={focusedElem:t,selectionRange:n},Ec=!1,E=e;E!==null;)if(e=E,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,E=t;else for(;E!==null;){e=E;try{var _=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var{memoizedProps:b,memoizedState:K}=_,h=e.stateNode,d=h.getSnapshotBeforeUpdate(e.elementType===e.type?b:xn(e.type,b),K);h.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=e.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Ee(e,e.return,g)}if(t=e.sibling,t!==null){t.return=e.return,E=t;break}E=e.return}return _=dv,dv=!1,_}function Da(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&mh(e,n,s)}i=i.next}while(i!==r)}}function Gc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yh(t){var e=t.ref;if(e!==null){var n=t.stateNode;t.tag,t=n,typeof e=="function"?e(t):e.current=t}}function H0(t){var e=t.alternate;e!==null&&(t.alternate=null,H0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Nn],delete e[no],delete e[Mc],delete e[U_],delete e[R_])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Y0(t){return t.tag===5||t.tag===3||t.tag===4}function Pg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Y0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function gh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=mc));else if(r!==4&&(t=t.child,t!==null))for(gh(t,e,n),t=t.sibling;t!==null;)gh(t,e,n),t=t.sibling}function vh(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vh(t,e,n),t=t.sibling;t!==null;)vh(t,e,n),t=t.sibling}function Kr(t,e,n){for(n=n.child;n!==null;)K0(t,e,n),n=n.sibling}function K0(t,e,n){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(rf,n)}catch{}switch(n.tag){case 5:lt||Ms(n,e);case 6:var r=qe,i=In;qe=null,Kr(t,e,n),qe=r,In=i,qe!==null&&(In?(t=qe,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):qe.removeChild(n.stateNode));break;case 18:qe!==null&&(In?(t=qe,n=n.stateNode,t.nodeType===8?_d(t.parentNode,n):t.nodeType===1&&_d(t,n),Ca(t)):_d(qe,n.stateNode));break;case 4:r=qe,i=In,qe=n.stateNode.containerInfo,In=!0,Kr(t,e,n),qe=r,In=i;break;case 0:case 11:case 14:case 15:if(!lt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&((s&2)!==0||(s&4)!==0)&&mh(n,e,o),i=i.next}while(i!==r)}Kr(t,e,n);break;case 1:if(!lt&&(Ms(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ee(n,e,a)}Kr(t,e,n);break;case 21:Kr(t,e,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,Kr(t,e,n),lt=r):Kr(t,e,n);break;default:Kr(t,e,n)}}function jg(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Q_),e.forEach(function(r){var i=g1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function bn(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*G_(r/1960))-r,10t?16:t,qr===null)var r=!1;else{if(t=qr,qr=null,Vc=0,(re&6)!==0)throw Error(x(331));var i=re;for(re|=4,E=t.current;E!==null;){var s=E,o=s.child;if((E.flags&16)!==0){var a=s.deletions;if(a!==null){for(var l=0;lFe()-Rp?Hi(t,0):Up|=n),Tt(t,e)}function t_(t,e){e===0&&((t.mode&1)===0?e=1:(e=Vu,Vu<<=1,(Vu&130023424)===0&&(Vu=4194304)));var n=yt();t=Tr(t,e),t!==null&&(Ga(t,e,n),Tt(t,n))}function y1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),t_(t,n)}function g1(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),t_(t,n)}function n_(t,e){return Op(t,e)}function v1(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,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 tn(t,e,n,r){return new v1(t,e,n,r)}function Sp(t){return t=t.prototype,!(!t||!t.isReactComponent)}function _1(t){if(typeof t=="function")return Sp(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ef)return 11;if(t===tf)return 14}return 2}function ni(t,e){var n=t.alternate;return n===null?(n=tn(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function nc(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Sp(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ji:return Yi(n.children,i,s,e);case qc:o=8,i|=8;break;case Bc:return t=tn(12,n,e,i|2),t.elementType=Bc,t.lanes=s,t;case Dc:return t=tn(13,n,e,i),t.elementType=Dc,t.lanes=s,t;case Nc:return t=tn(19,n,e,i),t.elementType=Nc,t.lanes=s,t;case Np:return Xc(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Bp:o=10;break e;case Dp:o=9;break e;case ef:o=11;break e;case tf:o=14;break e;case br:o=16,r=null;break e}throw Error(x(130,t==null?t:typeof t,""))}return e=tn(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Yi(t,e,n,r){return t=tn(7,t,r,e),t.lanes=n,t}function Xc(t,e,n,r){return t=tn(22,t,r,e),t.elementType=Np,t.lanes=n,t.stateNode={isHidden:!1},t}function Dd(t,e,n){return t=tn(6,t,null,e),t.lanes=n,t}function Nd(t,e,n){return e=tn(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function w1(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=md(0),this.expirationTimes=md(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=md(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function bp(t,e,n,r,i,s,o,a,l){return t=new w1(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=tn(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fp(s),t}function S1(t,e,n){var r=3{if(Qg=de(Wt(),1),It=de(xx(),1),Ip=new Set,Ks={},jn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ic=Object.prototype.hasOwnProperty,s_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bh={},xh={},Ye={},"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ye[t]=new pt(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ye[e]=new pt(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ye[t]=new pt(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ye[t]=new pt(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ye[t]=new pt(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Ye[t]=new pt(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Ye[t]=new pt(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Ye[t]=new pt(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Ye[t]=new pt(t,5,!1,t.toLowerCase(),null,!1,!1)}),Pu=/[\-:]([a-z])/g,"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Pu,hd);Ye[e]=new pt(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Pu,hd);Ye[e]=new pt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Pu,hd);Ye[e]=new pt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){Ye[t]=new pt(t,1,!1,t.toLowerCase(),null,!1,!1)}),Ye.xlinkHref=new pt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){Ye[t]=new pt(t,1,!1,t.toLowerCase(),null,!0,!0)}),zn=Qg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ba=Symbol.for("react.element"),Pi=Symbol.for("react.portal"),ji=Symbol.for("react.fragment"),qc=Symbol.for("react.strict_mode"),Bc=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Dp=Symbol.for("react.context"),ef=Symbol.for("react.forward_ref"),Dc=Symbol.for("react.suspense"),Nc=Symbol.for("react.suspense_list"),tf=Symbol.for("react.memo"),br=Symbol.for("react.lazy"),Np=Symbol.for("react.offscreen"),Ih=Symbol.iterator,xe=Object.assign,Ls=Array.isArray,Tp=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,i){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,i)})}:t})(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(ju=ju||document.createElement("div"),ju.innerHTML=""+e.valueOf().toString()+"",e=ju.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}}),Cs={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},Gg=["Webkit","ms","Moz","O"],Object.keys(Cs).forEach(function(t){Gg.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Cs[e]=Cs[t]})}),o_=xe({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}),jn)try{Os={},Object.defineProperty(Os,"passive",{get:function(){Nh=!0}}),window.addEventListener("test",Os,Os),window.removeEventListener("test",Os,Os)}catch{Nh=!1}for(a_={onError:function(t){Na=!0,Tc=t}},Op=It.unstable_scheduleCallback,Oh=It.unstable_cancelCallback,l_=It.unstable_shouldYield,u_=It.unstable_requestPaint,Fe=It.unstable_now,c_=It.unstable_getCurrentPriorityLevel,nf=It.unstable_ImmediatePriority,Ep=It.unstable_UserBlockingPriority,za=It.unstable_NormalPriority,f_=It.unstable_LowPriority,Fp=It.unstable_IdlePriority,nn=Math.clz32?Math.clz32:Lx,d_=Math.log,h_=Math.LN2,xa=[],eo=new Map,to=new Map,Ir=[],g_="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" "),Ki=zn.ReactCurrentBatchConfig,Fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sf=Rt(Fi),Es=xe({},Fi,{view:0,detail:0}),v_=Rt(Es),ya=xe({},Es,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==ma&&(ma&&t.type==="mousemove"?(kd=t.screenX-ma.screenX,Ad=t.screenY-ma.screenY):Ad=kd=0,ma=t),kd)},movementY:function(t){return"movementY"in t?t.movementY:Ad}}),Fh=Rt(ya),Zg=xe({},ya,{dataTransfer:0}),__=Rt(Zg),Jg=xe({},Es,{relatedTarget:0}),sc=Rt(Jg),qg=xe({},Fi,{animationName:0,elapsedTime:0,pseudoElement:0}),w_=Rt(qg),ev=xe({},Fi,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),S_=Rt(ev),tv=xe({},Fi,{data:0}),kh=Rt(tv),nv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},b_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"},iv=xe({},Es,{key:function(t){if(t.key){var e=nv[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Ju(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?rv[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(t){return t.type==="keypress"?Ju(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ju(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),x_=Rt(iv),sv=xe({},ya,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ah=Rt(sv),ov=xe({},Es,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),I_=Rt(ov),av=xe({},Fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),B_=Rt(av),lv=xe({},ya,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),D_=Rt(lv),N_=[9,13,27,32],kc=jn&&("CompositionEvent"in window),jn&&("documentMode"in document)&&(ga=document.documentMode),T_=jn&&("TextEvent"in window)&&!ga,Mp=jn&&(!kc||ga&&8=ga),Mh=" ",O_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0},jn&&(jn?($u="oninput"in document,$u||(Ld=document.createElement("div"),Ld.setAttribute("oninput","return;"),$u=typeof Ld.oninput=="function"),Md=$u):Md=!1,E_=Md&&(!document.documentMode||9=document.documentMode,Ci={animationend:Au("Animation","AnimationEnd"),animationiteration:Au("Animation","AnimationIteration"),animationstart:Au("Animation","AnimationStart"),transitionend:Au("Transition","TransitionEnd")},oc={},Uh={},jn&&(Uh=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition),Rh=Mu("animationend"),Ph=Mu("animationiteration"),jh=Mu("animationstart"),zh=Mu("transitionend"),Lp=new Map,Cd="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" "),Hu=0;Hu"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}n(),e.exports=Wv}),C1=oo(function(t){var e=de(jp());t.createRoot=e.createRoot,t.hydrateRoot=e.hydrateRoot;var n}),q_={};Qh(q_,{Fragment:()=>iw,jsx:()=>sw,jsxs:()=>ow});function mv(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)tw.call(e,r)&&!rw.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:ew,type:t,key:s,ref:o,props:i,_owner:nw.current}}var yv,ew,gv,tw,nw,rw,iw,sw,ow,U1=Gh(()=>{yv=de(Wt(),1),ew=Symbol.for("react.element"),gv=Symbol.for("react.fragment"),tw=Object.prototype.hasOwnProperty,nw=yv.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rw={key:!0,ref:!0,__self:!0,__source:!0},iw=gv,sw=mv,ow=mv}),Fr=oo(function(t,e){U1(),e.exports=q_}),qt=de(Wt(),1),R1=de(C1(),1),P1=de(jp(),1),hM=de(Wt(),1);function $c(t){return String(t||"").split(".").at(-1)}function zp(t,e={}){if(t==null||t==="")return"\u2014";let n=typeof t=="number"?t:Number(t);if(!Number.isFinite(n))return String(t);let r=String(e.format||"").trim().toLowerCase(),i=e.style==="percent"||r.includes("%")||r.includes("percent")||r.includes("pct")||!r&&!e.style&&!e.currency&&e.type==="ratio",s=r.match(/^[^0#]*[0#,]+(?:\.([0#]+))?(?:\\?%)?$/),o=r.match(/^(?:decimal|percent|usd)_(\d+)$/),a=s?(s[1]||"").length:o?Number(o[1]):void 0,l=e.maximumFractionDigits??(a===void 0?i||e.compact?1:2:Math.min(a,20)),u=a===void 0?void 0:Math.min(s?(s[1]||"").replaceAll("#","").length:a,l);if(i)return(e.style==="percent"?n:Math.abs(n)<=1?n*100:n).toLocaleString(void 0,{maximumFractionDigits:l,minimumFractionDigits:u,style:e.style==="percent"?"percent":"decimal"})+(e.style==="percent"?"":"%");let c=e.style==="currency"||e.currency||r.includes("$")||r.includes("usd")||r.includes("currency")||r.includes("dollar");return n.toLocaleString(void 0,{currency:c?e.currency||"USD":void 0,maximumFractionDigits:l,minimumFractionDigits:u,notation:e.compact?"compact":"standard",style:c?"currency":"decimal"})}function Ji(t){return String(t??"")}function aw(t,e,n){let r={...t},i=Ji(n),s=new Set((r[e]||[]).map(Ji));return s.has(i)?s.delete(i):s.add(i),s.size?r[e]=[...s]:delete r[e],r}function lw(t,e,n){let r={...t},i=Ji(n),s=(r[e]||[]).map(Ji).filter(o=>o!==i);return s.length?r[e]=s:delete r[e],r}var pM=de(Fr(),1);var vv=de(Wt(),1);function j1(t){return t.split(".").at(-1)||t}var Wc="\0__null__";function Hc(t){return t===Wc||t===""?"\u2014":t}function Pd(t,e={}){return zp(t,e)}function Vp(t,e){return e==="clickhouse"&&(t=t.replaceAll("\\","\\\\")),`'${t.replaceAll("'","''")}'`}function z1(t){if(t.mode==="contains")return`contains ${Vp(t.pattern??"")}`;let{values:e}=t,n=t.mode==="exclude"?"is not":"is";return e.length===0?n:e.length===1?`${n} ${Hc(e[0])}`:e.length<=2?`${n} ${e.map(Hc).join(", ")}`:`${n} ${e.length} values`}var at=de(Wt(),1),V1=de(jp(),1);function $1(t,e){let n=new Set;for(let r of t.joinablePairs??[])r.from===e&&n.add(r.to),r.to===e&&n.add(r.from);return t.graphMetrics.filter(r=>r.ownerModel?r.ownerModel===e||n.has(r.ownerModel):!0)}var W1=new Set(["second","minute","hour","day","week","month","quarter","year"]);function Qu(t){return t===void 0?[]:Array.isArray(t)?t:[t]}function Gu(t,e){return t.models.flatMap(n=>n.dimensions).find(n=>e===n.ref||e.startsWith(`${n.ref}__`))}function H1(t,e){let n=t.split("__").at(-1);return n&&W1.has(n)?n:e}function Y1(t){let e=t.defaults?.query;if(!e||typeof e!="object")return;let n=e,r=n.use_preaggregations??n.usePreaggregations;return typeof r=="boolean"?r:void 0}function K1(t,e){let n=t.defaults?.query,r=n&&typeof n=="object"?n:{},i=e.query.interaction_preaggregations??e.query.interactionPreaggregations??e.interaction_preaggregations??e.interactionPreaggregations??r.interaction_preaggregations??r.interactionPreaggregations;return typeof i=="boolean"?i:void 0}function Q1(t,e,n){if(!e?.tabs.length)return null;let r=e.tabs.find(g=>g.id===n)??e.tabs[0],i=r.charts[0];if(!i)return null;let s=Qu(i.query.dimensions),o=Qu(i.query.metrics),a=o.map(g=>t.graphMetrics.find(w=>w.ref===g)?.ownerModel).find(g=>!!g),l=o.find(g=>g.includes("."))?.split(".")[0]??a??s.find(g=>g.includes("."))?.split(".")[0],u=t.models.find(g=>g.name===l)??t.models[0];if(!u)return null;let c=[...t.models.flatMap(g=>g.metrics),...$1(t,u.name)],f=o.map(g=>c.find(w=>w.ref===g)).filter(g=>!!g),y=s.map(g=>Gu(t,g)).filter((g,w,D)=>!!g&&D.findIndex(B=>B?.ref===g?.ref)===w),v=i.encoding?.y,b=(Array.isArray(v)?v:v?[v]:[]).find(g=>f.some(w=>w.ref===g))??f[0]?.ref??u.metrics[0]?.ref??"",K=i.encoding?.x,h=(K&&Gu(t,K)?.type==="time"?K:void 0)??s.find(g=>Gu(t,g)?.type==="time"),d=u.defaultGrain??"month",m=h?Gu(t,h):u.timeDimension;return{id:r.id,label:r.label??r.id,title:i.title??e.title,model:u,metrics:f.length?f:u.metrics,dimensions:y.length?y:u.dimensions,timeDimension:m,selectedMetric:b,grain:h?H1(h,d):d,filters:Qu(i.query.filters),segments:Qu(i.query.segments),usePreaggregations:K1(e,i)??i.query.use_preaggregations??i.query.usePreaggregations??Y1(e)}}var G1=["second","minute","hour","day","week","month","quarter","year"];function X1(t){return t.toISOString().slice(0,10)}function Z1(t){return t.slice(0,10)}function J1(t){return new Date(`${Z1(t)}T00:00:00Z`)}function q1(t,e){let n=J1(t);return n.setUTCDate(n.getUTCDate()+e),X1(n)}function eI(t,e){return e.from.includes("T")||e.to.includes("T")?[`${t} >= cast('${e.from}' as timestamp)`,`${t} < cast('${e.to}' as timestamp)`]:[`${t} >= cast('${e.from}' as date)`,`${t} < cast('${q1(e.to,1)}' as date)`]}function tI(t){return t.mode==="contains"?!t.pattern:t.values.length===0}function nI(t){return Object.fromEntries(t.map(e=>[e.ref,e.type]))}function rI(t){return nI(t.models.flatMap(e=>e.dimensions))}function _v(t,e,n){if((e==="numeric"||e==="number")&&t.trim()!==""&&Number.isFinite(Number(t)))return t;if(e==="boolean"){let r=t.toLowerCase();if(r==="true"||r==="false")return r}return Vp(t,n)}function iI(t){return t.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_")}function uw(t,e,n){let r=Vp(`%${iI(e)}%`,n);return`CAST(${t} AS VARCHAR) ILIKE ${r}${n==="clickhouse"?"":" ESCAPE '\\'"}`}function sI(t,e,n,r){let i=e.mode==="exclude",s=e.values.includes(Wc),o=e.values.filter(l=>l!==Wc),a=null;if(o.length===1)a=`${t} ${i?"!=":"="} ${_v(o[0],n,r)}`;else if(o.length>1){let l=o.map(u=>_v(u,n,r)).join(", ");a=`${t} ${i?"NOT IN":"IN"} (${l})`}if(!i){let l=[];return a&&l.push(a),s&&l.push(`${t} IS NULL`),l.length===0?null:l.length===1?l[0]:`(${l.join(" OR ")})`}if(s){let l=[];return a&&l.push(a),l.push(`${t} IS NOT NULL`),l.length===1?l[0]:`(${l.join(" AND ")})`}return a?`(${a} OR ${t} IS NULL)`:null}function oI(t,e={}){let n=[];for(let[r,i]of Object.entries(t)){if(r===e.excludeDim||tI(i))continue;let s=e.types?.[r];if(i.mode==="contains"){n.push(uw(r,i.pattern??"",e.dialect));continue}let o=sI(r,i,s,e.dialect);o&&n.push(o)}return n}function aI(t,e={}){let n=oI(t,{types:e.types,excludeDim:e.excludeDim,dialect:e.dialect});return e.timeRef&&e.range&&n.push(...eI(e.timeRef,e.range)),n}function lI(t,e,n=50,r,i){return{dimensions:[t],filters:e,...r?.length?{segments:r}:{},...i!=null?{usePreaggregations:i}:{},orderBy:[`${t} ASC`],limit:n}}var cw=de(Wt(),1),mM=new Set(G1);var uI=cw.createContext(null);function cI(){let t=cw.useContext(uI);if(!t)throw new Error("useExplorer must be used within ExplorerProvider");return t}var jd=de(Wt(),1),yM=de(Wt(),1),Yc={active:0,listeners:new Set};function fw(){for(let t of Yc.listeners)t()}function fI(){Yc.active+=1,fw()}function dI(){Yc.active=Math.max(0,Yc.active-1),fw()}var hI=80;function pI(t,e){let[n,r]=jd.useState({loading:!1}),i=jd.useRef(0),s=e?JSON.stringify(e):null;return jd.useEffect(()=>{if(!e){r({loading:!1});return}let o=++i.current;r(l=>({result:l.result,resultKey:l.resultKey,loading:!0}));let a=setTimeout(()=>{fI(),t.runQuery(e).then(l=>{o===i.current&&r({result:l,resultKey:s??void 0,loading:!1})}).catch(l=>{o===i.current&&r({loading:!1,error:l instanceof Error?l.message:String(l)})}).finally(()=>dI())},hI);return()=>clearTimeout(a)},[s,t]),{...n,queryKey:s??void 0}}var mI=de(Wt(),1);function yI(t,e,n=!0){mI.useLayoutEffect(()=>{let r=t.current,i=e.current;if(!n||!r||!i)return;function s(){if(!r||!i)return;let l=i.getBoundingClientRect(),u=i.closest("[data-filter-strip]")?.getBoundingClientRect(),c=8,f=Math.max(c,Math.min(l.left,window.innerWidth-r.offsetWidth-c)),y=u?Math.max(u.top,Math.min(l.bottom,u.bottom)):l.bottom,v=Math.max(c,Math.min(y+4,window.innerHeight-c));r.style.left=`${f}px`,r.style.top=`${v}px`,r.style.setProperty("--filter-popover-height",`${Math.max(0,window.innerHeight-v-c)}px`)}s();let o=new ResizeObserver(s);o.observe(r),o.observe(i);let a=i.closest("[data-filter-strip]");return a&&o.observe(a),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{o.disconnect(),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}})}var Ae=de(Fr(),1),gI=[{mode:"include",label:"Include"},{mode:"exclude",label:"Exclude"},{mode:"contains",label:"Contains"}],vI=50,wv=200;function Sv(t,e){let[n,r]=at.useState(t);return at.useEffect(()=>{let i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function _I({dim:t,model:e,anchorRef:n,onClose:r}){let{state:i,dispatch:s,backend:o,catalog:a,dashboard:l}=cI(),u=at.useMemo(()=>Q1(a,l,i.dashboardTab),[a,l,i.dashboardTab]),c=i.filters[t.ref],[f,y]=at.useState(c?.mode??"include"),v=at.useMemo(()=>new Set(c?.mode!=="contains"?c?.values??[]:[]),[c]),_=at.useRef(null);yI(_,n);let b=at.useRef(null),K=at.useId(),[h,d]=at.useState(""),m=Sv(h,wv),g=c?.mode==="contains"?c.pattern??"":"",[w,D]=at.useState(g),B=Sv(w,wv);at.useEffect(()=>{let F=n.current;return b.current?.focus(),()=>F?.focus({preventScroll:!0})},[n]),at.useEffect(()=>{function F(ct){ct.key==="Escape"&&(ct.stopPropagation(),r())}function ie(ct){_.current&&!_.current.contains(ct.target)&&r()}return document.addEventListener("keydown",F,!0),document.addEventListener("mousedown",ie,!0),()=>{document.removeEventListener("keydown",F,!0),document.removeEventListener("mousedown",ie,!0)}},[r]),at.useEffect(()=>{f==="contains"&&B!==g&&s({type:"setFilterPattern",dim:t.ref,pattern:B})},[B,f,t.ref,s]);let S=a.models.find(F=>F.name===i.model)??e,Q=u?.timeDimension?.ref??S.timeDimension?.ref,L=at.useMemo(()=>rI(a),[a]),he=at.useMemo(()=>{let F=[...u?.filters??[],...aI(i.filters,{timeRef:Q,range:i.dateRange,excludeDim:t.ref,types:L,dialect:a.dialect})];return m.trim()&&F.push(uw(t.ref,m.trim(),a.dialect)),F},[u,i.filters,Q,i.dateRange,t.ref,m,L,a.dialect]),We=f!=="contains",{result:Se,loading:Te,error:Me}=pI(o,We?lI(t.ref,he,vI,u?.segments,u?.usePreaggregations):null),Le=j1(t.ref),Yn=at.useMemo(()=>Se?Se.rows.map(F=>{let ie=F[Le];return ie==null?Wc:String(ie)}):[],[Se,Le]),N=!!Se&&Se.rows.length>0&&!Se.columns.includes(Le),C=We&&(Te||N);function I(F){y(F),c&&s({type:"setFilterMode",dim:t.ref,mode:F}),F==="contains"&&D(g)}function M(F){if(F.key!=="Tab")return;let ie=_.current?.querySelectorAll('button, input, [href], select, textarea, [tabindex]:not([tabindex="-1"])');if(!ie||ie.length===0)return;let ct=ie[0],es=ie[ie.length-1];F.shiftKey&&document.activeElement===ct?(F.preventDefault(),es.focus()):!F.shiftKey&&document.activeElement===es&&(F.preventDefault(),ct.focus())}return V1.createPortal(Ae.jsxs("div",{ref:_,role:"dialog","aria-modal":"true","aria-labelledby":K,onKeyDown:M,className:"fixed z-30 max-h-[var(--filter-popover-height)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto border border-line bg-surface p-2 text-2xs shadow-lg",children:[Ae.jsxs("div",{id:K,className:"mb-2 flex items-baseline justify-between gap-2",children:[Ae.jsx("span",{className:"min-w-0 break-words font-semibold text-ink",children:t.label}),Ae.jsx("button",{type:"button","aria-label":"Close filter editor",onClick:r,className:"grid size-4 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),Ae.jsx("div",{role:"group","aria-label":"Filter mode",className:"mb-2 grid grid-cols-3 gap-px border border-line bg-line",children:gI.map(({mode:F,label:ie})=>Ae.jsx("button",{type:"button","aria-pressed":f===F,onClick:()=>I(F),className:`px-1.5 py-1 text-center ${f===F?"bg-accent-soft font-medium text-accent":"bg-surface text-muted hover:bg-surface-soft"}`,children:ie},F))}),f==="contains"?Ae.jsx("input",{ref:b,type:"text","aria-label":`${t.label} contains`,placeholder:"Substring\u2026",value:w,onChange:F=>D(F.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}):Ae.jsxs(Ae.Fragment,{children:[Ae.jsx("input",{ref:b,type:"text","aria-label":`Search ${t.label} values`,placeholder:"Search values\u2026",value:h,onChange:F=>d(F.target.value),className:"w-full border border-line bg-surface px-1.5 py-1 text-2xs text-ink placeholder:text-faint"}),Ae.jsx("div",{className:"mt-2 max-h-56 overflow-y-auto",role:"group","aria-label":`${t.label} values`,children:Me?Ae.jsx("p",{className:"px-1 py-2 text-danger",children:Me}):C?Ae.jsx("div",{className:"space-y-1.5 p-1",children:[0,1,2,3,4].map(F=>Ae.jsx("div",{className:"skeleton h-4 w-full"},F))}):Yn.length===0?Ae.jsx("p",{className:"px-1 py-2 text-faint",children:"No values"}):Yn.map(F=>{let ie=v.has(F);return Ae.jsxs("label",{className:"flex cursor-pointer items-center gap-2 px-1 py-1 hover:bg-surface-soft",children:[Ae.jsx("input",{type:"checkbox",checked:ie,onChange:()=>s({type:"toggleFilter",dim:t.ref,value:F,mode:f}),className:"size-3 shrink-0 accent-[var(--accent)]"}),Ae.jsx("span",{className:"min-w-0 break-words text-ink",children:Hc(F)})]},F)})})]}),Ae.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-line pt-2",children:[Ae.jsx("button",{type:"button",onClick:()=>s({type:"removeFilterDim",dim:t.ref}),className:"text-muted underline-offset-2 hover:text-ink hover:underline",children:"Clear"}),Ae.jsx("button",{type:"button",onClick:r,className:"border border-line px-2 py-1 text-muted hover:bg-surface-soft",children:"Done"})]})]}),document.body)}var Vn=de(Fr(),1);function bv(t){let[e,n]=vv.useState(!1),r=vv.useRef(null);if(!("dim"in t))return Vn.jsxs("span",{"data-dimension":t.dimension,"data-value":t.value,className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("span",{className:"truncate",children:[Vn.jsxs("span",{className:"text-faint",children:[t.dimensionLabel??t.dimension,":"]})," ",t.value]}),t.onRemove?Vn.jsx("button",{type:"button","aria-label":`Remove filter ${t.value}`,onClick:t.onRemove,className:"-mr-0.5 px-0.5 text-faint hover:text-ink",children:"\xD7"}):null]});let{dim:i,model:s,filter:o,onRemove:a}=t;return Vn.jsxs("span",{className:"relative inline-flex max-w-full items-center","data-dimension":i.ref,"data-mode":o.mode,children:[Vn.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-surface-soft px-2 py-0.5 text-2xs leading-4 text-muted",children:[Vn.jsxs("button",{ref:r,type:"button","aria-label":`Edit filter ${i.label}`,"aria-haspopup":"dialog","aria-expanded":e,onClick:()=>n(l=>!l),className:"min-w-0 truncate text-left hover:text-ink",children:[Vn.jsx("span",{className:"text-faint",children:i.label})," ",z1(o)]}),Vn.jsx("button",{type:"button","aria-label":`Remove filter ${i.label}`,onClick:a,className:"grid size-3.5 shrink-0 place-items-center rounded-full bg-surface-soft text-faint hover:bg-line hover:text-ink",children:"\xD7"})]}),e?Vn.jsx(_I,{dim:i,model:s,anchorRef:r,onClose:()=>n(!1)}):null]})}var Je=de(Fr(),1),wI={positive:"text-success",negative:"text-danger",neutral:"text-faint"};function SI({dimension:t,title:e,metricLabel:n,rows:r,selectedValues:i=[],loading:s,formatMetric:o,onToggle:a,contextColumn:l="none",contextOptions:u,onContextColumn:c,collapsedLimit:f=6,expanded:y=!1,onExpandedChange:v,containerRef:_}){let b=new Set(i),K=y?r:r.slice(0,f),h=Math.max(1,...K.map(w=>Math.abs(w.metric))),d=y||r.length>f,m=l!=="none",g=m?"grid-cols-[minmax(0,1fr)_auto_auto]":"grid-cols-[minmax(0,1fr)_auto]";return Je.jsxs("section",{ref:_,"data-testid":"dimension-leaderboard","data-dimension":t,"data-expanded":y||void 0,"aria-label":`${e}, ranked by ${n}`,className:"flex min-h-40 flex-col border-b border-r border-line bg-surface data-[expanded=true]:col-span-full",children:[Je.jsxs("header",{className:"flex items-center justify-between gap-3 px-3 pb-2 pt-2.5",children:[Je.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[Je.jsx("h3",{className:"truncate text-sm font-semibold text-ink",children:e}),Je.jsxs("p",{className:"sr-only",children:["Ranked by ",n]})]}),u&&c?Je.jsx("div",{role:"group","aria-label":"Context column","data-testid":"leaderboard-context-toggle",className:"flex shrink-0 overflow-hidden border border-line text-2xs",children:u.map(w=>Je.jsx("button",{type:"button",title:w.title,"aria-pressed":l===w.key,"data-context":w.key,"data-active":l===w.key||void 0,onClick:()=>c(w.key),className:"border-l border-line px-1.5 py-0.5 font-mono text-faint first:border-l-0 hover:bg-surface-soft data-[active=true]:bg-accent-soft data-[active=true]:text-accent",children:w.label},w.key))}):null]}),Je.jsx("div",{"data-testid":"leaderboard-rows",children:s&&r.length===0?Je.jsx("div",{className:"space-y-2 p-3",children:[0,1,2,3].map(w=>Je.jsx("div",{className:"skeleton h-5 w-full"},w))}):r.length===0?Je.jsx("p",{className:"px-3 py-4 text-xs text-faint",children:"No values"}):K.map(w=>{let D=w.metric<0?"negative":"positive",B=b.has(w.value),S=`${Math.round(Math.abs(w.metric)/h*100)}%`;return Je.jsxs("button",{type:"button","data-dimension":t,"data-value":w.value,"data-selected":B||void 0,"data-tone":D,onClick:()=>a?.(w.value),"aria-pressed":B,className:`leaderboard-row relative grid w-full ${g} items-center gap-3 overflow-hidden border-0 bg-transparent px-3 py-1 text-left text-xs text-ink data-[selected=true]:bg-chart-primary-selected`,children:[Je.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 ${D==="negative"?"bg-danger-soft":"bg-chart-primary-soft"}`,style:{width:S}}),Je.jsx("span",{className:"relative min-w-0 truncate text-muted",children:Hc(w.value)}),Je.jsx("strong",{className:"relative tnum font-semibold text-ink",children:o(w.metric)}),m?Je.jsx("span",{"data-testid":"leaderboard-context","data-tone":w.context?.tone??"neutral",className:`relative w-14 text-right font-mono tnum text-2xs ${wI[w.context?.tone??"neutral"]}`,children:w.context?.label??"\u2014"}):null]},`${t}:${w.value}`)})}),d&&!s?Je.jsx("button",{type:"button","data-action":y?"leaderboard-back":"leaderboard-expand","aria-expanded":y,onClick:()=>v?.(!y),className:"leaderboard-expand border-0 border-t border-line bg-transparent px-3 py-1 text-left text-xs font-normal text-faint hover:text-accent",children:y?"\u2190 All dimensions":`Expand table (${r.length})`}):null]})}var bI=de(Wt(),1),wr=de(Wt(),1),gM=de(Wt(),1),xI=de(Fr(),1);function II({tip:t,position:e="fixed",offset:n=12,className:r,style:i}){return t?xI.jsx("div",{role:"tooltip",style:{position:e,left:t.x+n,top:t.y+n,pointerEvents:"none",zIndex:50,...i},className:r||"rounded-lg border border-line bg-surface px-2.5 py-1.5 text-xs text-ink shadow-[var(--shadow)]",children:t.content}):null}var st=de(Fr(),1);function BI({values:t,labels:e,height:n=44,ariaLabel:r,formatValue:i=a=>a.toLocaleString(void 0,{maximumFractionDigits:2}),onHover:s,onBrush:o}){let a=wr.useRef(null),l=wr.useId(),u=wr.useRef(null),c=wr.useRef(null),[f,y]=wr.useState(200),[v,_]=wr.useState(null),[b,K]=wr.useState(null),[h,d]=wr.useState(null);wr.useEffect(()=>{let I=a.current;if(!I||typeof ResizeObserver>"u")return;let M=new ResizeObserver(F=>{for(let ie of F)y(Math.max(40,ie.contentRect.width))});return M.observe(I),()=>M.disconnect()},[]);let m=t.map((I,M)=>({index:M,value:I})).filter(I=>Number.isFinite(I.value));if(m.length<2)return st.jsx("svg",{ref:u,role:"img","aria-label":r||"No trend data",className:"h-11 w-full",viewBox:`0 0 ${f} ${n}`});let g=3,w=Math.min(...m.map(I=>I.value)),B=Math.max(...m.map(I=>I.value))-w||1,S=m.map((I,M)=>({...I,x:g+M/(m.length-1)*(f-g*2),y:g+(1-(I.value-w)/B)*(n-g*2)})),Q=S.map(({x:I,y:M})=>`${I.toFixed(1)},${M.toFixed(1)}`).join(" L "),L=`M ${S[0].x.toFixed(1)},${n-g} L ${Q} L ${S.at(-1).x.toFixed(1)},${n-g} Z`,he=S.at(-1),We=r||`Trend of ${m.length} points, latest ${i(he.value)}`;function Se(I){let M=u.current?.getBoundingClientRect();return M?Math.max(g,Math.min(f-g,(I.clientX-M.left)/M.width*f)):g}function Te(I){return Math.max(0,Math.min(S.length-1,Math.round((I-g)/(f-g*2)*(S.length-1))))}function Me(I){let M=Se(I),F=Te(M),ie=S[F];_(F),d({content:`${e?.[ie.index]?`${e[ie.index]}: `:""}${i(ie.value)}`,x:I.clientX,y:I.clientY}),s?.({index:ie.index,label:e?.[ie.index],value:ie.value}),c.current!==null&&K({a:c.current,b:M})}function Le(I){if(!o||!e?.length)return;I.currentTarget.setPointerCapture(I.pointerId);let M=Se(I);c.current=M,K({a:M,b:M})}function Yn(I){if(c.current===null||!o||!e?.length)return;I.currentTarget.hasPointerCapture(I.pointerId)&&I.currentTarget.releasePointerCapture(I.pointerId);let M=Se(I);if(Math.abs(M-c.current)>6){let F=S[Te(Math.min(c.current,M))],ie=S[Te(Math.max(c.current,M))];o({from:e[F.index],to:e[ie.index]})}c.current=null,K(null)}function N(){_(null),d(null),s?.(null),c.current===null&&K(null)}let C=v===null?null:S[v];return st.jsxs("span",{ref:a,className:"relative block w-full",children:[st.jsxs("svg",{ref:u,role:"img","aria-label":We,className:`h-11 w-full overflow-hidden text-chart-primary ${o?"touch-none select-none":""}`,viewBox:`0 0 ${f} ${n}`,preserveAspectRatio:"none",onPointerMove:Me,onPointerDown:Le,onPointerUp:Yn,onPointerCancel:N,onPointerLeave:N,onDoubleClick:()=>o?.(null),children:[st.jsx("defs",{children:st.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[st.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.16}),st.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]})}),st.jsx("path",{d:L,fill:`url(#${l})`}),st.jsx("path",{d:`M ${Q}`,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),b?st.jsx("rect",{x:Math.min(b.a,b.b),y:0,width:Math.abs(b.b-b.a),height:n,fill:"currentColor",opacity:.12}):null,C?st.jsxs(st.Fragment,{children:[st.jsx("line",{x1:C.x,x2:C.x,y1:0,y2:n,stroke:"currentColor",strokeWidth:1,opacity:.45}),st.jsx("circle",{cx:C.x,cy:C.y,r:2.5,fill:"currentColor"})]}):st.jsx("circle",{cx:he.x,cy:he.y,r:2.25,fill:"currentColor"})]}),st.jsx(II,{tip:h})]})}var ot=de(Fr(),1),DI={positive:"text-success",negative:"text-danger",neutral:"text-faint"},NI={positive:"\u25B2",negative:"\u25BC",neutral:"\xB7"};function TI({metric:t,label:e,value:n,valueText:r,format:i,delta:s,comparison:o,sparkValues:a=[],sparkLabels:l,selected:u,loading:c,onSelect:f,onSparkHover:y,onSparkBrush:v}){let[_,b]=bI.useState(null),K=ot.jsxs(ot.Fragment,{children:[ot.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[ot.jsx("span",{className:"truncate text-xs font-medium text-muted",children:e}),_?.label?ot.jsx("span",{className:"shrink-0 font-mono text-2xs text-faint",children:_.label}):null]}),ot.jsx("div",{className:"font-mono tnum text-[19px] font-semibold leading-tight tracking-tight text-ink",children:c?ot.jsx("span",{className:"skeleton inline-block h-6 w-24 align-middle"}):_?Pd(_.value,i):r??Pd(n,i)}),s||o?ot.jsxs("div",{className:"flex items-baseline gap-1 text-2xs",children:[s?ot.jsxs("span",{"data-tone":s.tone,className:`font-mono tnum font-medium ${DI[s.tone]}`,children:[ot.jsx("span",{"aria-hidden":"true",className:"mr-0.5 text-[8px]",children:NI[s.tone]}),s.label]}):null,o?ot.jsx("span",{className:"truncate text-faint",children:o}):null]}):null]}),h="group flex w-full flex-col gap-1.5 overflow-hidden rounded-xl border border-line bg-surface px-3.5 pt-3 text-left shadow-[var(--shadow-sm)] transition-colors hover:border-line-strong data-[selected=true]:border-accent",d=ot.jsx("div",{className:"-mx-3.5 mt-auto",children:ot.jsx(BI,{values:a,labels:l,onHover:m=>{b(m),y?.(m)},onBrush:v,formatValue:m=>Pd(m,i)})});return f?ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[ot.jsx("button",{type:"button","data-metric":t,"aria-pressed":!!u,onClick:()=>f(t),className:"-m-1 flex flex-col gap-1 border-0 bg-transparent p-1 text-left transition hover:opacity-75",children:K}),d]}):ot.jsxs("article",{"data-metric":t,"data-selected":u||void 0,className:h,children:[K,d]})}var vM=de(Fr(),1);var Xr=de(Fr(),1);function $p({tone:t,title:e,message:n}){let r=t==="danger";return Xr.jsx("div",{className:`grid min-h-[200px] place-items-center border bg-surface p-6 text-center ${r?"border-danger/40":"border-line"}`,"data-state":t,role:r?"alert":"status","aria-live":r?"assertive":"polite",children:Xr.jsxs("div",{className:"max-w-md",children:[t==="loading"?Xr.jsx("span",{"aria-hidden":"true",className:"motion-safe:animate-pulse inline-block size-2 rounded-full bg-accent"}):null,e?Xr.jsx("h3",{className:`text-sm font-semibold ${r?"text-danger":"text-ink"}`,children:e}):null,Xr.jsx("p",{className:`mt-1 text-xs ${r?"text-danger":"text-muted"}`,children:n})]})})}function OI({title:t="Loading",message:e="Loading metrics\u2026"}){return Xr.jsx($p,{tone:"loading",title:t,message:e})}function EI({title:t="No results",message:e}){return Xr.jsx($p,{tone:"muted",title:t,message:e})}function FI({title:t="Query failed",message:e}){return Xr.jsx($p,{tone:"danger",title:t,message:e})}var xv=new WeakMap;function uf(t,e){let n=xv.get(t);n||(t.replaceChildren(),n=R1.createRoot(t),xv.set(t,n)),P1.flushSync(()=>n.render(e))}function kI(t){return t.result?.sample_rows??t.result?.rows??[]}function zd(t,e=""){return t.output_aliases?.[e]??$c(e)}function dw(t,e){return typeof t=="function"?t(e):t}function AI(t={}){return{columns:t.columns??[],sample_rows:t.sample_rows??t.rows??[]}}function MI({dimensions:t=[],metrics:e=[],result:n,outputAliases:r}={}){return{dimensions:t,metrics:e,output_aliases:r,result:AI(n)}}function hw(t,e={}){let n=e.totals?.rows?.[0]??{},r=e.seriesRows??[];uf(t,qt.createElement(qt.Fragment,null,...(e.metrics??[]).map(i=>{let s=i.key,o=$c(s);return qt.createElement(TI,{key:s,metric:s,label:i.label??o.replaceAll("_"," "),value:n[o],format:dw(e.valueFormat,s),selected:e.selectedMetric===s,sparkValues:r.map(a=>Number(a[o])||0),sparkLabels:r.map(a=>String(a[e.timeKey]??"")),onSparkBrush:e.onBrush?a=>e.onBrush(a?.from??null,a?.to??null):void 0,onSelect:e.onSelect?()=>e.onSelect({metric:s,key:o,value:n[o]}):void 0})})))}function Wp(t,e,n={}){let r=t.__sdmExpandedDim,i=r?e.filter(s=>(s.key??s)===r):e;uf(t,qt.createElement(qt.Fragment,null,...i.map(s=>{let o=s.key??s,a=n.resultForDimension?.(s)??{rows:[]},l=MI({dimensions:[o],metrics:[n.metricRef],result:a}),u=kI(l),c=r===o;return qt.createElement(SI,{key:o,dimension:o,title:s.label??$c(o).replaceAll("_"," "),metricLabel:n.metricLabel?.(s)??n.metricName??$c(n.metricRef),rows:u.map(f=>({value:Ji(f[zd(l,o)]),metric:Number(f[zd(l,n.metricRef)])||0})),selectedValues:n.selectedValuesForDimension?.(s)??[],collapsedLimit:n.limit??6,expanded:c,formatMetric:f=>zp(f,dw(n.valueFormat,{metric:n.metricRef,value:f})),onToggle:n.onSelect?f=>n.onSelect({dimension:o,value:f,row:u.find(y=>Ji(y[zd(l,o)])===f)}):void 0,onExpandedChange:n.expandable===!1?void 0:f=>{t.__sdmExpandedDim=f?o:void 0,Wp(t,e,n)}})})))}function pw(t,e,n,r={}){let i=Object.entries(e??{}).flatMap(([s,o])=>(o??[]).map(a=>{let l=Ji(a);return qt.createElement(bv,{key:`${s}:${l}`,dimension:s,value:l,onRemove:n?()=>n({dimension:s,value:l}):void 0})}));for(let s of r.extraPills??[])i.push(qt.createElement(bv,{key:s.key??`${s.dimension}:${s.value}`,dimension:s.dimension,dimensionLabel:s.dimensionLabel,value:s.value,onRemove:s.onRemove}));uf(t,i.length?qt.createElement(qt.Fragment,null,...i):r.emptyLabel?qt.createElement("span",{className:"text-faint"},r.emptyLabel):null)}function mw(t,e){let n=e.kind==="error"?FI:e.kind==="loading"?OI:EI;uf(t,qt.createElement(n,{message:e.message}))}function Hp(t){if(!t)return"";if(typeof t=="string")return t.slice(0,10);if(t instanceof Date)return t.toISOString().slice(0,10);if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e).toISOString().slice(0,10):e>1e9?new Date(e*1e3).toISOString().slice(0,10):new Date(e*864e5).toISOString().slice(0,10)}return String(t).slice(0,10)}function yw(t){if(!t)return null;if(t instanceof Date)return t;if(typeof t=="number"||typeof t=="bigint"){let e=typeof t=="bigint"?Number(t):t;return e>1e12?new Date(e):e>1e9?new Date(e*1e3):new Date(e*864e5)}if(typeof t=="string"){let e=t.match(/^\d{4}-\d{2}-\d{2}/);if(e)return new Date(`${e[0]}T00:00:00Z`);let n=new Date(t);if(!Number.isNaN(n.getTime()))return n}return null}function gw(t,e){return t.toLocaleDateString("en-US",{timeZone:"UTC",...e})}function vw(t,e){let n=yw(t),r=yw(e);if(!n||!r){let a=Hp(t),l=Hp(e);return!a&&!l?"":a&&l?`${a} \u2013 ${l}`:a||l}let i=n.getFullYear()===r.getFullYear(),s=gw(n,{month:"short",day:"numeric",year:i?void 0:"numeric"}),o=gw(r,{month:"short",day:"numeric",year:"numeric"});return`${s} \u2013 ${o}`}function LI(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r
@@ -37,4 +37,4 @@ Error generating stack: `+s.message+`
- `;let n=e.querySelector(".filter-pills"),r=e.querySelector(".metrics-col"),i=e.querySelector(".dimensions-grid"),s=e.querySelector(".metric-select"),o=e.querySelector(".grain-select"),a=e.querySelector(".widget-status"),l=null;function u(){return t.get("filters")||{}}function c(S){t.set("filters",S),t.save_changes()}function d(){l&&clearTimeout(l),l=setTimeout(()=>{t.set("active_dimension",""),t.save_changes()},400)}function y(){l&&(clearTimeout(l),l=null),t.set("active_dimension","")}function v(S,K){t.set("active_dimension",S),c(ow(u(),S,K)),d()}function w(S,K){y(),c(aw(u(),S,K))}function I(S,K){S&&K?(y(),t.set("brush_selection",[S,K])):t.set("brush_selection",[]),t.save_changes()}function Y(){y(),t.set("brush_selection",[]),t.save_changes()}function h(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"",L=t.get("date_range")||[],ue=t.get("brush_selection")||[],Te=ue&&ue.length===2?ue:L,Re=t.get("metric_totals")||{},ke=(t.get("transport")||"base64")==="binary"?t.get("metric_series_data_binary"):t.get("metric_series_data");if(!ke||ke.byteLength!==void 0&&ke.byteLength===0){pw(r,{kind:"loading",message:"Loading metrics\u2026"});return}try{let Pe=vw(ke);if(!Pe){r.innerHTML='
Failed to parse data
';return}let M=(t.get("config")||{}).time_series_column||Object.keys(Pe[0]||{}).find(b=>b.includes("time")||b.includes("date")||b==="__time"),B=M?Pe.map(b=>Wp(b[M])):[];dw(r,{metrics:S,totals:{rows:[Re]},seriesRows:Pe,timeKey:M,selectedMetric:K,rangeLabel:Te?.length===2?gw(Te[0],Te[1]):"",valueFormat:b=>({format:S.find(X=>X.key===b)?.format}),onSelect:({metric:b})=>{t.set("selected_metric",b),t.save_changes()},onBrush:I})}catch(Pe){r.innerHTML=`
Error: ${Pe.message}
`}}function f(){let S=t.get("dimensions_config")||[],L=(t.get("transport")||"base64")==="binary"?t.get("dimension_data_binary")||{}:t.get("dimension_data")||{},ue=t.get("selected_metric")||"",Te=u(),Re=new Map;S.forEach(Ie=>{let ke=L[Ie.key];if(!ke||(typeof ke=="string"?ke.length===0:ke.byteLength===0)){Re.set(Ie.key,[]);return}try{let Pe=vw(ke);if(!Pe){Re.set(Ie.key,[]);return}Re.set(Ie.key,Pe)}catch{Re.set(Ie.key,[])}}),$p(i,S,{metricRef:ue,resultForDimension:Ie=>({rows:Re.get(Ie.key)||[]}),selectedValuesForDimension:Ie=>Te[Ie.key]||[],interactive:!0,expandable:!0,onSelect:({dimension:Ie,value:ke})=>v(Ie,ke)})}function m(){let S=u(),K=t.get("brush_selection")||[];hw(n,S,({dimension:L,value:ue})=>w(L,ue),{emptyLabel:"No filters",extraPills:K.length===2?[{key:"active-date-range",dimension:"__date_range",dimensionLabel:"Date",value:gw(K[0],K[1]),onRemove:Y}]:[]})}function g(){let S=t.get("metrics_config")||[],K=t.get("selected_metric")||"";s.innerHTML=S.map(L=>``).join("")}function _(){let S=t.get("time_grain_options")||[],K=t.get("time_grain")||"";if(!S.length){o.innerHTML="",o.disabled=!0;return}o.disabled=!1,o.innerHTML=S.map(L=>{let ue=L.replace(/_/g," ").replace(/\b\w/g,Te=>Te.toUpperCase());return``}).join("")}function D(){let S=t.get("status")||"loading",K=t.get("error")||"";S==="error"&&K?(a.textContent=`Error: ${K}`,a.className="widget-status error"):S==="loading"?(a.textContent="Loading...",a.className="widget-status loading"):(a.textContent="",a.className="widget-status")}function N(){D(),m(),g(),_(),h(),f()}return s.addEventListener("change",S=>{y(),t.set("selected_metric",S.target.value),t.save_changes()}),o.addEventListener("change",S=>{t.set("time_grain",S.target.value),t.save_changes()}),t.on("change:metric_series_data",h),t.on("change:metric_totals",h),t.on("change:dimension_data",f),t.on("change:filters",()=>{m(),f()}),t.on("change:brush_selection",m),t.on("change:selected_metric",()=>{g(),h()}),t.on("change:time_grain",_),t.on("change:status",D),t.on("change:error",D),t.on("change:metrics_config",N),t.on("change:dimensions_config",N),t.on("change:time_grain_options",_),N(),()=>{t.off("change:metric_series_data",h),t.off("change:metric_totals",h),t.off("change:dimension_data",f),t.off("change:filters"),t.off("change:brush_selection",m),t.off("change:selected_metric"),t.off("change:time_grain",_),t.off("change:status",D),t.off("change:error",D),t.off("change:metrics_config",N),t.off("change:dimensions_config",N),t.off("change:time_grain_options",_)}}var SL={render:MI};export{SL as default}; + `;let n=e.querySelector(".filter-pills"),r=e.querySelector(".metrics-col"),i=e.querySelector(".dimensions-grid"),s=e.querySelector(".metric-select"),o=e.querySelector(".grain-select"),a=e.querySelector(".widget-status"),l=null;function u(){return t.get("filters")||{}}function c(S){t.set("filters",S),t.save_changes()}function f(){l&&clearTimeout(l),l=setTimeout(()=>{t.set("active_dimension",""),t.save_changes()},400)}function y(){l&&(clearTimeout(l),l=null),t.set("active_dimension","")}function v(S,Q){t.set("active_dimension",S),c(aw(u(),S,Q)),f()}function _(S,Q){y(),c(lw(u(),S,Q))}function b(S,Q){S&&Q?(y(),t.set("brush_selection",[S,Q])):t.set("brush_selection",[]),t.save_changes()}function K(){y(),t.set("brush_selection",[]),t.save_changes()}function h(){let S=t.get("metrics_config")||[],Q=t.get("selected_metric")||"",L=t.get("date_range")||[],he=t.get("brush_selection")||[],We=he&&he.length===2?he:L,Se=t.get("metric_totals")||{},Me=(t.get("transport")||"base64")==="binary"?t.get("metric_series_data_binary"):t.get("metric_series_data");if(!Me||Me.byteLength!==void 0&&Me.byteLength===0){mw(r,{kind:"loading",message:"Loading metrics\u2026"});return}try{let Le=_w(Me);if(!Le){r.innerHTML='
Failed to parse data
';return}let C=(t.get("config")||{}).time_series_column||Object.keys(Le[0]||{}).find(M=>M.includes("time")||M.includes("date")||M==="__time"),I=C?Le.map(M=>Hp(M[C])):[];hw(r,{metrics:S,totals:{rows:[Se]},seriesRows:Le,timeKey:C,selectedMetric:Q,rangeLabel:We?.length===2?vw(We[0],We[1]):"",valueFormat:M=>({format:S.find(F=>F.key===M)?.format}),onSelect:({metric:M})=>{t.set("selected_metric",M),t.save_changes()},onBrush:b})}catch(Le){r.innerHTML=`
Error: ${Le.message}
`}}function d(){let S=t.get("dimensions_config")||[],L=(t.get("transport")||"base64")==="binary"?t.get("dimension_data_binary")||{}:t.get("dimension_data")||{},he=t.get("selected_metric")||"",We=u(),Se=new Map;S.forEach(Te=>{let Me=L[Te.key];if(!Me||(typeof Me=="string"?Me.length===0:Me.byteLength===0)){Se.set(Te.key,[]);return}try{let Le=_w(Me);if(!Le){Se.set(Te.key,[]);return}Se.set(Te.key,Le)}catch{Se.set(Te.key,[])}}),Wp(i,S,{metricRef:he,resultForDimension:Te=>({rows:Se.get(Te.key)||[]}),selectedValuesForDimension:Te=>We[Te.key]||[],interactive:!0,expandable:!0,onSelect:({dimension:Te,value:Me})=>v(Te,Me)})}function m(){let S=u(),Q=t.get("brush_selection")||[];pw(n,S,({dimension:L,value:he})=>_(L,he),{emptyLabel:"No filters",extraPills:Q.length===2?[{key:"active-date-range",dimension:"__date_range",dimensionLabel:"Date",value:vw(Q[0],Q[1]),onRemove:K}]:[]})}function g(){let S=t.get("metrics_config")||[],Q=t.get("selected_metric")||"";s.innerHTML=S.map(L=>``).join("")}function w(){let S=t.get("time_grain_options")||[],Q=t.get("time_grain")||"";if(!S.length){o.innerHTML="",o.disabled=!0;return}o.disabled=!1,o.innerHTML=S.map(L=>{let he=L.replace(/_/g," ").replace(/\b\w/g,We=>We.toUpperCase());return``}).join("")}function D(){let S=t.get("status")||"loading",Q=t.get("error")||"";S==="error"&&Q?(a.textContent=`Error: ${Q}`,a.className="widget-status error"):S==="loading"?(a.textContent="Loading...",a.className="widget-status loading"):(a.textContent="",a.className="widget-status")}function B(){D(),m(),g(),w(),h(),d()}return s.addEventListener("change",S=>{y(),t.set("selected_metric",S.target.value),t.save_changes()}),o.addEventListener("change",S=>{t.set("time_grain",S.target.value),t.save_changes()}),t.on("change:metric_series_data",h),t.on("change:metric_totals",h),t.on("change:dimension_data",d),t.on("change:filters",()=>{m(),d()}),t.on("change:brush_selection",m),t.on("change:selected_metric",()=>{g(),h()}),t.on("change:time_grain",w),t.on("change:status",D),t.on("change:error",D),t.on("change:metrics_config",B),t.on("change:dimensions_config",B),t.on("change:time_grain_options",w),B(),()=>{t.off("change:metric_series_data",h),t.off("change:metric_totals",h),t.off("change:dimension_data",d),t.off("change:filters"),t.off("change:brush_selection",m),t.off("change:selected_metric"),t.off("change:time_grain",w),t.off("change:status",D),t.off("change:error",D),t.off("change:metrics_config",B),t.off("change:dimensions_config",B),t.off("change:time_grain_options",w)}}var bM={render:CI};export{bM as default}; diff --git a/webapp/src/components/AddFilter.tsx b/webapp/src/components/AddFilter.tsx index 44bd1b1d3..aa2a53c2a 100644 --- a/webapp/src/components/AddFilter.tsx +++ b/webapp/src/components/AddFilter.tsx @@ -1,4 +1,5 @@ import { useEffect, useRef, useState } from "react"; +import { createPortal } from "react-dom"; import type { CatalogDimension, CatalogModel } from "../data/types"; import { joinedDimensionsForModel } from "../lib/catalog"; import { useExplorer } from "../state/ExplorerContext"; @@ -14,17 +15,21 @@ export function AddFilter({ model }: { model: CatalogModel }) { const [picked, setPicked] = useState(null); const rootRef = useRef(null); const menuRef = useRef(null); - useFilterPopover(menuRef, open && !picked); + const buttonRef = useRef(null); + useFilterPopover(menuRef, buttonRef, open && !picked); useEffect(() => { if (!open) return; function onKey(event: KeyboardEvent) { - if (event.key === "Escape") close(); + if (event.key === "Escape") { + close(); + buttonRef.current?.focus({ preventScroll: true }); + } } function onPointer(event: MouseEvent) { // The editor's own outside-click handler covers the picked state; only the menu needs this. if (picked) return; - if (rootRef.current && !rootRef.current.contains(event.target as Node)) close(); + if (!rootRef.current?.contains(event.target as Node) && !menuRef.current?.contains(event.target as Node)) close(); } document.addEventListener("keydown", onKey, true); document.addEventListener("mousedown", onPointer, true); @@ -44,6 +49,7 @@ export function AddFilter({ model }: { model: CatalogModel }) { return ( - {open && !picked ? ( + {open && !picked ? createPortal(
{dims.map((dim) => (
+
, + document.body, ) : null} - {open && picked ? : null} + {open && picked ? : null} ); } diff --git a/webapp/src/components/AppShell.tsx b/webapp/src/components/AppShell.tsx index 82da5ad83..d1314bada 100644 --- a/webapp/src/components/AppShell.tsx +++ b/webapp/src/components/AppShell.tsx @@ -102,8 +102,8 @@ export function AppShell({ brand, toolbar, filters, rail, children, drawer, show {filters ? ( - // Wrap crowded filters and keep their popovers above the stage without clipping them. -
+ // Keep the stage available with many filters; popovers render outside this scroll clip. +
{filters}
) : null} diff --git a/webapp/src/components/FilterEditor.tsx b/webapp/src/components/FilterEditor.tsx index c89f057fd..2d8f3098c 100644 --- a/webapp/src/components/FilterEditor.tsx +++ b/webapp/src/components/FilterEditor.tsx @@ -1,4 +1,5 @@ -import { useEffect, useId, useMemo, useRef, useState } from "react"; +import { useEffect, useId, useMemo, useRef, useState, type RefObject } from "react"; +import { createPortal } from "react-dom"; import { aliasOf, NULL_TOKEN, type CatalogDimension, type CatalogModel } from "../data/types"; import { displayDimValue } from "../lib/format"; import { dashboardTabConfig } from "../lib/dashboard"; @@ -37,10 +38,12 @@ function useDebounced(value: T, delayMs: number): T { export function FilterEditor({ dim, model, + anchorRef, onClose, }: { dim: CatalogDimension; model: CatalogModel; + anchorRef: RefObject; onClose: () => void; }) { const { state, dispatch, backend, catalog, dashboard } = useExplorer(); @@ -56,7 +59,7 @@ export function FilterEditor({ const selected = useMemo(() => new Set(filter?.mode !== "contains" ? (filter?.values ?? []) : []), [filter]); const panelRef = useRef(null); - useFilterPopover(panelRef); + useFilterPopover(panelRef, anchorRef); const searchRef = useRef(null); const labelId = useId(); @@ -69,10 +72,10 @@ export function FilterEditor({ // Focus the search box on open; restore focus to the opener when the popover unmounts. useEffect(() => { - const opener = document.activeElement as HTMLElement | null; + const opener = anchorRef.current; searchRef.current?.focus(); - return () => opener?.focus?.(); - }, []); + return () => opener?.focus({ preventScroll: true }); + }, [anchorRef]); // Escape closes; outside pointer/click closes. Focus is trapped to the panel via onKeyDown below. useEffect(() => { @@ -164,14 +167,14 @@ export function FilterEditor({ } } - return ( + return createPortal(
{dim.label} @@ -273,6 +276,7 @@ export function FilterEditor({ Done
-
+
, + document.body, ); } diff --git a/webapp/src/components/FilterPill.tsx b/webapp/src/components/FilterPill.tsx index 3e0027a22..08dffbc65 100644 --- a/webapp/src/components/FilterPill.tsx +++ b/webapp/src/components/FilterPill.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useRef, useState } from "react"; import type { CatalogDimension, CatalogModel } from "../data/types"; import { filterSummary } from "../lib/format"; import type { DimFilter } from "../lib/queries"; @@ -24,6 +24,7 @@ type FilterPillProps = EditableFilterPillProps | PortableFilterPillProps; * US", "name contains 'acme'"). Clicking the label opens the editor popover; the × clears it. */ export function FilterPill(props: FilterPillProps) { const [open, setOpen] = useState(false); + const buttonRef = useRef(null); if (!("dim" in props)) { return ( @@ -42,6 +43,7 @@ export function FilterPill(props: FilterPillProps) {