@malloy-publisher/sdk 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/{DocumentStorage-BiFqO15i.es.js → DocumentStorage-DkwqA8SA.es.js} +2284 -2319
  2. package/dist/{DocumentStorage-CMyLifsz.cjs.js → DocumentStorage-mMn5SZ1c.cjs.js} +29 -29
  3. package/dist/{RenderedResult-CvrmYyr5.es.js → RenderedResult-CTD2Ej2S.es.js} +100 -80
  4. package/dist/{RenderedResult-CZzE8wv-.cjs.js → RenderedResult-GukOadCi.cjs.js} +27 -7
  5. package/dist/ServerProvider-CC9ein5-.cjs.js +1 -0
  6. package/dist/{ServerProvider-BWOEKg0O.es.js → ServerProvider-IzXlqSVe.es.js} +572 -553
  7. package/dist/builder/index.cjs.js +54 -49
  8. package/dist/builder/index.es.js +4124 -3521
  9. package/dist/client/api.d.ts +54 -2
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.es.js +1 -1
  12. package/dist/components/Dashboard/TileCard.d.ts +7 -3
  13. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +15 -4
  14. package/dist/components/DashboardBuilder/controls.d.ts +8 -6
  15. package/dist/components/DashboardBuilder/document.d.ts +19 -5
  16. package/dist/components/DashboardBuilder/malloyText.d.ts +0 -30
  17. package/dist/components/DashboardBuilder/malloyTree.d.ts +232 -0
  18. package/dist/components/DashboardBuilder/preview.d.ts +17 -0
  19. package/dist/components/DashboardBuilder/readDocument.d.ts +23 -28
  20. package/dist/components/DashboardBuilder/spliceDocument.d.ts +12 -0
  21. package/dist/index.cjs.js +1 -1
  22. package/dist/index.es.js +5 -5
  23. package/dist/theme/resolveTheme.d.ts +1 -1
  24. package/dist/theme/types.d.ts +12 -2
  25. package/package.json +1 -1
  26. package/src/components/Dashboard/TileCard.tsx +8 -4
  27. package/src/components/DashboardBuilder/BuilderToolbar.tsx +4 -5
  28. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +356 -0
  29. package/src/components/DashboardBuilder/DashboardEditor.tsx +116 -25
  30. package/src/components/DashboardBuilder/FilterDialog.tsx +19 -6
  31. package/src/components/DashboardBuilder/TileFrame.tsx +11 -2
  32. package/src/components/DashboardBuilder/TileMenu.tsx +6 -0
  33. package/src/components/DashboardBuilder/__test__/inventory.ts +367 -0
  34. package/src/components/DashboardBuilder/controls.spec.ts +53 -3
  35. package/src/components/DashboardBuilder/controls.ts +9 -7
  36. package/src/components/DashboardBuilder/document.ts +17 -5
  37. package/src/components/DashboardBuilder/invariants.spec.ts +297 -0
  38. package/src/components/DashboardBuilder/malloyText.spec.ts +27 -66
  39. package/src/components/DashboardBuilder/malloyText.ts +4 -109
  40. package/src/components/DashboardBuilder/malloyTree.spec.ts +362 -0
  41. package/src/components/DashboardBuilder/malloyTree.ts +954 -0
  42. package/src/components/DashboardBuilder/preview.spec.ts +18 -0
  43. package/src/components/DashboardBuilder/preview.ts +24 -6
  44. package/src/components/DashboardBuilder/readDocument.spec.ts +312 -21
  45. package/src/components/DashboardBuilder/readDocument.ts +144 -165
  46. package/src/components/DashboardBuilder/scannerShapes.spec.ts +550 -0
  47. package/src/components/DashboardBuilder/spliceDocument.spec.ts +955 -21
  48. package/src/components/DashboardBuilder/spliceDocument.ts +509 -119
  49. package/src/components/DashboardBuilder/statementExtent.spec.ts +606 -0
  50. package/src/components/RenderedResult/RenderedResult.tsx +21 -1
  51. package/src/components/given/GivensPanel.tsx +15 -3
  52. package/src/theme/buildTableCssVars.spec.ts +3 -0
  53. package/src/theme/buildTableCssVars.ts +6 -0
  54. package/src/theme/defaults.ts +16 -12
  55. package/src/theme/resolveTheme.spec.ts +14 -7
  56. package/src/theme/resolveTheme.ts +14 -8
  57. package/src/theme/types.ts +12 -2
  58. package/tsconfig.spec.json +5 -1
  59. package/dist/ServerProvider-Cc489A3f.cjs.js +0 -1
@@ -1,9 +1,9 @@
1
- import { jsx as L } from "react/jsx-runtime";
1
+ import { jsx as I } from "react/jsx-runtime";
2
2
  import { Box as oe, useTheme as ce } from "@mui/material";
3
- import { Suspense as ue, useRef as z, useCallback as he, useMemo as me, useEffect as fe, useLayoutEffect as be } from "react";
4
- import { D as ye, r as K, b as pe, a as ve, m as ge, c as we, d as ae } from "./DocumentStorage-BiFqO15i.es.js";
5
- import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-BWOEKg0O.es.js";
6
- const v = "publisher-drill";
3
+ import { Suspense as ue, useRef as z, useCallback as he, useMemo as me, useEffect as be, useLayoutEffect as fe } from "react";
4
+ import { D as ye, r as K, b as pe, a as ge, m as ve, c as we, d as ae } from "./DocumentStorage-DkwqA8SA.es.js";
5
+ import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-IzXlqSVe.es.js";
6
+ const g = "publisher-drill";
7
7
  function Re(e, r) {
8
8
  const t = /* @__PURE__ */ new Set();
9
9
  let a;
@@ -22,7 +22,7 @@ function Re(e, r) {
22
22
  }
23
23
  return t;
24
24
  }
