@bicharts/chart-host 0.5.7 → 0.5.9

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.
@@ -33,49 +33,49 @@ var COLOR_SCALE_SELF_CLAMP_PCT_MAX = 100;
33
33
 
34
34
  // src/defaults.ts
35
35
  var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
36
- function resolveOptions(p2) {
36
+ function resolveOptions(p) {
37
37
  return {
38
38
  // ---- host fields: pass through exactly as supplied ----
39
- width: p2.width,
40
- height: p2.height,
41
- palette: p2.palette,
42
- geoUnmatched: p2.geoUnmatched,
43
- geo: p2.geo,
44
- geoPoint: p2.geoPoint,
45
- maxMapPoints: p2.maxMapPoints,
46
- uiState: p2.uiState,
47
- setUiState: p2.setUiState,
48
- backgroundColor: p2.backgroundColor,
49
- themeBg: p2.themeBg,
50
- themeFg: p2.themeFg,
51
- isHighContrast: p2.isHighContrast,
52
- themeAccent: p2.themeAccent,
53
- cultureCode: p2.cultureCode,
54
- allowTooltips: p2.allowTooltips,
55
- noDataText: p2.noDataText,
56
- onSelect: p2.onSelect,
39
+ width: p.width,
40
+ height: p.height,
41
+ palette: p.palette,
42
+ geoUnmatched: p.geoUnmatched,
43
+ geo: p.geo,
44
+ geoPoint: p.geoPoint,
45
+ maxMapPoints: p.maxMapPoints,
46
+ uiState: p.uiState,
47
+ setUiState: p.setUiState,
48
+ backgroundColor: p.backgroundColor,
49
+ themeBg: p.themeBg,
50
+ themeFg: p.themeFg,
51
+ isHighContrast: p.isHighContrast,
52
+ themeAccent: p.themeAccent,
53
+ cultureCode: p.cultureCode,
54
+ allowTooltips: p.allowTooltips,
55
+ noDataText: p.noDataText,
56
+ onSelect: p.onSelect,
57
57
  // ---- live-restyle knobs: `raw || undefined` / `.toString() || undefined` ----
58
- colorScaleLow: p2.colorScaleLow || void 0,
59
- colorScaleHigh: p2.colorScaleHigh || void 0,
58
+ colorScaleLow: p.colorScaleLow || void 0,
59
+ colorScaleHigh: p.colorScaleHigh || void 0,
60
60
  // "" (global, the default), "frame", or "self"; anything else fails open to global.
61
- colorScaleScope: p2.colorScaleScope === "frame" || p2.colorScaleScope === "self" ? p2.colorScaleScope : "",
61
+ colorScaleScope: p.colorScaleScope === "frame" || p.colorScaleScope === "self" ? p.colorScaleScope : "",
62
62
  // Math.max(50, Math.min(100, Number(raw) || 95)) — only meaningful under "self".
63
- colorScaleSelfClampPct: clamp(Number(p2.colorScaleSelfClampPct) || COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX),
63
+ colorScaleSelfClampPct: clamp(Number(p.colorScaleSelfClampPct) || COLOR_SCALE_SELF_CLAMP_PCT_DEFAULT, COLOR_SCALE_SELF_CLAMP_PCT_MIN, COLOR_SCALE_SELF_CLAMP_PCT_MAX),
64
64
  // Map fills: `raw || undefined` like the colour-scale endpoints. The no-data ->
65
65
  // land cascade is left to the chart (so the fallback chain is visible in the
66
66
  // generated code); HC substitution has already happened in the caller.
67
- geoLandColor: p2.geoLandColor || void 0,
68
- geoNoDataColor: p2.geoNoDataColor || void 0,
69
- aggregation: (p2.aggregation == null ? "" : String(p2.aggregation)) || void 0,
67
+ geoLandColor: p.geoLandColor || void 0,
68
+ geoNoDataColor: p.geoNoDataColor || void 0,
69
+ aggregation: (p.aggregation == null ? "" : String(p.aggregation)) || void 0,
70
70
  // ---- animation: booleans, default+clamp numerics, "" default enum ----
71
- animAutoPlay: !!p2.animAutoPlay,
71
+ animAutoPlay: !!p.animAutoPlay,
72
72
  // Math.max(250, Math.min(5000, Number(raw) || 1000))
73
- animPlaySpeedMs: clamp(Number(p2.animPlaySpeedMs) || ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX),
73
+ animPlaySpeedMs: clamp(Number(p.animPlaySpeedMs) || ANIM_PLAY_SPEED_DEFAULT, ANIM_PLAY_SPEED_MIN, ANIM_PLAY_SPEED_MAX),
74
74
  // Math.max(3, Math.min(500, Number(raw) || 60))
75
- animMaxIdealFrames: clamp(Number(p2.animMaxIdealFrames) || ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX),
76
- animStopAtEnd: !!p2.animStopAtEnd,
77
- filtersDuringPlay: !!p2.filtersDuringPlay,
78
- animTimelineStyle: (p2.animTimelineStyle || "").toString()
75
+ animMaxIdealFrames: clamp(Number(p.animMaxIdealFrames) || ANIM_MAX_IDEAL_FRAMES_DEFAULT, ANIM_MAX_IDEAL_FRAMES_MIN, ANIM_MAX_IDEAL_FRAMES_MAX),
76
+ animStopAtEnd: !!p.animStopAtEnd,
77
+ filtersDuringPlay: !!p.filtersDuringPlay,
78
+ animTimelineStyle: (p.animTimelineStyle || "").toString()
79
79
  };
80
80
  }
81
81
 
@@ -85,12 +85,12 @@ var byAsset = /* @__PURE__ */ new Map();
85
85
  var _na;
86
86
  function geoAssetFor(geoKind) {
87
87
  if (!geoKind) return null;
88
- const k3 = geoKind.toLowerCase();
89
- if (/^country/.test(k3)) return "world";
90
- if (k3 === "north-america") return "world";
91
- if (k3 === "world") return "world";
92
- if (k3 === "us-state-code" || k3 === "us-state-name") return "us-states";
93
- if (k3 === "us-zip5") return "us-zip3";
88
+ const k2 = geoKind.toLowerCase();
89
+ if (/^country/.test(k2)) return "world";
90
+ if (k2 === "north-america") return "world";
91
+ if (k2 === "world") return "world";
92
+ if (k2 === "us-state-code" || k2 === "us-state-name") return "us-states";
93
+ if (k2 === "us-zip5") return "us-zip3";
94
94
  return null;
95
95
  }
96
96
  var _worldBase;
@@ -344,14 +344,14 @@ function r3(n) {
344
344
  if (a2 && o && i3(a2) !== o && (a2 = null), n.city !== void 0 && n.city !== null) {
345
345
  let r = u(String(n.city)), l = F[n.mapKind || "north-america"] ?? "N", f = Y(r);
346
346
  if (f) {
347
- let C = n.state === void 0 || n.state === null ? "" : String(n.state).trim(), d2 = C ? u(C) : "", p2 = C ? H(C) : null, S = [], R = -1;
347
+ let C = n.state === void 0 || n.state === null ? "" : String(n.state).trim(), d2 = C ? u(C) : "", p = C ? H(C) : null, S = [], R = -1;
348
348
  for (let s of f) {
349
- let A2 = s.row;
350
- if (!A2.kinds.includes(l)) continue;
349
+ let A = s.row;
350
+ if (!A.kinds.includes(l)) continue;
351
351
  let c = 0;
352
- if (C && A2.a1 !== "") if (p2 && A2.a1 === p2 || u(A2.a1) === d2) c++;
352
+ if (C && A.a1 !== "") if (p && A.a1 === p || u(A.a1) === d2) c++;
353
353
  else continue;
354
- if (o) if (I(A2.cc) === o) c++;
354
+ if (o) if (I(A.cc) === o) c++;
355
355
  else continue;
356
356
  c > R ? (R = c, S = [s]) : c === R && S.push(s);
357
357
  }
@@ -382,26 +382,26 @@ function r3(n) {
382
382
  var U = { latlon: 0, city: 1, zip3: 2, state: 3, country: 4 };
383
383
  var V = 8;
384
384
  function N3(n, e) {
385
- let t = new Array(n.length), i = new Array(n.length), o = /* @__PURE__ */ new Set(), a2 = [], r = /* @__PURE__ */ new Set(), l = [], f = /* @__PURE__ */ new Set(), C = [], d2 = { latlon: 0, city: 0, zip3: 0, state: 0, country: 0 }, p2 = 0, S = 0, R = null;
385
+ let t = new Array(n.length), i = new Array(n.length), o = /* @__PURE__ */ new Set(), a2 = [], r = /* @__PURE__ */ new Set(), l = [], f = /* @__PURE__ */ new Set(), C = [], d2 = { latlon: 0, city: 0, zip3: 0, state: 0, country: 0 }, p = 0, S = 0, R = null;
386
386
  for (let s = 0; s < n.length; ++s) {
387
- let A2 = n[s], c = r3({ ...A2, mapKind: e });
387
+ let A = n[s], c = r3({ ...A, mapKind: e });
388
388
  if (o3(c)) {
389
389
  t[s] = null, i[s] = null, S++;
390
- let M2 = E(A2);
391
- M2 && !f.has(M2.toLowerCase()) && (f.add(M2.toLowerCase()), C.length < V && C.push(M2));
390
+ let M = E(A);
391
+ M && !f.has(M.toLowerCase()) && (f.add(M.toLowerCase()), C.length < V && C.push(M));
392
392
  } else if (c) {
393
- if (t[s] = c.lat, i[s] = c.lon, p2++, d2[c.precision]++, (R === null || U[c.precision] > U[R]) && (R = c.precision), U[c.precision] > U.city) {
394
- let M2 = E(A2);
395
- M2 && !r.has(M2.toLowerCase()) && (r.add(M2.toLowerCase()), l.length < V && l.push(M2));
393
+ if (t[s] = c.lat, i[s] = c.lon, p++, d2[c.precision]++, (R === null || U[c.precision] > U[R]) && (R = c.precision), U[c.precision] > U.city) {
394
+ let M = E(A);
395
+ M && !r.has(M.toLowerCase()) && (r.add(M.toLowerCase()), l.length < V && l.push(M));
396
396
  }
397
397
  } else {
398
398
  t[s] = null, i[s] = null;
399
- let M2 = E(A2);
400
- M2 && !o.has(M2.toLowerCase()) && (o.add(M2.toLowerCase()), a2.push(M2));
399
+ let M = E(A);
400
+ M && !o.has(M.toLowerCase()) && (o.add(M.toLowerCase()), a2.push(M));
401
401
  }
402
402
  }
403
403
  let N2 = !v() && n.some((s) => s.city !== null && s.city !== void 0 && String(s.city).trim() !== "");
404
- return { lat: t, lon: i, precision: R, precisionCounts: d2, coarseExamples: l, unmatched: a2, ambiguousRows: S, ambiguousExamples: C, matchedRows: p2, totalRows: n.length, ...N2 ? { cityTableMissing: true } : {} };
404
+ return { lat: t, lon: i, precision: R, precisionCounts: d2, coarseExamples: l, unmatched: a2, ambiguousRows: S, ambiguousExamples: C, matchedRows: p, totalRows: n.length, ...N2 ? { cityTableMissing: true } : {} };
405
405
  }
406
406
  function E(n) {
407
407
  return [n.city, n.state, n.zip, n.country].filter((e) => e != null && String(e).trim() !== "").map((e) => String(e).trim()).join(", ");
@@ -414,16 +414,20 @@ function s3(n, e) {
414
414
  return t.some((o) => o.row.kinds.includes(i));
415
415
  }
416
416
 
417
- // ../shape-core/dist/chunk-JY46MGFW.mjs
417
+ // ../shape-core/dist/chunk-7GWUBKNE.mjs
418
418
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
419
- var v2 = [["AL", "Alabama"], ["AK", "Alaska"], ["AZ", "Arizona"], ["AR", "Arkansas"], ["CA", "California"], ["CO", "Colorado"], ["CT", "Connecticut"], ["DE", "Delaware"], ["FL", "Florida"], ["GA", "Georgia"], ["HI", "Hawaii"], ["ID", "Idaho"], ["IL", "Illinois"], ["IN", "Indiana"], ["IA", "Iowa"], ["KS", "Kansas"], ["KY", "Kentucky"], ["LA", "Louisiana"], ["ME", "Maine"], ["MD", "Maryland"], ["MA", "Massachusetts"], ["MI", "Michigan"], ["MN", "Minnesota"], ["MS", "Mississippi"], ["MO", "Missouri"], ["MT", "Montana"], ["NE", "Nebraska"], ["NV", "Nevada"], ["NH", "New Hampshire"], ["NJ", "New Jersey"], ["NM", "New Mexico"], ["NY", "New York"], ["NC", "North Carolina"], ["ND", "North Dakota"], ["OH", "Ohio"], ["OK", "Oklahoma"], ["OR", "Oregon"], ["PA", "Pennsylvania"], ["RI", "Rhode Island"], ["SC", "South Carolina"], ["SD", "South Dakota"], ["TN", "Tennessee"], ["TX", "Texas"], ["UT", "Utah"], ["VT", "Vermont"], ["VA", "Virginia"], ["WA", "Washington"], ["WV", "West Virginia"], ["WI", "Wisconsin"], ["WY", "Wyoming"], ["DC", "District of Columbia"], ["PR", "Puerto Rico"], ["GU", "Guam"], ["VI", "U.S. Virgin Islands"], ["AS", "American Samoa"], ["MP", "Northern Mariana Islands"]];
420
- var j2 = new Set(v2.map((n) => n[0]));
421
- var en = { "Ala.": "AL", "Alab.": "AL", "Ariz.": "AZ", "Ark.": "AR", "Calif.": "CA", "Cal.": "CA", "Colo.": "CO", "Col.": "CO", "Conn.": "CT", "Del.": "DE", "Fla.": "FL", "Flor.": "FL", "Ga.": "GA", "Ill.": "IL", "Ind.": "IN", "Kan.": "KS", "Kans.": "KS", "Ky.": "KY", "La.": "LA", "Md.": "MD", "Mass.": "MA", "Mich.": "MI", "Minn.": "MN", "Miss.": "MS", "Mo.": "MO", "Mont.": "MT", "Neb.": "NE", "Nebr.": "NE", "Nev.": "NV", "N.H.": "NH", "N.J.": "NJ", "N.M.": "NM", "N.Mex.": "NM", "N. Mex.": "NM", "N.Y.": "NY", "N.C.": "NC", "N.D.": "ND", "N.Dak.": "ND", "N. Dak.": "ND", "Okla.": "OK", "Ore.": "OR", "Oreg.": "OR", "Pa.": "PA", "Penn.": "PA", "Penna.": "PA", "R.I.": "RI", "S.C.": "SC", "S.D.": "SD", "S.Dak.": "SD", "S. Dak.": "SD", "Tenn.": "TN", "Tex.": "TX", "Vt.": "VT", "Va.": "VA", "Wash.": "WA", "W.Va.": "WV", "W. Va.": "WV", "Wis.": "WI", "Wisc.": "WI", "Wyo.": "WY", "D.C.": "DC", "Wash. D.C.": "DC", "Wash., D.C.": "DC", "P.R.": "PR", "V.I.": "VI" };
422
- var B2 = (() => {
419
+ var sn = /* @__PURE__ */ new Set(["n a", "none", "null", "nil", "unknown", "not applicable", "not available", "not specified", "unspecified", "missing", "blank", "empty", "tbd", "to be determined"]);
420
+ function Sn(n) {
421
+ return n ? sn.has(n) : true;
422
+ }
423
+ var B2 = [["AL", "Alabama"], ["AK", "Alaska"], ["AZ", "Arizona"], ["AR", "Arkansas"], ["CA", "California"], ["CO", "Colorado"], ["CT", "Connecticut"], ["DE", "Delaware"], ["FL", "Florida"], ["GA", "Georgia"], ["HI", "Hawaii"], ["ID", "Idaho"], ["IL", "Illinois"], ["IN", "Indiana"], ["IA", "Iowa"], ["KS", "Kansas"], ["KY", "Kentucky"], ["LA", "Louisiana"], ["ME", "Maine"], ["MD", "Maryland"], ["MA", "Massachusetts"], ["MI", "Michigan"], ["MN", "Minnesota"], ["MS", "Mississippi"], ["MO", "Missouri"], ["MT", "Montana"], ["NE", "Nebraska"], ["NV", "Nevada"], ["NH", "New Hampshire"], ["NJ", "New Jersey"], ["NM", "New Mexico"], ["NY", "New York"], ["NC", "North Carolina"], ["ND", "North Dakota"], ["OH", "Ohio"], ["OK", "Oklahoma"], ["OR", "Oregon"], ["PA", "Pennsylvania"], ["RI", "Rhode Island"], ["SC", "South Carolina"], ["SD", "South Dakota"], ["TN", "Tennessee"], ["TX", "Texas"], ["UT", "Utah"], ["VT", "Vermont"], ["VA", "Virginia"], ["WA", "Washington"], ["WV", "West Virginia"], ["WI", "Wisconsin"], ["WY", "Wyoming"], ["DC", "District of Columbia"], ["PR", "Puerto Rico"], ["GU", "Guam"], ["VI", "U.S. Virgin Islands"], ["AS", "American Samoa"], ["MP", "Northern Mariana Islands"]];
424
+ var X2 = new Set(B2.map((n) => n[0]));
425
+ var on = { "Ala.": "AL", "Alab.": "AL", "Ariz.": "AZ", "Ark.": "AR", "Calif.": "CA", "Cal.": "CA", "Colo.": "CO", "Col.": "CO", "Conn.": "CT", "Del.": "DE", "Fla.": "FL", "Flor.": "FL", "Ga.": "GA", "Ill.": "IL", "Ind.": "IN", "Kan.": "KS", "Kans.": "KS", "Ky.": "KY", "La.": "LA", "Md.": "MD", "Mass.": "MA", "Mich.": "MI", "Minn.": "MN", "Miss.": "MS", "Mo.": "MO", "Mont.": "MT", "Neb.": "NE", "Nebr.": "NE", "Nev.": "NV", "N.H.": "NH", "N.J.": "NJ", "N.M.": "NM", "N.Mex.": "NM", "N. Mex.": "NM", "N.Y.": "NY", "N.C.": "NC", "N.D.": "ND", "N.Dak.": "ND", "N. Dak.": "ND", "Okla.": "OK", "Ore.": "OR", "Oreg.": "OR", "Pa.": "PA", "Penn.": "PA", "Penna.": "PA", "R.I.": "RI", "S.C.": "SC", "S.D.": "SD", "S.Dak.": "SD", "S. Dak.": "SD", "Tenn.": "TN", "Tex.": "TX", "Vt.": "VT", "Va.": "VA", "Wash.": "WA", "W.Va.": "WV", "W. Va.": "WV", "Wis.": "WI", "Wisc.": "WI", "Wyo.": "WY", "D.C.": "DC", "Wash. D.C.": "DC", "Wash., D.C.": "DC", "P.R.": "PR", "V.I.": "VI" };
426
+ var j2 = (() => {
423
427
  let n = /* @__PURE__ */ new Map();
424
- for (let [i, s] of v2) n.set(d(s), i);
428
+ for (let [i, s] of B2) n.set(d(s), i);
425
429
  n.set(d("Washington DC"), "DC"), n.set(d("Washington D.C."), "DC"), n.set(d("US Virgin Islands"), "VI");
426
- for (let [i, s] of Object.entries(en)) {
430
+ for (let [i, s] of Object.entries(on)) {
427
431
  let o = d(i);
428
432
  o && !n.has(o) && n.set(o, s);
429
433
  }
@@ -436,7 +440,7 @@ function E2(n) {
436
440
  function d(n) {
437
441
  return u(n);
438
442
  }
439
- function ln(n, i) {
443
+ function dn(n, i) {
440
444
  if (n == null) return null;
441
445
  let s = String(n).trim();
442
446
  if (s.length === 0) return null;
@@ -452,7 +456,7 @@ function ln(n, i) {
452
456
  case "us-state-code":
453
457
  case "us-state-name": {
454
458
  let o = E2(s);
455
- return j2.has(o) ? o : B2.get(d(s)) ?? null;
459
+ return X2.has(o) ? o : j2.get(d(s)) ?? null;
456
460
  }
457
461
  case "us-zip5": {
458
462
  let o = /^(\d{5})(-\d{4})?$/.exec(s);
@@ -464,7 +468,7 @@ function ln(n, i) {
464
468
  return null;
465
469
  }
466
470
  }
467
- function hn(n) {
471
+ function Mn(n) {
468
472
  switch (n) {
469
473
  case "country-iso3":
470
474
  case "country-iso2":
@@ -478,152 +482,149 @@ function hn(n) {
478
482
  return false;
479
483
  }
480
484
  }
481
- function An(n, i) {
482
- let s = new Array(n.length), o = /* @__PURE__ */ new Set(), h2 = [], p2 = 0;
485
+ function In(n, i) {
486
+ let s = new Array(n.length), o = /* @__PURE__ */ new Set(), h3 = [], p = 0;
483
487
  for (let S = 0; S < n.length; ++S) {
484
- let T3 = ln(n[S], i);
485
- if (s[S] = T3, T3 !== null) p2++;
488
+ let T3 = dn(n[S], i);
489
+ if (s[S] = T3, T3 !== null) p++;
486
490
  else {
487
- let A2 = n[S];
488
- if (A2 != null) {
489
- let N2 = String(A2).trim();
490
- if (N2.length > 0) {
491
- let m2 = N2.toLowerCase();
492
- o.has(m2) || (o.add(m2), h2.push(N2));
491
+ let A = n[S];
492
+ if (A != null) {
493
+ let m3 = String(A).trim();
494
+ if (m3.length > 0) {
495
+ let N2 = m3.toLowerCase();
496
+ o.has(N2) || (o.add(N2), h3.push(m3));
493
497
  }
494
498
  }
495
499
  }
496
500
  }
497
- return { iso: s, unmatched: h2, matchedRows: p2, totalRows: n.length };
501
+ return { iso: s, unmatched: h3, matchedRows: p, totalRows: n.length };
498
502
  }
499
503
 
500
504
  // ../shape-core/dist/index.mjs
501
505
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
502
- var A = 85;
503
- var T2 = 2;
504
- var pt = 100;
505
- var N = 400;
506
- var mt = 97;
507
- function L2(r) {
506
+ var L2 = 2;
507
+ var _2 = 400;
508
+ function w2(r) {
508
509
  return !!w(r);
509
510
  }
510
- function p(r) {
511
+ function m2(r) {
511
512
  let n = /* @__PURE__ */ new Set();
512
513
  for (let e of r) {
513
514
  if (e == null) continue;
514
515
  let i = u(String(e));
515
- if (i && !n.has(i) && (n.add(i), n.size >= N)) break;
516
+ if (!Sn(i) && !n.has(i) && (n.add(i), n.size >= _2)) break;
516
517
  }
517
518
  return Array.from(n);
518
519
  }
519
- function g2(r) {
520
- let n = p(r);
521
- if (n.length === 0 || ht(r) < mt) return false;
522
- let e = n.filter((c) => L2(c) && !H(c)).length, i = n.filter((c) => !L2(c) && !!H(c)).length;
520
+ function h2(r) {
521
+ let n = m2(r);
522
+ if (n.length === 0 || gt(r) < 95) return false;
523
+ let e = n.filter((a2) => w2(a2) && !H(a2)).length, i = n.filter((a2) => !w2(a2) && !!H(a2)).length;
523
524
  return e >= 1 && e >= i;
524
525
  }
525
- var gt = /* @__PURE__ */ new Set(["USA", "CAN", "MEX"]);
526
- function z2(r, n) {
526
+ var mt = /* @__PURE__ */ new Set(["USA", "CAN", "MEX"]);
527
+ function N(r, n) {
527
528
  if (!H(r)) return false;
528
529
  let e = w(r);
529
- return e ? n === "world" ? true : gt.has(e) : false;
530
+ return e ? n === "world" ? true : mt.has(e) : false;
530
531
  }
531
- function ht(r) {
532
- let n = p(r);
532
+ function gt(r) {
533
+ let n = m2(r);
533
534
  if (n.length === 0) return 0;
534
535
  let e = 0;
535
- for (let i of n) L2(i) && e++;
536
+ for (let i of n) w2(i) && e++;
536
537
  return Math.round(e / n.length * 1e3) / 10;
537
538
  }
538
- function M(r) {
539
- let n = p(r);
539
+ function v2(r) {
540
+ let n = m2(r);
540
541
  if (n.length === 0) return 0;
541
542
  let e = 0;
542
543
  for (let i of n) H(i) && e++;
543
544
  return Math.round(e / n.length * 1e3) / 10;
544
545
  }
545
- function _2(r) {
546
+ function $2(r) {
546
547
  let n = /* @__PURE__ */ new Set();
547
548
  for (let e of r) {
548
549
  if (e == null) continue;
549
550
  let i = String(e).trim();
550
- if (i && !n.has(i) && (n.add(i), n.size >= N)) break;
551
+ if (!Sn(u(i)) && !n.has(i) && (n.add(i), n.size >= _2)) break;
551
552
  }
552
553
  return Array.from(n);
553
554
  }
554
- function D(r) {
555
- let n = _2(r);
555
+ function B3(r) {
556
+ let n = $2(r);
556
557
  if (n.length === 0) return 0;
557
558
  let e = 0;
558
559
  for (let i of n) x(i).length > 0 && e++;
559
560
  return Math.round(e / n.length * 1e3) / 10;
560
561
  }
561
- function Ct(r, n) {
562
- let e = p(r);
562
+ function ht(r, n) {
563
+ let e = m2(r);
563
564
  if (e.length === 0) return 0;
564
565
  let i = 0;
565
- for (let c of e) s3(c, n) && i++;
566
+ for (let a2 of e) s3(a2, n) && i++;
566
567
  return Math.round(i / e.length * 1e3) / 10;
567
568
  }
568
- function k2(r, n) {
569
+ function T2(r, n) {
569
570
  let e = 0;
570
- for (let i of p(r)) n(i) && e++;
571
+ for (let i of m2(r)) n(i) && e++;
571
572
  return e;
572
573
  }
573
- function Pt(r, n) {
574
+ function Ct(r, n) {
574
575
  let e = 0;
575
- for (let i of _2(r)) n(i) && e++;
576
+ for (let i of $2(r)) n(i) && e++;
576
577
  return e;
577
578
  }
578
- function bt(r, n, e, i) {
579
- let c = [], m2 = [], o = {}, w2 = new Set(r), y2 = (t) => n.map((s) => s[t]);
579
+ function Pt(r, n, e, i) {
580
+ let a2 = [], g2 = [], o = {}, G2 = new Set(r), y2 = (t) => n.map((s) => s[t]);
580
581
  for (let t of ["city", "zip", "lat", "lon", "country"]) {
581
582
  let s = e?.[t];
582
- s && w2.has(s) && (o[t] = s);
583
+ s && G2.has(s) && (o[t] = s);
583
584
  }
584
585
  let l = e?.state;
585
- if (l && w2.has(l)) {
586
- let t = y2(l), s = p(t);
587
- s.length > 0 && s.every((a2) => z2(a2, i)) ? m2.push(`state=${l} (every value is "CA", which is both Canada and California)`) : g2(t) ? (m2.push(`state=${l} (every value is a country, not a state)`), o.country || (o.country = l)) : M(t) < A ? m2.push(`state=${l} (only ${M(t)}% of values are states/provinces)`) : o.state = l;
586
+ if (l && G2.has(l)) {
587
+ let t = y2(l), s = m2(t);
588
+ s.length > 0 && s.every((c) => N(c, i)) ? g2.push(`state=${l} (every value is "CA", which is both Canada and California)`) : h2(t) ? (g2.push(`state=${l} (every value is a country, not a state)`), o.country || (o.country = l)) : v2(t) < 95 ? g2.push(`state=${l} (only ${v2(t)}% of values are states/provinces)`) : o.state = l;
588
589
  }
589
- let d2 = new Set(Object.values(o).filter(Boolean)), h2 = r.filter((t) => !d2.has(t) && !t.startsWith("__"));
590
+ let d2 = new Set(Object.values(o).filter(Boolean)), C = r.filter((t) => !d2.has(t) && !t.startsWith("__"));
590
591
  if (!o.state) {
591
592
  let t = null;
592
- for (let s of h2) {
593
- let a2 = y2(s);
594
- if (g2(a2)) continue;
595
- let u2 = M(a2);
596
- if (u2 < A) continue;
597
- let S = k2(a2, (C) => !!H(C)), O2 = k2(a2, (C) => !!H(C) && !z2(C, i));
598
- S < T2 && O2 < 1 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
593
+ for (let s of C) {
594
+ let c = y2(s);
595
+ if (h2(c)) continue;
596
+ let u2 = v2(c);
597
+ if (u2 < 95) continue;
598
+ let S = T2(c, (P2) => !!H(P2)), O2 = T2(c, (P2) => !!H(P2) && !N(P2, i));
599
+ S < L2 && O2 < 1 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
599
600
  }
600
- t && (o.state = t.name, d2.add(t.name), c.push(`state=${t.name} (${t.pct}% states/provinces)`));
601
+ t && (o.state = t.name, d2.add(t.name), a2.push(`state=${t.name} (${t.pct}% states/provinces)`));
601
602
  }
602
- if (!o.zip) for (let t of h2) {
603
+ if (!o.zip) for (let t of C) {
603
604
  if (d2.has(t)) continue;
604
- let s = y2(t), a2 = D(s);
605
- if (!(a2 < pt) && !(Pt(s, (u2) => x(u2).length > 0) < T2)) {
606
- o.zip = t, d2.add(t), c.push(`zip=${t} (${a2}% ZIP codes)`);
605
+ let s = y2(t), c = B3(s);
606
+ if (!(c < 95) && !(Ct(s, (u2) => x(u2).length > 0) < L2)) {
607
+ o.zip = t, d2.add(t), a2.push(`zip=${t} (${c}% ZIP codes)`);
607
608
  break;
608
609
  }
609
610
  }
610
611
  if (!o.country) {
611
- for (let t of h2) if (!d2.has(t) && g2(y2(t))) {
612
- o.country = t, d2.add(t), c.push(`country=${t}`);
612
+ for (let t of C) if (!d2.has(t) && h2(y2(t))) {
613
+ o.country = t, d2.add(t), a2.push(`country=${t}`);
613
614
  break;
614
615
  }
615
616
  }
616
617
  if (!o.city) {
617
618
  let t = null;
618
- for (let s of h2) {
619
+ for (let s of C) {
619
620
  if (d2.has(s)) continue;
620
- let a2 = y2(s), u2 = Ct(a2, i);
621
- u2 < A || k2(a2, (S) => s3(S, i)) < T2 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
621
+ let c = y2(s), u2 = ht(c, i);
622
+ u2 < 95 || T2(c, (S) => s3(S, i)) < L2 || (!t || u2 > t.pct) && (t = { name: s, pct: u2 });
622
623
  }
623
- t && (o.city = t.name, c.push(`city=${t.name} (${t.pct}% known cities)`));
624
+ t && (o.city = t.name, a2.push(`city=${t.name} (${t.pct}% known cities)`));
624
625
  }
625
- let G2 = o.country ? y2(o.country) : [], R = !!o.country && g2(G2), $2 = R ? new Set(G2.map((t) => w(t == null ? null : String(t))).filter(Boolean)).size : 0, I2 = R && $2 >= 2;
626
- return o.country && !I2 && !(o.city || o.state || o.zip || o.lat && o.lon) && m2.push(R ? `country=${o.country} (every row resolves to the same country - nothing to place apart)` : `country=${o.country} (values are not country identifiers)`), { bind: !!(o.city || o.state || o.zip || I2 || o.lat && o.lon) ? o : null, backfilled: c, refused: m2 };
626
+ let I2 = o.country ? y2(o.country) : [], R = !!o.country && h2(I2), D = R ? new Set(I2.map((t) => w(t == null ? null : String(t))).filter(Boolean)).size : 0, z2 = R && D >= 2;
627
+ return o.country && !z2 && !(o.city || o.state || o.zip || o.lat && o.lon) && g2.push(R ? `country=${o.country} (every row resolves to the same country - nothing to place apart)` : `country=${o.country} (values are not country identifiers)`), { bind: !!(o.city || o.state || o.zip || z2 || o.lat && o.lon) ? o : null, backfilled: a2, refused: g2 };
627
628
  }
628
629
 
629
630
  // src/payload.ts
@@ -637,21 +638,21 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
637
638
  let rolesRefused = [];
638
639
  if (bind) {
639
640
  const dims = cols.filter((c) => !c.isMeasure).map((c) => c.name);
640
- const res = bt(dims, rowObjs, bind, point?.mapKind);
641
+ const res = Pt(dims, rowObjs, bind, point?.mapKind);
641
642
  bind = res.bind;
642
643
  rolesBackfilled = res.backfilled;
643
644
  rolesRefused = res.refused;
644
645
  }
645
646
  const hasPointBind = !!bind && !!(bind.city || bind.state || bind.zip || bind.country || bind.lat && bind.lon);
646
647
  if (hasPointBind) {
647
- const p2 = bind;
648
+ const p = bind;
648
649
  const built = N3(rowObjs.map((r) => ({
649
- lat: p2.lat ? r[p2.lat] : null,
650
- lon: p2.lon ? r[p2.lon] : null,
651
- city: p2.city ? r[p2.city] : null,
652
- state: p2.state ? r[p2.state] : null,
653
- zip: p2.zip ? r[p2.zip] : null,
654
- country: p2.country ? r[p2.country] : null
650
+ lat: p.lat ? r[p.lat] : null,
651
+ lon: p.lon ? r[p.lon] : null,
652
+ city: p.city ? r[p.city] : null,
653
+ state: p.state ? r[p.state] : null,
654
+ zip: p.zip ? r[p.zip] : null,
655
+ country: p.country ? r[p.country] : null
655
656
  })), point?.mapKind);
656
657
  pLat = built.lat;
657
658
  pLon = built.lon;
@@ -678,8 +679,8 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
678
679
  let geoIso = null;
679
680
  let geoUnmatched;
680
681
  let geoUnmatchedDistinct;
681
- if (geo && geo.column && geo.kind && hn(geo.kind)) {
682
- const built = An(rowObjs.map((r) => r[geo.column]), geo.kind);
682
+ if (geo && geo.column && geo.kind && Mn(geo.kind)) {
683
+ const built = In(rowObjs.map((r) => r[geo.column]), geo.kind);
683
684
  geoIso = built.iso;
684
685
  geoUnmatched = { count: built.totalRows - built.matchedRows, examples: built.unmatched.slice(0, 8) };
685
686
  geoUnmatchedDistinct = built.unmatched.length;
@@ -697,12 +698,12 @@ function buildRenderPayload(cols, rowObjs, geo, point) {
697
698
  a2[c] = v3 ?? null;
698
699
  }
699
700
  }
700
- let k3 = cols.length;
701
- a2[k3++] = r;
702
- if (geoIso) a2[k3++] = geoIso[r];
701
+ let k2 = cols.length;
702
+ a2[k2++] = r;
703
+ if (geoIso) a2[k2++] = geoIso[r];
703
704
  if (pLat && pLon) {
704
- a2[k3++] = pLat[r];
705
- a2[k3++] = pLon[r];
705
+ a2[k2++] = pLat[r];
706
+ a2[k2++] = pLon[r];
706
707
  }
707
708
  out[r] = a2;
708
709
  }
@@ -742,14 +743,14 @@ function createMarkResolver(env) {
742
743
  const distToPathCenterline = (el, x2, y2) => {
743
744
  const L3 = el.getTotalLength();
744
745
  if (!(L3 > 0)) return Number.MAX_VALUE;
745
- const m2 = el.getScreenCTM();
746
- if (!m2) return Number.MAX_VALUE;
746
+ const m3 = el.getScreenCTM();
747
+ if (!m3) return Number.MAX_VALUE;
747
748
  let best = Number.MAX_VALUE;
748
749
  const N2 = 64;
749
750
  for (let i = 0; i <= N2; i++) {
750
- const pt2 = el.getPointAtLength(L3 * i / N2);
751
- const dx = m2.a * pt2.x + m2.c * pt2.y + m2.e - x2;
752
- const dy = m2.b * pt2.x + m2.d * pt2.y + m2.f - y2;
751
+ const pt = el.getPointAtLength(L3 * i / N2);
752
+ const dx = m3.a * pt.x + m3.c * pt.y + m3.e - x2;
753
+ const dy = m3.b * pt.x + m3.d * pt.y + m3.f - y2;
753
754
  const d2 = dx * dx + dy * dy;
754
755
  if (d2 < best) best = d2;
755
756
  }
@@ -794,9 +795,9 @@ function createMarkResolver(env) {
794
795
  const findMark = (target, sel = ".d3-mark", ev) => {
795
796
  if (!isElement(target)) return null;
796
797
  const el = target;
797
- const m2 = el.closest(sel);
798
- if (m2 && ev) return refineHitCorridor(m2, ev.clientX, ev.clientY, sel);
799
- return m2;
798
+ const m3 = el.closest(sel);
799
+ if (m3 && ev) return refineHitCorridor(m3, ev.clientX, ev.clientY, sel);
800
+ return m3;
800
801
  };
801
802
  const rowIdxsFromMark = (el) => {
802
803
  if (!el) return [];
@@ -880,8 +881,8 @@ var D3_PLUGIN_PACKAGES = {
880
881
  };
881
882
  function requiredD3Plugins(code) {
882
883
  const out = /* @__PURE__ */ new Set();
883
- for (const m2 of String(code || "").matchAll(/\bd3\s*\.\s*(\w+)\s*\(/g)) {
884
- const pkg = D3_PLUGIN_PACKAGES[m2[1]];
884
+ for (const m3 of String(code || "").matchAll(/\bd3\s*\.\s*(\w+)\s*\(/g)) {
885
+ const pkg = D3_PLUGIN_PACKAGES[m3[1]];
885
886
  if (pkg) out.add(pkg);
886
887
  }
887
888
  return [...out].sort();
@@ -893,8 +894,8 @@ function explainRenderFailure(err, d3) {
893
894
  "[@bicharts/chart-host] no d3 was provided, so the generated chart could not run. Pass it explicitly \u2014 createChartHost(el, { d3 }) / <BicChart d3={d3} /> \u2014 or set window.d3. The chart needs D3 v7 (npm install d3@7). Original error: " + msg
894
895
  );
895
896
  }
896
- const m2 = /d3\.(\w+) is not a function|(\w+) is not a function/.exec(msg);
897
- const name = m2?.[1] ?? m2?.[2] ?? "";
897
+ const m3 = /d3\.(\w+) is not a function|(\w+) is not a function/.exec(msg);
898
+ const name = m3?.[1] ?? m3?.[2] ?? "";
898
899
  const pkg = D3_PLUGIN_PACKAGES[name];
899
900
  if (pkg) {
900
901
  return new Error(
@@ -982,10 +983,10 @@ function createChartHost(container, config) {
982
983
  container.classList?.[active ? "add" : "remove"](SELECTION_ACTIVE_CLASS);
983
984
  const wanted = new Set(sel ?? []);
984
985
  const marks = container.querySelectorAll(`.${MARK_CLASS}[${ROW_IDX_ATTR}], .${LEGEND_MARK_CLASS}[${ROW_IDX_ATTR}]`);
985
- for (const m2 of Array.from(marks)) {
986
- const rows = parseRowIdxs(m2.getAttribute(ROW_IDX_ATTR));
987
- const on = active && rows.some((r) => wanted.has(r));
988
- m2.classList?.[on ? "add" : "remove"](MARK_SELECTED_CLASS);
986
+ for (const m3 of Array.from(marks)) {
987
+ const rows = parseRowIdxs(m3.getAttribute(ROW_IDX_ATTR));
988
+ const on2 = active && rows.some((r) => wanted.has(r));
989
+ m3.classList?.[on2 ? "add" : "remove"](MARK_SELECTED_CLASS);
989
990
  }
990
991
  } catch {
991
992
  }
@@ -1061,8 +1062,8 @@ function createChartHost(container, config) {
1061
1062
  renderFn = compileRenderFn(config.code, win, doc, d3);
1062
1063
  }
1063
1064
  if (resolved.geo === void 0 && config.geoKind) {
1064
- const g3 = config.geoProvider?.(config.geoKind) ?? geoFromCache(config.geoKind);
1065
- if (g3) resolved = { ...resolved, geo: g3 };
1065
+ const g2 = config.geoProvider?.(config.geoKind) ?? geoFromCache(config.geoKind);
1066
+ if (g2) resolved = { ...resolved, geo: g2 };
1066
1067
  else if (!warnedGeo) {
1067
1068
  warnedGeo = true;
1068
1069
  try {
package/dist/index.mjs CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  requiredD3Plugins,
40
40
  resolveOptions,
41
41
  stripEsmExports
42
- } from "./chunk-RENIKQVS.mjs";
42
+ } from "./chunk-L5Y6RLK2.mjs";
43
43
  import "./chunk-A2GMXZP7.mjs";
44
44
 
45
45
  // src/index.ts
package/dist/react.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createChartHost,
5
5
  geoFromCache,
6
6
  loadGeo
7
- } from "./chunk-RENIKQVS.mjs";
7
+ } from "./chunk-L5Y6RLK2.mjs";
8
8
  import "./chunk-A2GMXZP7.mjs";
9
9
 
10
10
  // src/react.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/chart-host",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",