25
- function B(e) {
25
+ function L(e) {
26
26
  const r = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
27
  return r ? r[1] : void 0;
28
28
  }
@@ -36,25 +36,25 @@ function Ee(e, r) {
36
36
  ".column-cell.th"
37
37
  )) {
38
38
  if (!a(l)) continue;
39
- const s = (l.textContent ?? "").replace(/\u200b/g, "").trim(), y = B(l);
39
+ const s = (l.textContent ?? "").replace(/\u200b/g, "").trim(), y = L(l);
40
40
  y && r.has(s) && n.add(y);
41
41
  }
42
42
  if (n.size === 0) continue;
43
43
  const o = /* @__PURE__ */ new Set();
44
44
  for (const l of t.querySelectorAll(
45
- `.${v}[tabindex="0"]`
45
+ `.${g}[tabindex="0"]`
46
46
  )) {
47
47
  if (!a(l)) continue;
48
- const s = B(l);
48
+ const s = L(l);
49
49
  s && (o.has(s) ? l.tabIndex = -1 : o.add(s));
50
50
  }
51
51
  for (const l of t.querySelectorAll(
52
52
  ".column-cell.td"
53
53
  )) {
54
54
  if (!a(l)) continue;
55
- const s = B(l), y = !l.querySelector(".value-null") && (l.textContent ?? "").trim() !== "";
55
+ const s = L(l), y = !l.querySelector(".value-null") && (l.textContent ?? "").trim() !== "";
56
56
  if (s && y && n.has(s) && !l.querySelector(".malloy-table")) {
57
- if (l.classList.add(v), l.tabIndex === 0)
57
+ if (l.classList.add(g), l.tabIndex === 0)
58
58
  o.add(s);
59
59
  else {
60
60
  const h = o.has(s);
@@ -66,11 +66,11 @@ function Ee(e, r) {
66
66
  }
67
67
  }
68
68
  function Se(e) {
69
- const r = e.closest(".malloy-table"), t = B(e);
69
+ const r = e.closest(".malloy-table"), t = L(e);
70
70
  return !r || !t ? [] : Array.from(
71
- r.querySelectorAll(`.${v}`)
71
+ r.querySelectorAll(`.${g}`)
72
72
  ).filter(
73
- (a) => a.closest(".malloy-table") === r && B(a) === t
73
+ (a) => a.closest(".malloy-table") === r && L(a) === t
74
74
  );
75
75
  }
76
76
  function ne(e, r) {
@@ -140,8 +140,8 @@ function Oe(e) {
140
140
  for (const s of ke) {
141
141
  const y = a.tag(s);
142
142
  if (!y) continue;
143
- const h = {}, g = y.text("light"), x = y.text("dark");
144
- g && (h.light = g), x && (h.dark = x), Object.keys(h).length > 0 && (o[s] = h);
143
+ const h = {}, v = y.text("light"), x = y.text("dark");
144
+ v && (h.light = v), x && (h.dark = x), Object.keys(h).length > 0 && (o[s] = h);
145
145
  }
146
146
  Object.keys(o).length > 0 && (t.palette = o);
147
147
  }
@@ -154,7 +154,7 @@ function Oe(e) {
154
154
  }
155
155
  return Object.keys(t).length > 0 ? t : void 0;
156
156
  }
157
- const Fe = async (e, r) => {
157
+ const Te = async (e, r) => {
158
158
  if (typeof window > "u")
159
159
  throw new Error("MalloyRenderer can only be used in browser environment");
160
160
  const { MalloyRenderer: t } = await import("@malloydata/render");
@@ -173,7 +173,7 @@ const Fe = async (e, r) => {
173
173
  }).createViz();
174
174
  };
175
175
  typeof window < "u" && import("@malloydata/render");
176
- async function Te(e) {
176
+ async function Fe(e) {
177
177
  if (!e || typeof e != "object") return;
178
178
  const r = e, t = [
179
179
  ...Array.isArray(r.model_annotations) ? r.model_annotations : [],
@@ -263,7 +263,27 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
263
263
  background: var(--malloy-render--tile-background) !important;
264
264
  color: var(--malloy-render--table-body-color) !important;
265
265
  box-shadow: none !important;
266
- border: var(--malloy-render--table-border) !important;
266
+ /* The card edge, not the table gridline: --publisher-dashboard-card-border,
267
+ the same value TileCard paints, so the renderer's card and the composite
268
+ one are outlined identically. */
269
+ border: var(--publisher-dashboard-card-border) !important;
270
+ }
271
+ /* The renderer's big-value card — the small card a "# big_value" measure sits
272
+ in, several to a row inside one tile. (No backticks in here: this is inside
273
+ a template literal.) Its own CSS gives it a 0.55px edge in
274
+ #e5e7eb: a sub-pixel width, and a grey off the slate ramp everything else on
275
+ the page is on. It is a dashboard card like any other, so it takes the card
276
+ edge and stops being the one card outlined in a hairline nobody can see. */
277
+ .malloy-render .malloy-big-value-card {
278
+ border: var(--publisher-dashboard-card-border) !important;
279
+ /* Its shadow is a four-layer Tailwind stack, and only two of those layers
280
+ are a shadow: the other is "0 0 0 1px #e5e7eb", a spread ring drawn as a
281
+ second border OVER the real one. So the border above was landing
282
+ underneath a ring in the renderer's own grey, and the card kept both a
283
+ lifted look the flat cards around it do not have and an edge we did not
284
+ pick. Dropped whole rather than rebuilt layer by layer: the ring's job is
285
+ the border's job, and the border is already doing it. */
286
+ box-shadow: none !important;
267
287
  }
268
288
  .malloy-render .malloy-dashboard .dashboard-row-header-separator {
269
289
  background: var(--malloy-render--table-border) !important;
@@ -298,10 +318,10 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
298
318
  and the only thing that tells a reader a cell navigates. Kept off the
299
319
  resting state deliberately: a column painted blue competes with the data.
300
320
  (No backticks in here: this is inside a template literal.) */
301
- .malloy-render .${v} {
321
+ .malloy-render .${g} {
302
322
  cursor: pointer;
303
323
  }
304
- .malloy-render .${v}:hover > .cell-content {
324
+ .malloy-render .${g}:hover > .cell-content {
305
325
  color: var(--publisher-drill-link) !important;
306
326
  text-decoration: underline;
307
327
  }
@@ -309,21 +329,21 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
309
329
  something a keyboard user can produce, and a focus ring is not something a
310
330
  mouse user sees. focus-visible rather than focus, so a click does not leave a
311
331
  ring behind it. (No backticks in here: this is inside a template literal.) */
312
- .malloy-render .${v}:focus-visible {
332
+ .malloy-render .${g}:focus-visible {
313
333
  outline: 2px solid var(--publisher-drill-link);
314
334
  outline-offset: -2px;
315
335
  }
316
- .malloy-render .${v}:focus-visible > .cell-content {
336
+ .malloy-render .${g}:focus-visible > .cell-content {
317
337
  color: var(--publisher-drill-link) !important;
318
338
  text-decoration: underline;
319
339
  }
320
340
  `, le = "publisher-malloy-renderer-overrides";
321
- function Le() {
341
+ function Ie() {
322
342
  if (typeof document > "u" || document.getElementById(le)) return;
323
343
  const e = document.createElement("style");
324
344
  e.id = le, e.textContent = ze, document.head.appendChild(e);
325
345
  }
326
- function Be({
346
+ function Le({
327
347
  result: e,
328
348
  height: r,
329
349
  drill: t,
@@ -334,7 +354,7 @@ function Be({
334
354
  l.current = t;
335
355
  const s = he((c) => {
336
356
  l.current?.onClick(c);
337
- }, []), y = t !== void 0, h = z(!1), g = z(
357
+ }, []), y = t !== void 0, h = z(!1), v = z(
338
358
  null
339
359
  ), x = z(0), { theme: G, layers: U, mode: X } = Ce(), Y = ce().shape.borderRadius, J = me(
340
360
  () => ({
@@ -343,56 +363,56 @@ function Be({
343
363
  }),
344
364
  [Y]
345
365
  );
346
- return fe(() => () => {
366
+ return be(() => () => {
347
367
  x.current += 1;
348
- const c = g.current;
349
- c?.viz.remove(), c?.node.remove(), g.current = null;
350
- }, []), be(() => {
368
+ const c = v.current;
369
+ c?.viz.remove(), c?.node.remove(), v.current = null;
370
+ }, []), fe(() => {
351
371
  if (!o.current || !e) return;
352
- Le();
372
+ Ie();
353
373
  const c = o.current, ie = x.current += 1;
354
- let P = !1;
355
- const j = () => !P && ie === x.current;
356
- let d, m, M = null, V = 0, I = null, N = null, $ = null, O = null, F = null, T = null, W = null, Q = 0, R = null;
374
+ let j = !1;
375
+ const P = () => !j && ie === x.current;
376
+ let d, m, B = null, V = 0, M = null, N = null, $ = null, O = null, T = null, F = null, W = null, Q = 0, R = null;
357
377
  h.current = !1;
358
378
  let p, E;
359
379
  const q = (w) => {
360
- if (P || !w.firstElementChild || K(p, E) === "container") return;
361
- const _ = ve(p, E);
380
+ if (j || !w.firstElementChild || K(p, E) === "container") return;
381
+ const _ = ge(p, E);
362
382
  if (h.current && !_) return;
363
- const k = ge(
383
+ const k = ve(
364
384
  w,
365
385
  ae(p)
366
386
  );
367
387
  k > 0 && (h.current = !0, a && k !== Q && (Q = k, a(k)));
368
388
  const S = we(w, ae(p));
369
- _ && S && W !== S && (W = S, T?.disconnect(), T = new ResizeObserver(() => q(w)), T.observe(S));
389
+ _ && S && W !== S && (W = S, F?.disconnect(), F = new ResizeObserver(() => q(w)), F.observe(S));
370
390
  };
371
391
  return (async () => {
372
392
  let w;
373
393
  try {
374
394
  w = JSON.parse(e);
375
- } catch (b) {
376
- console.error("Error parsing visualization result:", b);
395
+ } catch (f) {
396
+ console.error("Error parsing visualization result:", f);
377
397
  return;
378
398
  }
379
- const _ = await Te(w), k = _ ? xe([...U, _], X) : G;
380
- if (!j()) return;
399
+ const _ = await Fe(w), k = _ ? xe([...U, _], X) : G;
400
+ if (!P()) return;
381
401
  try {
382
- m = await Fe(k, s);
383
- } catch (b) {
384
- console.error("Failed to create renderer:", b);
402
+ m = await Te(k, s);
403
+ } catch (f) {
404
+ console.error("Failed to create renderer:", f);
385
405
  return;
386
406
  }
387
- if (!j()) {
407
+ if (!P()) {
388
408
  m.remove(), m = void 0;
389
409
  return;
390
410
  }
391
- const S = g.current;
411
+ const S = v.current;
392
412
  d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", _e(d, k, J), c.childElementCount > 0 && (c.style.position = "relative", d.style.position = "absolute", d.style.inset = "0", d.style.visibility = "hidden"), c.appendChild(d);
393
413
  const u = d;
394
414
  O = new MutationObserver(() => {
395
- F && clearTimeout(F), F = setTimeout(() => {
415
+ T && clearTimeout(T), T = setTimeout(() => {
396
416
  q(u), h.current && O?.disconnect();
397
417
  }, 100);
398
418
  }), O.observe(d, {
@@ -403,11 +423,11 @@ function Be({
403
423
  const se = m;
404
424
  let Z = !1;
405
425
  const ee = () => {
406
- if (!(Z || !j())) {
426
+ if (!(Z || !P())) {
407
427
  Z = !0, R && (clearTimeout(R), R = null), S?.viz.remove();
408
- for (const b of Array.from(c.children))
409
- b !== u && c.removeChild(b);
410
- u.style.position = "", u.style.inset = "", u.style.visibility = "", c.style.position = "", g.current = { viz: se, node: u }, q(u);
428
+ for (const f of Array.from(c.children))
429
+ f !== u && c.removeChild(f);
430
+ u.style.position = "", u.style.inset = "", u.style.visibility = "", c.style.position = "", v.current = { viz: se, node: u }, q(u);
411
431
  }
412
432
  };
413
433
  try {
@@ -419,10 +439,10 @@ function Be({
419
439
  p = void 0, E = void 0;
420
440
  }
421
441
  n?.(K(p, E)), d.dataset.malloyRenderAs = p ?? "unknown", d.dataset.malloySizing = K(p, E), m.render(d);
422
- const b = l.current;
442
+ const f = l.current;
423
443
  try {
424
- if (b) {
425
- const C = Re(m, b.canDrill), A = () => {
444
+ if (f) {
445
+ const C = Re(m, f.canDrill), A = () => {
426
446
  try {
427
447
  Ee(u, C);
428
448
  } catch (i) {
@@ -441,28 +461,28 @@ function Be({
441
461
  clientY: Math.round(H.bottom)
442
462
  })
443
463
  );
444
- }, te = (i) => i.target?.closest?.(`.${v}`) ?? null, de = (i, f) => {
445
- ne(i, f)?.focus();
464
+ }, te = (i) => i.target?.closest?.(`.${g}`) ?? null, de = (i, b) => {
465
+ ne(i, b)?.focus();
446
466
  };
447
- I = (i) => {
448
- const f = te(i);
449
- if (!f) return;
467
+ M = (i) => {
468
+ const b = te(i);
469
+ if (!b) return;
450
470
  const D = i.key === "ArrowDown" ? 1 : i.key === "ArrowUp" ? -1 : i.key === "Home" ? "first" : i.key === "End" ? "last" : void 0;
451
471
  if (D !== void 0) {
452
- i.preventDefault(), de(f, D);
472
+ i.preventDefault(), de(b, D);
453
473
  return;
454
474
  }
455
- i.key === "Enter" ? (i.preventDefault(), re(f)) : i.key === " " && i.preventDefault();
475
+ i.key === "Enter" ? (i.preventDefault(), re(b)) : i.key === " " && i.preventDefault();
456
476
  }, N = (i) => {
457
477
  if (i.key !== " ") return;
458
- const f = te(i);
459
- f && (i.preventDefault(), re(f));
478
+ const b = te(i);
479
+ b && (i.preventDefault(), re(b));
460
480
  }, $ = (i) => {
461
- const f = i.target?.closest?.(`.${v}`);
462
- f && ne(f, 0);
463
- }, u.addEventListener("keydown", I), u.addEventListener("keyup", N), u.addEventListener("focusin", $), C.size > 0 && typeof MutationObserver < "u" && (M = new MutationObserver(() => {
481
+ const b = i.target?.closest?.(`.${g}`);
482
+ b && ne(b, 0);
483
+ }, u.addEventListener("keydown", M), u.addEventListener("keyup", N), u.addEventListener("focusin", $), C.size > 0 && typeof MutationObserver < "u" && (B = new MutationObserver(() => {
464
484
  cancelAnimationFrame(V), V = requestAnimationFrame(A);
465
- }), M.observe(u, {
485
+ }), B.observe(u, {
466
486
  childList: !0,
467
487
  subtree: !0
468
488
  }));
@@ -471,11 +491,11 @@ function Be({
471
491
  console.warn("Drill affordance skipped:", C);
472
492
  }
473
493
  m.onReady(ee), R = setTimeout(ee, 1e4);
474
- } catch (b) {
475
- console.error("Error rendering visualization:", b), O?.disconnect(), T?.disconnect(), M?.disconnect(), m.remove(), m = void 0, u.parentNode === c && c.removeChild(u);
494
+ } catch (f) {
495
+ console.error("Error rendering visualization:", f), O?.disconnect(), F?.disconnect(), B?.disconnect(), m.remove(), m = void 0, u.parentNode === c && c.removeChild(u);
476
496
  }
477
497
  })(), () => {
478
- P = !0, O?.disconnect(), T?.disconnect(), F && clearTimeout(F), R && clearTimeout(R), d && g.current?.node !== d && (I && d.removeEventListener("keydown", I), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), M?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === c && c.removeChild(d), c.style.position = "");
498
+ j = !0, O?.disconnect(), F?.disconnect(), T && clearTimeout(T), R && clearTimeout(R), d && v.current?.node !== d && (M && d.removeEventListener("keydown", M), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), B?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === c && c.removeChild(d), c.style.position = "");
479
499
  };
480
500
  }, [
481
501
  e,
@@ -487,7 +507,7 @@ function Be({
487
507
  U,
488
508
  X,
489
509
  J
490
- ]), /* @__PURE__ */ L(
510
+ ]), /* @__PURE__ */ I(
491
511
  "div",
492
512
  {
493
513
  ref: o,
@@ -498,8 +518,8 @@ function Be({
498
518
  }
499
519
  );
500
520
  }
501
- function Me(e) {
502
- return typeof window > "u" ? /* @__PURE__ */ L(
521
+ function Be(e) {
522
+ return typeof window > "u" ? /* @__PURE__ */ I(
503
523
  oe,
504
524
  {
505
525
  sx: {
@@ -512,10 +532,10 @@ function Me(e) {
512
532
  },
513
533
  children: "Loading..."
514
534
  }
515
- ) : /* @__PURE__ */ L(
535
+ ) : /* @__PURE__ */ I(
516
536
  ue,
517
537
  {
518
- fallback: /* @__PURE__ */ L(
538
+ fallback: /* @__PURE__ */ I(
519
539
  oe,
520
540
  {
521
541
  sx: {
@@ -529,17 +549,17 @@ function Me(e) {
529
549
  children: "Loading visualization..."
530
550
  }
531
551
  ),
532
- children: /* @__PURE__ */ L(Be, { ...e })
552
+ children: /* @__PURE__ */ I(Le, { ...e })
533
553
  }
534
554
  );
535
555
  }
536
556
  const Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
537
557
  __proto__: null,
538
- default: Me
558
+ default: Be
539
559
  }, Symbol.toStringTag, { value: "Module" }));
540
560
  export {
541
- v as D,
542
- Me as R,
561
+ g as D,
562
+ Be as R,
543
563
  De as a,
544
564
  Ae as b,
545
565
  Ve as c,
@@ -1,4 +1,4 @@
1
- "use strict";var ve=Object.create;var le=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Ce=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Re.call(e,o)&&o!==t&&le(e,o,{get:()=>r[o],enumerable:!(n=ge(r,o))||n.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ve(ke(e)):{},Ce(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const B=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),v=require("./DocumentStorage-CMyLifsz.cjs.js"),X=require("./ServerProvider-Cc489A3f.cjs.js"),g="publisher-drill";function de(e,r){const t=new Set;let n;try{n=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const a of n)!a||r(a)||a.tag?.tag("hidden")===void 0&&o.add(a.tag?.text("label")??a.name);for(const a of n){if(!a||!r(a))continue;const l=a.tag?.text("label")??a.name;o.has(l)||t.add(l)}return t}function M(e){const r=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return r?r[1]:void 0}function ce(e,r){if(r.size!==0)for(const t of e.querySelectorAll(".malloy-table")){const n=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!n(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),y=M(l);y&&r.has(s)&&o.add(y)}if(o.size===0)continue;const a=new Set;for(const l of t.querySelectorAll(`.${g}[tabindex="0"]`)){if(!n(l))continue;const s=M(l);s&&(a.has(s)?l.tabIndex=-1:a.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!n(l))continue;const s=M(l),y=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&y&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(g),l.tabIndex===0)a.add(s);else{const h=a.has(s);h||a.add(s),l.tabIndex=h?-1:0}l.setAttribute("role","button")}}}}function xe(e){const r=e.closest(".malloy-table"),t=M(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${g}`)).filter(n=>n.closest(".malloy-table")===r&&M(n)===t)}function ie(e,r){const t=xe(e),n=t.indexOf(e);if(n===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(n+r,0),t.length-1)];if(o){for(const a of t)a.tabIndex=a===o?0:-1;return o}}function ue(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function he(e){const{foreground:r,axisFaint:t,font:n}=e,o={background:e.background,font:n.family,title:{color:r,font:n.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:n.family,titleFont:n.family},legend:{labelColor:r,titleColor:r,labelFont:n.family,titleFont:n.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return a=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},n=r.tag("palette");if(n){const a={},l=n.textArray("series");l&&l.length>0&&(a.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const y=n.tag(s);if(!y)continue;const h={},k=y.text("light"),E=y.text("dark");k&&(h.light=k),E&&(h.dark=E),Object.keys(h).length>0&&(a[s]=h)}Object.keys(a).length>0&&(t.palette=a)}const o=r.tag("font");if(o){const a={},l=o.text("family");l&&(a.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(a.size=s),Object.keys(a).length>0&&(t.font=a)}return Object.keys(t).length>0?t:void 0}const Ee=async(e,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await import("@malloydata/render");return new t({onClick:r,vegaConfigOverride:he(e),theme:ue(e),onError:o=>{console.error("Error rendering visualization:",typeof o,o)}}).createViz()};typeof window<"u"&&import("@malloydata/render");async function Se(e){if(!e||typeof e!="object")return;const r=e,t=[...Array.isArray(r.model_annotations)?r.model_annotations:[],...Array.isArray(r.source_annotations)?r.source_annotations:[],...Array.isArray(r.annotations)?r.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(t.length===0)return;let n;try{({parseAnnotation:n}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=n(t);return me(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:t});return}}function Ae(e,r,t){const n=v.buildTableCssVars(r,t);for(const[o,a]of Object.entries(n))e.style.setProperty(o,a)}const De=`
1
+ "use strict";var ge=Object.create;var le=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var xe=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Re.call(e,o)&&o!==t&&le(e,o,{get:()=>r[o],enumerable:!(a=ve(r,o))||a.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ge(ke(e)):{},xe(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const I=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),g=require("./DocumentStorage-mMn5SZ1c.cjs.js"),X=require("./ServerProvider-CC9ein5-.cjs.js"),v="publisher-drill";function de(e,r){const t=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const n of a)!n||r(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!r(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||t.add(l)}return t}function B(e){const r=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return r?r[1]:void 0}function ce(e,r){if(r.size!==0)for(const t of e.querySelectorAll(".malloy-table")){const a=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!a(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),y=B(l);y&&r.has(s)&&o.add(y)}if(o.size===0)continue;const n=new Set;for(const l of t.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const s=B(l);s&&(n.has(s)?l.tabIndex=-1:n.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!a(l))continue;const s=B(l),y=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&y&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(s);else{const h=n.has(s);h||n.add(s),l.tabIndex=h?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const r=e.closest(".malloy-table"),t=B(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===r&&B(a)===t)}function ie(e,r){const t=Ce(e),a=t.indexOf(e);if(a===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(a+r,0),t.length-1)];if(o){for(const n of t)n.tabIndex=n===o?0:-1;return o}}function ue(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function he(e){const{foreground:r,axisFaint:t,font:a}=e,o={background:e.background,font:a.family,title:{color:r,font:a.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:a.family,titleFont:a.family},legend:{labelColor:r,titleColor:r,labelFont:a.family,titleFont:a.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return n=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},a=r.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const y=a.tag(s);if(!y)continue;const h={},k=y.text("light"),E=y.text("dark");k&&(h.light=k),E&&(h.dark=E),Object.keys(h).length>0&&(n[s]=h)}Object.keys(n).length>0&&(t.palette=n)}const o=r.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(n.size=s),Object.keys(n).length>0&&(t.font=n)}return Object.keys(t).length>0?t:void 0}const Ee=async(e,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await import("@malloydata/render");return new t({onClick:r,vegaConfigOverride:he(e),theme:ue(e),onError:o=>{console.error("Error rendering visualization:",typeof o,o)}}).createViz()};typeof window<"u"&&import("@malloydata/render");async function Se(e){if(!e||typeof e!="object")return;const r=e,t=[...Array.isArray(r.model_annotations)?r.model_annotations:[],...Array.isArray(r.source_annotations)?r.source_annotations:[],...Array.isArray(r.annotations)?r.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(t.length===0)return;let a;try{({parseAnnotation:a}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=a(t);return me(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:t});return}}function Ae(e,r,t){const a=g.buildTableCssVars(r,t);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}const De=`
2
2
  /* Card geometry, through the renderer's OWN theme vars rather than over the top
3
3
  of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
4
4
  passes each through to the --malloy-render--* the card CSS reads, so a value
@@ -58,7 +58,27 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
58
58
  background: var(--malloy-render--tile-background) !important;
59
59
  color: var(--malloy-render--table-body-color) !important;
60
60
  box-shadow: none !important;
61
- border: var(--malloy-render--table-border) !important;
61
+ /* The card edge, not the table gridline: --publisher-dashboard-card-border,
62
+ the same value TileCard paints, so the renderer's card and the composite
63
+ one are outlined identically. */
64
+ border: var(--publisher-dashboard-card-border) !important;
65
+ }
66
+ /* The renderer's big-value card — the small card a "# big_value" measure sits
67
+ in, several to a row inside one tile. (No backticks in here: this is inside
68
+ a template literal.) Its own CSS gives it a 0.55px edge in
69
+ #e5e7eb: a sub-pixel width, and a grey off the slate ramp everything else on
70
+ the page is on. It is a dashboard card like any other, so it takes the card
71
+ edge and stops being the one card outlined in a hairline nobody can see. */
72
+ .malloy-render .malloy-big-value-card {
73
+ border: var(--publisher-dashboard-card-border) !important;
74
+ /* Its shadow is a four-layer Tailwind stack, and only two of those layers
75
+ are a shadow: the other is "0 0 0 1px #e5e7eb", a spread ring drawn as a
76
+ second border OVER the real one. So the border above was landing
77
+ underneath a ring in the renderer's own grey, and the card kept both a
78
+ lifted look the flat cards around it do not have and an edge we did not
79
+ pick. Dropped whole rather than rebuilt layer by layer: the ring's job is
80
+ the border's job, and the border is already doing it. */
81
+ box-shadow: none !important;
62
82
  }
63
83
  .malloy-render .malloy-dashboard .dashboard-row-header-separator {
64
84
  background: var(--malloy-render--table-border) !important;
@@ -93,10 +113,10 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
93
113
  and the only thing that tells a reader a cell navigates. Kept off the
94
114
  resting state deliberately: a column painted blue competes with the data.
95
115
  (No backticks in here: this is inside a template literal.) */
96
- .malloy-render .${g} {
116
+ .malloy-render .${v} {
97
117
  cursor: pointer;
98
118
  }
99
- .malloy-render .${g}:hover > .cell-content {
119
+ .malloy-render .${v}:hover > .cell-content {
100
120
  color: var(--publisher-drill-link) !important;
101
121
  text-decoration: underline;
102
122
  }
@@ -104,12 +124,12 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
104
124
  something a keyboard user can produce, and a focus ring is not something a
105
125
  mouse user sees. focus-visible rather than focus, so a click does not leave a
106
126
  ring behind it. (No backticks in here: this is inside a template literal.) */
107
- .malloy-render .${g}:focus-visible {
127
+ .malloy-render .${v}:focus-visible {
108
128
  outline: 2px solid var(--publisher-drill-link);
109
129
  outline-offset: -2px;
110
130
  }
111
- .malloy-render .${g}:focus-visible > .cell-content {
131
+ .malloy-render .${v}:focus-visible > .cell-content {
112
132
  color: var(--publisher-drill-link) !important;
113
133
  text-decoration: underline;
114
134
  }
115
- `,se="publisher-malloy-renderer-overrides";function Oe(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=De,document.head.appendChild(e)}function Te({result:e,height:r,drill:t,onSizeChange:n,onSizing:o}){const a=p.useRef(null),l=p.useRef(t);l.current=t;const s=p.useCallback(c=>{l.current?.onClick(c)},[]),y=t!==void 0,h=p.useRef(!1),k=p.useRef(null),E=p.useRef(0),{theme:Y,layers:J,mode:W}=X.usePublisherTheme(),Q=U.useTheme().shape.borderRadius,Z=p.useMemo(()=>({radius:`${Q}px`,padding:`${v.DASHBOARD_CARD_PADDING_PX}px`}),[Q]);return p.useEffect(()=>()=>{E.current+=1;const c=k.current;c?.viz.remove(),c?.node.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!a.current||!e)return;Oe();const c=a.current,fe=E.current+=1;let q=!1;const P=()=>!q&&fe===E.current;let d,m,I=null,V=0,N=null,j=null,$=null,L=null,_=null,z=null,ee=null,re=0,S=null;h.current=!1;let w,A;const H=R=>{if(q||!R.firstElementChild||v.resultSizing(w,A)==="container")return;const F=v.remeasuresAfterReady(w,A);if(h.current&&!F)return;const C=v.measureContentHeight(R,v.contentNodeDepth(w));C>0&&(h.current=!0,n&&C!==re&&(re=C,n(C)));const D=v.contentNode(R,v.contentNodeDepth(w));F&&D&&ee!==D&&(ee=D,z?.disconnect(),z=new ResizeObserver(()=>H(R)),z.observe(D))};return(async()=>{let R;try{R=JSON.parse(e)}catch(f){console.error("Error parsing visualization result:",f);return}const F=await Se(R),C=F?X.resolveTheme([...J,F],W):Y;if(!P())return;try{m=await Ee(C,s)}catch(f){console.error("Failed to create renderer:",f);return}if(!P()){m.remove(),m=void 0;return}const D=k.current;d=document.createElement("div"),d.style.width="100%",d.style.height="100%",Ae(d,C,Z),c.childElementCount>0&&(c.style.position="relative",d.style.position="absolute",d.style.inset="0",d.style.visibility="hidden"),c.appendChild(d);const u=d;L=new MutationObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{H(u),h.current&&L?.disconnect()},100)}),L.observe(d,{childList:!0,subtree:!0,attributes:!0});const ye=m;let te=!1;const oe=()=>{if(!(te||!P())){te=!0,S&&(clearTimeout(S),S=null),D?.viz.remove();for(const f of Array.from(c.children))f!==u&&c.removeChild(f);u.style.position="",u.style.inset="",u.style.visibility="",c.style.position="",k.current={viz:ye,node:u},H(u)}};try{m.setResult(R);try{const x=m.getMetadata(),O=x?.getRootField();w=O?.renderAs(),A=O?x?.getPluginsForField(O.key)?.[0]?.sizingStrategy:void 0}catch{w=void 0,A=void 0}o?.(v.resultSizing(w,A)),d.dataset.malloyRenderAs=w??"unknown",d.dataset.malloySizing=v.resultSizing(w,A),m.render(d);const f=l.current;try{if(f){const x=de(m,f.canDrill),O=()=>{try{ce(u,x)}catch(i){console.warn("Drill affordance skipped:",i)}};O();const ne=i=>{const T=i.querySelector(".cell-content")??i,K=T.getBoundingClientRect();T.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:T.ownerDocument.defaultView,clientX:Math.round(K.left+K.width/2),clientY:Math.round(K.bottom)}))},ae=i=>i.target?.closest?.(`.${g}`)??null,pe=(i,b)=>{ie(i,b)?.focus()};N=i=>{const b=ae(i);if(!b)return;const T=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:i.key==="Home"?"first":i.key==="End"?"last":void 0;if(T!==void 0){i.preventDefault(),pe(b,T);return}i.key==="Enter"?(i.preventDefault(),ne(b)):i.key===" "&&i.preventDefault()},j=i=>{if(i.key!==" ")return;const b=ae(i);b&&(i.preventDefault(),ne(b))},$=i=>{const b=i.target?.closest?.(`.${g}`);b&&ie(b,0)},u.addEventListener("keydown",N),u.addEventListener("keyup",j),u.addEventListener("focusin",$),x.size>0&&typeof MutationObserver<"u"&&(I=new MutationObserver(()=>{cancelAnimationFrame(V),V=requestAnimationFrame(O)}),I.observe(u,{childList:!0,subtree:!0}))}}catch(x){console.warn("Drill affordance skipped:",x)}m.onReady(oe),S=setTimeout(oe,1e4)}catch(f){console.error("Error rendering visualization:",f),L?.disconnect(),z?.disconnect(),I?.disconnect(),m.remove(),m=void 0,u.parentNode===c&&c.removeChild(u)}})(),()=>{q=!0,L?.disconnect(),z?.disconnect(),_&&clearTimeout(_),S&&clearTimeout(S),d&&k.current?.node!==d&&(N&&d.removeEventListener("keydown",N),j&&d.removeEventListener("keyup",j),$&&d.removeEventListener("focusin",$),I?.disconnect(),cancelAnimationFrame(V),m?.remove(),d.parentNode===c&&c.removeChild(d),c.style.position="")}},[e,s,y,n,o,Y,J,W,Z]),B.jsx("div",{ref:a,style:{width:"100%",height:r?`${r}px`:"400px"}})}function be(e){return typeof window>"u"?B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):B.jsx(p.Suspense,{fallback:B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:B.jsx(Te,{...e})})}const Le=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=g;exports.RenderedResult=be;exports.RenderedResult$1=Le;exports.buildMalloyExplicitTheme=ue;exports.buildVegaThemeOverride=he;exports.drillableFieldNames=de;exports.markDrillableCells=ce;exports.readChartAnnotations=me;
135
+ `,se="publisher-malloy-renderer-overrides";function Te(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=De,document.head.appendChild(e)}function Oe({result:e,height:r,drill:t,onSizeChange:a,onSizing:o}){const n=p.useRef(null),l=p.useRef(t);l.current=t;const s=p.useCallback(c=>{l.current?.onClick(c)},[]),y=t!==void 0,h=p.useRef(!1),k=p.useRef(null),E=p.useRef(0),{theme:Y,layers:J,mode:W}=X.usePublisherTheme(),Q=U.useTheme().shape.borderRadius,Z=p.useMemo(()=>({radius:`${Q}px`,padding:`${g.DASHBOARD_CARD_PADDING_PX}px`}),[Q]);return p.useEffect(()=>()=>{E.current+=1;const c=k.current;c?.viz.remove(),c?.node.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!n.current||!e)return;Te();const c=n.current,fe=E.current+=1;let q=!1;const P=()=>!q&&fe===E.current;let d,m,M=null,V=0,j=null,N=null,$=null,_=null,L=null,z=null,ee=null,re=0,S=null;h.current=!1;let w,A;const H=R=>{if(q||!R.firstElementChild||g.resultSizing(w,A)==="container")return;const F=g.remeasuresAfterReady(w,A);if(h.current&&!F)return;const x=g.measureContentHeight(R,g.contentNodeDepth(w));x>0&&(h.current=!0,a&&x!==re&&(re=x,a(x)));const D=g.contentNode(R,g.contentNodeDepth(w));F&&D&&ee!==D&&(ee=D,z?.disconnect(),z=new ResizeObserver(()=>H(R)),z.observe(D))};return(async()=>{let R;try{R=JSON.parse(e)}catch(f){console.error("Error parsing visualization result:",f);return}const F=await Se(R),x=F?X.resolveTheme([...J,F],W):Y;if(!P())return;try{m=await Ee(x,s)}catch(f){console.error("Failed to create renderer:",f);return}if(!P()){m.remove(),m=void 0;return}const D=k.current;d=document.createElement("div"),d.style.width="100%",d.style.height="100%",Ae(d,x,Z),c.childElementCount>0&&(c.style.position="relative",d.style.position="absolute",d.style.inset="0",d.style.visibility="hidden"),c.appendChild(d);const u=d;_=new MutationObserver(()=>{L&&clearTimeout(L),L=setTimeout(()=>{H(u),h.current&&_?.disconnect()},100)}),_.observe(d,{childList:!0,subtree:!0,attributes:!0});const ye=m;let te=!1;const oe=()=>{if(!(te||!P())){te=!0,S&&(clearTimeout(S),S=null),D?.viz.remove();for(const f of Array.from(c.children))f!==u&&c.removeChild(f);u.style.position="",u.style.inset="",u.style.visibility="",c.style.position="",k.current={viz:ye,node:u},H(u)}};try{m.setResult(R);try{const C=m.getMetadata(),T=C?.getRootField();w=T?.renderAs(),A=T?C?.getPluginsForField(T.key)?.[0]?.sizingStrategy:void 0}catch{w=void 0,A=void 0}o?.(g.resultSizing(w,A)),d.dataset.malloyRenderAs=w??"unknown",d.dataset.malloySizing=g.resultSizing(w,A),m.render(d);const f=l.current;try{if(f){const C=de(m,f.canDrill),T=()=>{try{ce(u,C)}catch(i){console.warn("Drill affordance skipped:",i)}};T();const ae=i=>{const O=i.querySelector(".cell-content")??i,K=O.getBoundingClientRect();O.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:O.ownerDocument.defaultView,clientX:Math.round(K.left+K.width/2),clientY:Math.round(K.bottom)}))},ne=i=>i.target?.closest?.(`.${v}`)??null,pe=(i,b)=>{ie(i,b)?.focus()};j=i=>{const b=ne(i);if(!b)return;const O=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:i.key==="Home"?"first":i.key==="End"?"last":void 0;if(O!==void 0){i.preventDefault(),pe(b,O);return}i.key==="Enter"?(i.preventDefault(),ae(b)):i.key===" "&&i.preventDefault()},N=i=>{if(i.key!==" ")return;const b=ne(i);b&&(i.preventDefault(),ae(b))},$=i=>{const b=i.target?.closest?.(`.${v}`);b&&ie(b,0)},u.addEventListener("keydown",j),u.addEventListener("keyup",N),u.addEventListener("focusin",$),C.size>0&&typeof MutationObserver<"u"&&(M=new MutationObserver(()=>{cancelAnimationFrame(V),V=requestAnimationFrame(T)}),M.observe(u,{childList:!0,subtree:!0}))}}catch(C){console.warn("Drill affordance skipped:",C)}m.onReady(oe),S=setTimeout(oe,1e4)}catch(f){console.error("Error rendering visualization:",f),_?.disconnect(),z?.disconnect(),M?.disconnect(),m.remove(),m=void 0,u.parentNode===c&&c.removeChild(u)}})(),()=>{q=!0,_?.disconnect(),z?.disconnect(),L&&clearTimeout(L),S&&clearTimeout(S),d&&k.current?.node!==d&&(j&&d.removeEventListener("keydown",j),N&&d.removeEventListener("keyup",N),$&&d.removeEventListener("focusin",$),M?.disconnect(),cancelAnimationFrame(V),m?.remove(),d.parentNode===c&&c.removeChild(d),c.style.position="")}},[e,s,y,a,o,Y,J,W,Z]),I.jsx("div",{ref:n,style:{width:"100%",height:r?`${r}px`:"400px"}})}function be(e){return typeof window>"u"?I.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):I.jsx(p.Suspense,{fallback:I.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:I.jsx(Oe,{...e})})}const _e=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=v;exports.RenderedResult=be;exports.RenderedResult$1=_e;exports.buildMalloyExplicitTheme=ue;exports.buildVegaThemeOverride=he;exports.drillableFieldNames=de;exports.markDrillableCells=ce;exports.readChartAnnotations=me;