var AP = Object.defineProperty;
var CP = (e, t, n) => t in e ? AP(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var zs = (e, t, n) => (CP(e, typeof t != "symbol" ? t + "" : t, n), n);
import * as An from "https://esm.sh/d3@7";
function Zn() {
}
function F3(e, t) {
  for (const n in t)
    e[n] = t[n];
  return (
    /** @type {T & S} */
    e
  );
}
function T3(e) {
  return e();
}
function yS() {
  return /* @__PURE__ */ Object.create(null);
}
function As(e) {
  e.forEach(T3);
}
function O3(e) {
  return typeof e == "function";
}
function Cs(e, t) {
  return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
}
function $P(e) {
  return Object.keys(e).length === 0;
}
function Dv(e, t, n, i) {
  if (e) {
    const r = N3(e, t, n, i);
    return e[0](r);
  }
}
function N3(e, t, n, i) {
  return e[1] && i ? F3(n.ctx.slice(), e[1](i(t))) : n.ctx;
}
function Rv(e, t, n, i) {
  if (e[2] && i) {
    const r = e[2](i(n));
    if (t.dirty === void 0)
      return r;
    if (typeof r == "object") {
      const s = [], o = Math.max(t.dirty.length, r.length);
      for (let a = 0; a < o; a += 1)
        s[a] = t.dirty[a] | r[a];
      return s;
    }
    return t.dirty | r;
  }
  return t.dirty;
}
function Lv(e, t, n, i, r, s) {
  if (r) {
    const o = N3(t, n, i, s);
    e.p(o, r);
  }
}
function Pv(e) {
  if (e.ctx.length > 32) {
    const t = [], n = e.ctx.length / 32;
    for (let i = 0; i < n; i++)
      t[i] = -1;
    return t;
  }
  return -1;
}
function ot(e) {
  return e ?? "";
}
function ve(e, t) {
  e.appendChild(t);
}
function Se(e, t, n) {
  e.insertBefore(t, n || null);
}
function _e(e) {
  e.parentNode && e.parentNode.removeChild(e);
}
function Ja(e, t) {
  for (let n = 0; n < e.length; n += 1)
    e[n] && e[n].d(t);
}
function pe(e) {
  return document.createElement(e);
}
function MP(e) {
  return document.createElementNS("http://www.w3.org/2000/svg", e);
}
function ei(e) {
  return document.createTextNode(e);
}
function ft() {
  return ei(" ");
}
function Zf() {
  return ei("");
}
function Cr(e, t, n, i) {
  return e.addEventListener(t, n, i), () => e.removeEventListener(t, n, i);
}
function he(e, t, n) {
  n == null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n);
}
function FP(e) {
  return Array.from(e.childNodes);
}
function xs(e, t) {
  t = "" + t, e.data !== t && (e.data = /** @type {string} */
  t);
}
function yf(e, t) {
  e.value = t ?? "";
}
function TP(e, t, n, i) {
  n == null ? e.style.removeProperty(t) : e.style.setProperty(t, n, i ? "important" : "");
}
function bS(e, t, n) {
  for (let i = 0; i < e.options.length; i += 1) {
    const r = e.options[i];
    if (r.__value === t) {
      r.selected = !0;
      return;
    }
  }
  (!n || t !== void 0) && (e.selectedIndex = -1);
}
function OP(e) {
  const t = e.querySelector(":checked");
  return t && t.__value;
}
function NP(e, t, { bubbles: n = !1, cancelable: i = !1 } = {}) {
  return new CustomEvent(e, { detail: t, bubbles: n, cancelable: i });
}
class Ip {
  constructor(t = !1) {
    /**
     * @private
     * @default false
     */
    zs(this, "is_svg", !1);
    /** parent for creating node */
    zs(this, "e");
    /** html tag nodes */
    zs(this, "n");
    /** target */
    zs(this, "t");
    /** anchor */
    zs(this, "a");
    this.is_svg = t, this.e = this.n = null;
  }
  /**
   * @param {string} html
   * @returns {void}
   */
  c(t) {
    this.h(t);
  }
  /**
   * @param {string} html
   * @param {HTMLElement | SVGElement} target
   * @param {HTMLElement | SVGElement} anchor
   * @returns {void}
   */
  m(t, n, i = null) {
    this.e || (this.is_svg ? this.e = MP(
      /** @type {keyof SVGElementTagNameMap} */
      n.nodeName
    ) : this.e = pe(
      /** @type {keyof HTMLElementTagNameMap} */
      n.nodeType === 11 ? "TEMPLATE" : n.nodeName
    ), this.t = n.tagName !== "TEMPLATE" ? n : (
      /** @type {HTMLTemplateElement} */
      n.content
    ), this.c(t)), this.i(i);
  }
  /**
   * @param {string} html
   * @returns {void}
   */
  h(t) {
    this.e.innerHTML = t, this.n = Array.from(
      this.e.nodeName === "TEMPLATE" ? this.e.content.childNodes : this.e.childNodes
    );
  }
  /**
   * @returns {void} */
  i(t) {
    for (let n = 0; n < this.n.length; n += 1)
      Se(this.t, this.n[n], t);
  }
  /**
   * @param {string} html
   * @returns {void}
   */
  p(t) {
    this.d(), this.h(t), this.i(this.a);
  }
  /**
   * @returns {void} */
  d() {
    this.n.forEach(_e);
  }
}
function vS(e, t) {
  return new e(t);
}
let bf;
function ef(e) {
  bf = e;
}
function Iv() {
  if (!bf)
    throw new Error("Function called outside component initialization");
  return bf;
}
function zv(e) {
  Iv().$$.on_mount.push(e);
}
function DP(e) {
  Iv().$$.on_destroy.push(e);
}
function Bv() {
  const e = Iv();
  return (t, n, { cancelable: i = !1 } = {}) => {
    const r = e.$$.callbacks[t];
    if (r) {
      const s = NP(
        /** @type {string} */
        t,
        n,
        { cancelable: i }
      );
      return r.slice().forEach((o) => {
        o.call(e, s);
      }), !s.defaultPrevented;
    }
    return !0;
  };
}
function xS(e, t) {
  const n = e.$$.callbacks[t.type];
  n && n.slice().forEach((i) => i.call(this, t));
}
const Fl = [], Ql = [];
let Bl = [];
const xy = [], RP = /* @__PURE__ */ Promise.resolve();
let wy = !1;
function LP() {
  wy || (wy = !0, RP.then(D3));
}
function ng(e) {
  Bl.push(e);
}
function jv(e) {
  xy.push(e);
}
const G0 = /* @__PURE__ */ new Set();
let pl = 0;
function D3() {
  if (pl !== 0)
    return;
  const e = bf;
  do {
    try {
      for (; pl < Fl.length; ) {
        const t = Fl[pl];
        pl++, ef(t), PP(t.$$);
      }
    } catch (t) {
      throw Fl.length = 0, pl = 0, t;
    }
    for (ef(null), Fl.length = 0, pl = 0; Ql.length; )
      Ql.pop()();
    for (let t = 0; t < Bl.length; t += 1) {
      const n = Bl[t];
      G0.has(n) || (G0.add(n), n());
    }
    Bl.length = 0;
  } while (Fl.length);
  for (; xy.length; )
    xy.pop()();
  wy = !1, G0.clear(), ef(e);
}
function PP(e) {
  if (e.fragment !== null) {
    e.update(), As(e.before_update);
    const t = e.dirty;
    e.dirty = [-1], e.fragment && e.fragment.p(e.ctx, t), e.after_update.forEach(ng);
  }
}
function IP(e) {
  const t = [], n = [];
  Bl.forEach((i) => e.indexOf(i) === -1 ? t.push(i) : n.push(i)), n.forEach((i) => i()), Bl = t;
}
const Th = /* @__PURE__ */ new Set();
let da;
function bi() {
  da = {
    r: 0,
    c: [],
    p: da
    // parent group
  };
}
function vi() {
  da.r || As(da.c), da = da.p;
}
function ge(e, t) {
  e && e.i && (Th.delete(e), e.i(t));
}
function Ce(e, t, n, i) {
  if (e && e.o) {
    if (Th.has(e))
      return;
    Th.add(e), da.c.push(() => {
      Th.delete(e), i && (n && e.d(1), i());
    }), e.o(t);
  } else
    i && i();
}
function Rn(e) {
  return (e == null ? void 0 : e.length) !== void 0 ? e : Array.from(e);
}
function wS(e, t) {
  const n = {}, i = {}, r = { $$scope: 1 };
  let s = e.length;
  for (; s--; ) {
    const o = e[s], a = t[s];
    if (a) {
      for (const l in o)
        l in a || (i[l] = 1);
      for (const l in a)
        r[l] || (n[l] = a[l], r[l] = 1);
      e[s] = a;
    } else
      for (const l in o)
        r[l] = 1;
  }
  for (const o in i)
    o in n || (n[o] = void 0);
  return n;
}
function _S(e) {
  return typeof e == "object" && e !== null ? e : {};
}
function Uv(e, t, n) {
  const i = e.$$.props[t];
  i !== void 0 && (e.$$.bound[i] = n, n(e.$$.ctx[i]));
}
function ii(e) {
  e && e.c();
}
function Ln(e, t, n) {
  const { fragment: i, after_update: r } = e.$$;
  i && i.m(t, n), ng(() => {
    const s = e.$$.on_mount.map(T3).filter(O3);
    e.$$.on_destroy ? e.$$.on_destroy.push(...s) : As(s), e.$$.on_mount = [];
  }), r.forEach(ng);
}
function Pn(e, t) {
  const n = e.$$;
  n.fragment !== null && (IP(n.after_update), As(n.on_destroy), n.fragment && n.fragment.d(t), n.on_destroy = n.fragment = null, n.ctx = []);
}
function zP(e, t) {
  e.$$.dirty[0] === -1 && (Fl.push(e), LP(), e.$$.dirty.fill(0)), e.$$.dirty[t / 31 | 0] |= 1 << t % 31;
}
function $s(e, t, n, i, r, s, o = null, a = [-1]) {
  const l = bf;
  ef(e);
  const u = e.$$ = {
    fragment: null,
    ctx: [],
    // state
    props: s,
    update: Zn,
    not_equal: r,
    bound: yS(),
    // lifecycle
    on_mount: [],
    on_destroy: [],
    on_disconnect: [],
    before_update: [],
    after_update: [],
    context: new Map(t.context || (l ? l.$$.context : [])),
    // everything else
    callbacks: yS(),
    dirty: a,
    skip_bound: !1,
    root: t.target || l.$$.root
  };
  o && o(u.root);
  let c = !1;
  if (u.ctx = n ? n(e, t.props || {}, (f, d, ...h) => {
    const g = h.length ? h[0] : d;
    return u.ctx && r(u.ctx[f], u.ctx[f] = g) && (!u.skip_bound && u.bound[f] && u.bound[f](g), c && zP(e, f)), d;
  }) : [], u.update(), c = !0, As(u.before_update), u.fragment = i ? i(u.ctx) : !1, t.target) {
    if (t.hydrate) {
      const f = FP(t.target);
      u.fragment && u.fragment.l(f), f.forEach(_e);
    } else
      u.fragment && u.fragment.c();
    t.intro && ge(e.$$.fragment), Ln(e, t.target, t.anchor), D3();
  }
  ef(l);
}
class Ms {
  constructor() {
    /**
     * ### PRIVATE API
     *
     * Do not use, may change at any time
     *
     * @type {any}
     */
    zs(this, "$$");
    /**
     * ### PRIVATE API
     *
     * Do not use, may change at any time
     *
     * @type {any}
     */
    zs(this, "$$set");
  }
  /** @returns {void} */
  $destroy() {
    Pn(this, 1), this.$destroy = Zn;
  }
  /**
   * @template {Extract<keyof Events, string>} K
   * @param {K} type
   * @param {((e: Events[K]) => void) | null | undefined} callback
   * @returns {() => void}
   */
  $on(t, n) {
    if (!O3(n))
      return Zn;
    const i = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
    return i.push(n), () => {
      const r = i.indexOf(n);
      r !== -1 && i.splice(r, 1);
    };
  }
  /**
   * @param {Partial<Props>} props
   * @returns {void}
   */
  $set(t) {
    this.$$set && !$P(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
  }
}
const BP = "4";
typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(BP);
function jP(e) {
  let t;
  return {
    c() {
      t = pe("div"), t.innerHTML = "";
    },
    m(n, i) {
      Se(n, t, i);
    },
    p: Zn,
    i: Zn,
    o: Zn,
    d(n) {
      n && _e(t);
    }
  };
}
let ES = 200, UP = 150, qP = 80, WP = 300, HP = 60;
function GP(e, t, n) {
  let { data: i } = t, { div: r } = t, { numConcepts: s } = t, { numSlices: o } = t, a;
  const l = Bv();
  zv(() => {
    u(i);
  });
  function u(M) {
    if (M != null && s > 0) {
      let w = JSON.parse(M);
      const k = ES + qP * o, A = WP + HP * s, F = "#82C1FB";
      a = new c(r).size([k, A]).options({
        highlightScope: "matrix",
        showSlider: !1,
        preserveRowOrder: !0,
        preserveColumnOrder: !0,
        sortOnAxisClick: !1
      }).font({ family: "system-ui", size: 10 }).columns({
        row: "concept",
        column: "id",
        value: "value",
        detail: "example"
      }).colors({
        above: F,
        below: F,
        row: "#eee"
      }).data(w), a.render();
    }
  }
  class c {
    constructor(w = document.createElement("DIV")) {
      this._container = w, this._options = new f(), this.partitions = new E(this), this._dataset = null, this._fieldNames = new m(), this.chartData = null, this.measures = new x(this._getMeasureSvg()), this.scales = new T(), this.renderer = new C(this);
    }
    get fieldNames() {
      return this._fieldNames;
    }
    size(w) {
      return arguments.length ? (this.measures.width = w[0], this.measures.height = w[1], this) : [this.measures.width, this.measures.height];
    }
    colors(w) {
      return arguments.length ? (this.renderer.colors.row = w.row, this.renderer.colors.above = w.above, this.renderer.colors.below = w.below, this.renderer.colors.label = w.label, this) : this.renderer.colors;
    }
    margin(w) {
      return arguments.length ? (this.measures.margin.left = w.left, this.measures.margin.right = w.right, this.measures.margin.top = w.top, this.measures.margin.bottom = w.bottom, this) : this.measures.margin;
    }
    options(w) {
      return arguments.length ? (this._options = Object.assign(this._options, w), this) : this._options;
    }
    columns(w) {
      return arguments.length ? (this._fieldNames.column = w.column, this._fieldNames.row = w.row, this._fieldNames.value = w.value, this._fieldNames.detail = w.detail, this) : this._fieldNames;
    }
    font(w) {
      return arguments.length ? (this.measures.font.family(w.family), this.measures.font.size(w.size), this) : this.measures.font;
    }
    data(w) {
      return arguments.length ? (this._dataset = w, this) : this._dataset;
    }
    events(w) {
      return arguments.length ? (this.renderer.rows.onclick = w.onclick, this.renderer.rows.onhover = w.onhover, this.renderer.rows.oncancel = w.oncancel, this) : {
        onclick: this.renderer.onclick,
        onhover: this.renderer.onhover,
        oncancel: this.renderer.oncancel
      };
    }
    render() {
      const w = this._options;
      return this.chartData = new d(this._dataset, this._fieldNames), this.chartData.numberIsPercentage = w.numberIsPercentage, this.chartData.preserveColumnOrder = w.preserveColumnOrder, this.chartData.preserveRowOrder = w.preserveRowOrder, this.chartData.numOfTopBottom = w.numberOfTopBottom, this.chartData.process(), this.measures.initialize(this.chartData, w.showSlider), this.scales.initialize(this), this.partitions.initialize(), this._container.appendChild(this.partitions.chartArea), this.renderer.rows.highlight = P[w.highlightScope], this.renderer.rows.showTooltip = w.showTooltip, this.renderer.rows.showAnnotation = w.showAnnotation, this.renderer.rows.sortOnAxisClick = w.sortOnAxisClick, this.renderer.columns.sortOnAxisClick = w.sortOnAxisClick, this.renderer.render(), w.showSlider && new D(this, w.sliderCaption).render(), this.partitions.adjustScrollableBlocks(), this;
    }
    _getMeasureSvg() {
      const w = An.select(this._container).append("svg").attr("width", 0).attr("height", 0).style("position", "absolute").style("visibility", "hidden");
      return w.append("text"), w;
    }
  }
  class f {
    constructor() {
      this.numberIsPercentage = !1, this.preserveRowOrder = !1, this.preserveColumnOrder = !1, this.showSlider = !0, this.sliderCaption = "Value", this.highlightScope = "matrix", this.numberOfTopBottom = 5, this.showTooltip = !0, this.showAnnotation = !0, this.sortOnAxisClick = !0;
    }
  }
  class d {
    constructor(w, k) {
      this._dataset = w, this._fieldNames = k, this.numberIsPercentage = !1, this.preserveColumnOrder = !1, this.preserveRowOrder = !1, this.columns = null, this.rows = null, this.level = 0, this.defaultLevel = 0, this.average = 0, this.min = 0, this.max = 0, this.numOfTopBottom = 5;
    }
    resetColumns(w) {
      this.columns.forEach((k) => {
        k !== w && (k.order = y.none);
      });
    }
    resetRows(w) {
      this.rows.forEach((k) => {
        k !== w && (k.order = y.none);
      });
    }
    process() {
      const w = this._fieldNames, k = An.group(this._dataset, (L) => L[w.row]);
      this.columns = [...new Set(this._dataset.map((L) => L[w.column]))].map((L, V) => new h(L, V)), this.preserveColumnOrder || (this.columns.sort((L, V) => L.name.localeCompare(V.name)), this.columns.forEach((L, V) => L.position = V));
      const A = [...k.keys()];
      this.preserveRowOrder || A.sort((L, V) => L.localeCompare(V)), this.rows = A.map((L, V) => {
        const K = k.get(L), Q = this.columns.map((Le) => {
          const Oe = K.find((mt) => mt[w.column] === Le.name);
          return new p(L, Le.name, Oe ? +Oe[w.value] : null, Oe[w.detail]);
        }), ie = new g(L, V, Q);
        return ie.markBounds(), ie;
      });
      const F = this.rows.flatMap((L) => L.cells).filter((L) => L.value).sort((L, V) => L.value - V.value);
      F[0].flag |= b.min, F[F.length - 1].flag |= b.max, F.slice(0, this.numOfTopBottom).forEach((L) => L.flag |= b.bottomGroup), F.slice(-this.numOfTopBottom).forEach((L) => L.flag |= b.topGroup);
      const R = F.reduce((L, V) => L + V.value, 0);
      this.level = this.defaultLevel = this.average = R / F.length, this.min = F[0].value, this.max = F[F.length - 1].value;
    }
  }
  class h {
    constructor(w, k) {
      this.name = w, this.position = k, this.order = y.none;
    }
  }
  class g {
    constructor(w, k, A) {
      this.name = w, this.position = k, this.order = y.none, this.cells = A;
    }
    markBounds() {
      const w = [...this.cells].filter((k) => k.value).sort((k, A) => k.value - A.value);
      w[0].flag |= b.rowMin, w[w.length - 1].flag |= b.rowMax;
    }
  }
  class p {
    constructor(w, k, A, F) {
      this.row = w, this.column = k, this.value = A, this.detail = F, this.flag = b.unspecified;
    }
  }
  class m {
    constructor(w, k, A, F) {
      this.column = w, this.row = k, this.value = A, this.detail = F;
    }
  }
  class y {
    static get none() {
      return 0;
    }
    static get ascending() {
      return 1;
    }
    static get descending() {
      return 2;
    }
  }
  class b {
    static get unspecified() {
      return 0;
    }
    static get min() {
      return 1;
    }
    static get max() {
      return 2;
    }
    static get rowMin() {
      return 4;
    }
    static get rowMax() {
      return 8;
    }
    static get bottomGroup() {
      return 16;
    }
    static get topGroup() {
      return 32;
    }
  }
  class v {
    constructor(w, k, A, F, R) {
      this._svg = w, this._font = k, this._charBox = null, this._box = this._initBox(A, F, R), this.left = 0, this.top = 0, this.getBBox = null, this.calcTextWidth = null, this.calcPosition = null;
    }
    get box() {
      return this._box;
    }
    get offset() {
      return 10;
    }
    show(w, k, A, F) {
      this._charBox || (this._charBox = this.getBBox("M"));
      const R = this, L = 1.4, V = this._calcWidth(k);
      this._box.style("visibility", "visible").select("rect").attr("width", V + 10).attr("height", `${k.length * L + 0.5}em`), K("backtext", "white", 3), K("foretext"), this.move(w, A, F);
      function K(Q, ie, Le) {
        R._box.selectAll("." + Q).data(k).join(
          (Oe) => {
            Oe.append("text").attr("class", Q).attr("dy", (mt, Z) => `${L * Z + 1}em`).attr("stroke", ie).attr("stroke-width", Le).text((mt) => mt);
          },
          (Oe) => Oe.text((mt) => mt),
          (Oe) => Oe.remove()
        );
      }
    }
    // wrap(text, wrapWidth, yAxisAdjustment = 0) {
    //   text.each(function() {
    //     var text = d3.select(this),
    //         words = text.text().split(/\s+/).reverse(),
    //         word,
    //         line = [],
    //         lineNumber = 0,
    //         lineHeight = 1.1, // ems
    //         y = text.attr("y"),
    //         dy = parseFloat(text.attr("dy")) - yAxisAdjustment,
    //         tspan = text.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", `${dy}em`);
    //     while (word = words.pop()) {
    //       line.push(word);
    //       tspan.text(line.join(" "));
    //       if (tspan.node().getComputedTextLength() > wrapWidth) {
    //         line.pop();
    //         tspan.text(line.join(" "));
    //         line = [word];
    //         tspan = text.append("tspan").attr("x", 0).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
    //       }
    //     }
    //   });
    //   return 0;
    // }
    move(w, k, A) {
      if (this._box) {
        const F = k && A ? new DOMPoint(k, A) : this._convertCoordinate(w, this._svg), R = this._box.node().getBBox(), { left: L, top: V } = this.calcPosition(F, R);
        this.left = L + this.offset, this.top = V + this.offset, this._box.attr("transform", `translate(${this.left},${this.top})`);
      }
    }
    hide() {
      this._box && this._box.style("visibility", "hidden");
    }
    _initBox(w, k, A) {
      const F = this._svg.append("g").attr("fill", "black").call((R) => {
        R.append("rect").attr("opacity", k).attr("stroke", A).attr("stroke-width", 0.5).attr("rx", 4).attr("ry", 4).attr("x", -5).attr("y", -5).attr("fill", w);
      });
      return this._font.applyTo(F), F;
    }
    _calcWidth(w) {
      let k = 0;
      return w.forEach((A) => {
        const F = this.calcTextWidth(A);
        F > k && (k = F);
      }), k;
    }
    _convertCoordinate(w, k) {
      const A = this._svg.node().createSVGPoint();
      return A.x = w.clientX, A.y = w.clientY, A.matrixTransform(k.node().getScreenCTM().inverse());
    }
  }
  class _ extends v {
    constructor(w, k, A, F, R) {
      super(w, k, A, F, R), this._pointer = null;
    }
    show(w, k, A, F, R, L) {
      super.show(w, k, A, F);
      const V = this.box.node().getBBox();
      this.move(w, A + R - this.offset, F + R - this.offset);
      const K = this.offset / 2;
      let Q = this.left, ie = this.top, Le = Q - K, Oe = ie - K, mt = Le + 30, Z = Oe + V.height;
      Q < A && (Le = A - R - K, mt = Le - 30, Q = A - R - V.width), ie < F && (Oe = F - R - K, Z = Oe - V.height, ie = F - R - V.height), this.box.attr("transform", `translate(${Q},${ie})`), this._removePointer(), this._pointer = this._svg.append("path").attr("fill", "none").attr("stroke", L).attr("stroke-width", 2).attr("d", `M ${A} ${F} L ${Le} ${Oe} L ${Le} ${Z} L ${mt} ${Z}`);
    }
    hide() {
      super.hide(), this._removePointer();
    }
    _removePointer() {
      this._pointer && (this._pointer.remove(), this._pointer = null);
    }
  }
  class x {
    constructor(w) {
      this._svg = w, this.font = new S(), this.padding = 10, this.margin = { left: 0, right: 0, top: 0, bottom: 0 }, this.width = 0, this.height = 0, this.sliderHeight = 20, this.columnHeight = 0, this.rowWidth = 0, this._minRadius = 25, this.bubbleRadius = 0, this.bubbleDiameter = 0;
    }
    initialize(w, k) {
      this._calculateLabels(w), this._calculateBubbleRadius(w, k);
    }
    _calculateLabels(w) {
      let k = "";
      const A = (F, R) => {
        let L = 0;
        return F.forEach((V) => {
          V = k.concat(V);
          const K = this.calculateStringWidth(V, void 0, R);
          K > L && (L = K);
        }), L;
      };
      this.columnHeight = A(w.columns.map((F) => this.trim(F.name) + "M")), this.rowWidth = this.margin.left + A(w.rows.map((F) => F.name + "MM"), this.font.clone().weight("bold")), this.columnHeight = UP, this.rowWidth = ES;
    }
    _calculateBubbleRadius(w, k) {
      const A = this.width - this.rowWidth, F = this.height - this.columnHeight - this.padding * 2 - (k ? this.sliderHeight : 0), R = w.rows.length, L = w.columns.length, V = (F / R - this.padding) / 2, K = A / L / 2;
      if (V < K)
        this.bubbleRadius = V;
      else {
        const Q = R * K;
        this.bubbleRadius = K > F ? K - (Q - F) / R / 2 : K;
      }
      this.bubbleRadius < this._minRadius && (this.bubbleRadius = this._minRadius), this.bubbleDiameter = this.bubbleRadius * 2;
    }
    getBBox(w, k, A) {
      const F = A ?? this.font, R = this._svg.select("text");
      return R ? (F.applyTo(R), R.text(w), k && R.attr("transform", `rotate(${k})`), R.node().getBBox()) : null;
    }
    calculateStringWidth(w, k, A) {
      const F = this.getBBox(w, k, A);
      return F ? Math.sqrt(F.width * F.width + F.height * F.height) : w.length * this.font.size;
    }
    trim(w) {
      return w.length > 100 ? `${w.substr(0, 10)}...` : w;
    }
  }
  class S {
    constructor(w = "", k = "10pt", A = "normal", F = "normal") {
      this._family = w, this._size = k, this._style = A, this._weight = F;
    }
    family(w) {
      return arguments.length ? (this._family = w, this) : this._family;
    }
    size(w) {
      return arguments.length ? (this._size = w, this) : this._size;
    }
    style(w) {
      return arguments.length ? (this._style = w, this) : this._style;
    }
    weight(w) {
      return arguments.length ? (this._weight = w, this) : this._weight;
    }
    applyTo(w) {
      w = w instanceof HTMLElement ? An.select(w) : w, w.style("font-family", this._family).style("font-size", isNaN(+this._size) ? this._size : `${this._size}pt`).style("font-style", this._style).style("font-weight", this._weight);
    }
    clone() {
      return new S(this._family, this._size, this._style, this._weight);
    }
  }
  class E {
    constructor(w) {
      this._chart = w, this.chartArea = this._createDiv(), this.mainBlock = this._createDiv(), this.slider = this._createDiv(), this.columnBlock = this._createDiv(), this.placeHolder = this._createDiv(), this.columns = this._createDiv(), this.matrixBlock = this._createDiv(), this.rows = this._createDiv(), this.matrix = this._createDiv();
    }
    initialize() {
      this._initStyles(), this._initLayout(), this._adjustSize();
    }
    adjustScrollableBlocks() {
      const w = this.matrix.offsetHeight - this.matrix.clientHeight, k = this.matrix.offsetWidth - this.matrix.clientWidth;
      w && (this.rows.style.height = `${this.rows.clientHeight - w}px`), k && (this.columns.style.width = `${this.columns.clientWidth - k}px`);
    }
    changeFont(w) {
      this.chartArea.style.font = w.shorthand;
    }
    _adjustSize() {
      const w = this._chart.measures;
      this.chartArea.style.height = `${w.height}px`, this._chart.options().showSlider && (this.slider.style.height = `${w.sliderHeight}px`), this.columns.style.height = `${w.columnHeight}px`, this.columns.style.width = `${w.width - w.rowWidth - w.margin.left}px`, this.placeHolder.style.width = `${w.rowWidth + w.margin.left}px`, this.placeHolder.style.height = `${w.columnHeight}px`, this.rows.style.width = `${w.rowWidth + w.margin.left}px`, this.matrix.style.width = `${w.width + w.margin.right + w.rowWidth}px`;
    }
    _createDiv() {
      return document.createElement("div");
    }
    _initStyles() {
      const w = this._chart.measures, k = w.width + w.margin.left + w.margin.right;
      let A = this.chartArea.style;
      A.display = "flex", A.flexDirection = "column", A.cursor = "default", A.userSelect = "none", w.font.applyTo(this.chartArea), A = this.mainBlock.style, A.display = "flex", A.flexDirection = "column", A.flexGrow = 1, A.height = "1px", A = this.columnBlock.style, A.textAlign = "left", A.display = "flex", A.flexDirection = "row", A.flexShrink = 0, A.width = "1px", A = this.placeHolder.style, A.flexShrink = 0, A.backgroundColor = "white", A = this.columns.style, A.paddingTop = "5px", A.paddingBottom = "5px", A.overflow = "hidden", A.flexShrink = 0, A.width = `${k}px`, A = this.matrixBlock.style, A.display = "flex", A.flexDirection = "row", A.flexGrow = 0, A.width = "1px", A.overflowY = "auto", A.textAlign = "left", A.width = `${k}px`, A = this.rows.style, A.overflow = "hidden", A.flexShrink = 0, A = this.matrix.style, A.overflowX = "auto", this.matrix.onscroll = (F) => {
        this.columns.scrollLeft = this.matrix.scrollLeft, this.rows.scrollTop = this.matrix.scrollTop;
      };
    }
    _initLayout() {
      this.chartArea.appendChild(this.mainBlock), this.mainBlock.appendChild(this.slider), this.mainBlock.appendChild(this.columnBlock), this.mainBlock.appendChild(this.matrixBlock), this.columnBlock.appendChild(this.placeHolder), this.columnBlock.appendChild(this.columns), this.matrixBlock.appendChild(this.rows), this.matrixBlock.appendChild(this.matrix);
    }
  }
  class C {
    constructor(w) {
      this.chart = w, this.colors = {
        row: "#caf0f8",
        above: "#ffd166",
        below: "#118ab2",
        label: "black"
      }, this.matrix = { svg: null, g: null, og: null, ig: null }, this.columns = new N(this), this.rows = new O(this), this._uuid = `uu${Date.now()}${Math.floor(Math.random() * 1e4)}`;
    }
    render() {
      this._initMatrix(), this._renderGradients(), this.columns.render(), this.rows.render();
    }
    _createSvg(w, k, A) {
      return An.select(w).append("svg").attr("width", k + 100).attr("height", A);
    }
    _transform(w, k) {
      return `translate(${w},${k})`;
    }
    _initMatrix() {
      const w = this.chart, k = this.matrix;
      k.svg = this._createSvg(w.partitions.matrix, w.scales.maxX, w.scales.maxY), k.g = k.svg.append("g"), k.og = k.g.append("g"), k.ig = k.svg.append("g").attr("transform", this._transform(0, w.measures.padding / 2));
    }
    uid(w) {
      return `${this._uuid}_${w}`;
    }
    _renderGradients() {
      const w = this.chart, k = (A) => {
        this.matrix.g.append("linearGradient").attr("id", this.uid(A ? "descending" : "ascending")).attr("x1", 0).attr("x2", w.measures.rowWidth + w.chartData.columns.length * w.measures.bubbleDiameter).attr("y1", "100%").attr("y2", "100%").attr("gradientUnits", "userSpaceOnUse").call((F) => {
          F.append("stop").attr("stop-color", this.colors.row).attr("stop-opacity", A ? 1 : 0).attr("offset", 0), F.append("stop").attr("stop-color", this.colors.row).attr("stop-opacity", A ? 0 : 1).attr("offset", 1);
        });
      };
      k(!1), k(!0);
    }
  }
  class $ {
    constructor(w) {
      this._mainRenderer = w, this.duration = 500;
    }
    get chart() {
      return this._mainRenderer.chart;
    }
    get matrix() {
      return this._mainRenderer.matrix;
    }
    get colors() {
      return this._mainRenderer.colors;
    }
    get rows() {
      return this._mainRenderer.rows;
    }
    get columns() {
      return this._mainRenderer.columns;
    }
    uid(w) {
      return this._mainRenderer.uid(w);
    }
    url(w) {
      return `url(#${w})`;
    }
  }
  class N extends $ {
    constructor(w) {
      super(w), this.text = null, this._arrow = null, this.labels = null, this.axis = null, this._focused = null, this.sortOnAxisClick = !0;
    }
    render() {
      const w = this.chart, F = An.select(w.partitions.columns).append("svg").attr("width", w.scales.maxX + w.measures.rowWidth + 0).attr("height", w.measures.columnHeight + 0).append("g");
      this.labels = this._renderGroups(F, `translate(0,${w.measures.columnHeight})`, "start", (R) => {
        this.text = R.append("text").attr("y", 0).attr("dy", "-0.25em").attr("transform", "rotate(-45)").attr("fill", this.colors.label).text(this._trim.bind(this)).on("click", this._click.bind(this)).on("pointerenter", this._handlePointerEnter.bind(this)).on("pointerleave", this._handlePointerLeave.bind(this));
      }), this.axis = this._renderGroups(this.matrix.og, void 0, "middle", (R) => {
        R.append("line").attr("y1", 0).attr("y2", w.scales.maxY).attr("stroke-width", 1).attr("stroke", "#8d99ae");
      });
    }
    _renderGroups(w, k, A, F) {
      const R = this.chart, L = w.append("g");
      return k && L.attr("transform", k), L.selectAll("g").data(R.chartData.columns).join("g").attr("text-anchor", A).attr("transform", (V, K) => `translate(${R.scales.x(K) + R.measures.bubbleRadius},0)`).call(F);
    }
    _trim(w) {
      return this.chart.measures.trim("" + w.name);
    }
    _click(w, k) {
      this._sort(k), this._arrow && this._arrow.attr("d", (A) => {
        if (k.order !== y.none && k.name === A.name) {
          const F = this.chart.measures.getBBox(this._trim(A)), R = F.height / 2 + 1, L = F.width, V = 5;
          return k.order === y.descending ? `M 0 ${R} L ${L} ${R} L ${L} ${R + V} L 0 ${R}` : `M 0 ${R} L 0 ${R + V} L ${L} ${R} L 0 ${R}`;
        }
      }), this._focused !== k ? (this.columns.axis.select("line").attr("stroke-width", (A) => A.name === k.name ? 2 : 1), this.columns.text.attr("font-weight", (A) => A.name === k.name ? "bold" : ""), this._focused = k, l("message", {
        selection_type: "col",
        col: "" + k.name,
        row: null,
        sortOrder: k.order
      }), this.rows._rowFocused != null && (this.rows._bubbleRects.attr("stroke-width", 0), this.rows._labelRects.attr("stroke-width", 0), this.rows._rowFocused = null)) : (this.columns.axis.select("line").attr("stroke-width", 1), this.columns.text.attr("font-weight", ""), this._focused = null, l("message", {
        selection_type: "col",
        col: null,
        row: null,
        sortOrder: k.order
      }));
    }
    _sort(w) {
      if (this.sortOnAxisClick) {
        let K = function(Q) {
          Q.transition().duration((ie, Le) => Le * V).attr("transform", (ie) => {
            let Le = 0;
            for (let Oe = 0; Oe < L.length; Oe++)
              if (L[Oe].row === ie) {
                ie.position = Le = Oe;
                break;
              }
            return `translate(0,${k.chart.scales.y(Le)})`;
          });
        };
        const k = this, A = this.chart.chartData, F = A.columns, R = F.indexOf(w), L = A.rows.map((Q) => ({ row: Q, column: Q.cells[R] }));
        A.resetColumns(w), w.order === y.none ? w.order = y.descending : w.order === y.descending ? w.order = y.ascending : w.order = y.none, w.order === y.ascending ? L.sort((Q, ie) => Q.column.value - ie.column.value) : w.order === y.descending && L.sort((Q, ie) => ie.column.value - Q.column.value);
        const V = this.duration / A.rows.length;
        K(this.rows.axis), K(this.rows.labels), this.rows.relocateAnnotation();
      }
    }
    _handlePointerEnter(w, k) {
      this.onhover && this.onhover(w, k), this.axis.select("line").attr("stroke-width", (A) => A.name === k.name || this._focused != null && A.name === this._focused.name ? 2 : 1), this.text.attr("font-weight", (A) => A.name === k.name || this._focused != null && A.name === this._focused.name ? "bold" : "");
    }
    _handlePointerLeave(w, k) {
      this._focused == null ? (this.oncancel && this.oncancel(w, k), this.axis.select("line").attr("stroke-width", 1), this.text.attr("font-weight", "")) : (this.axis.select("line").attr("stroke-width", (A) => A.name === this._focused.name ? 2 : 1), this.text.attr("font-weight", (A) => A.name === this._focused.name ? "bold" : ""));
    }
  }
  class O extends $ {
    constructor(w) {
      super(w), this._tooltip = null, this._annotation = null, this.labels = null, this.axis = null, this.highlight = P.matrix, this.showTooltip = !0, this.showAnnotation = !0, this.sortOnAxisClick = !0, this._labelRects = null, this._bubbleRects = null, this._bubbles = null, this._focused = null, this._rowFocused = null, this.onhover = null, this.oncancel = null, this.onclick = null;
    }
    get bubbles() {
      return this._bubbles;
    }
    render() {
      this._initInfoLayer();
      const w = this.chart, k = An.select(w.partitions.rows).append("svg").attr("width", w.measures.rowWidth).attr("height", w.scales.maxY).append("g").attr("transform", `translate(0,${w.measures.padding / 2})`);
      this.labels = this._renderGroups(k, (F) => {
        this._labelRects = this._renderRect(F, 1, w.measures.rowWidth + 10).on("click", this._click.bind(this)), F.append("text").attr("font-weight", "bold").attr("y", w.measures.bubbleRadius).attr("dx", "1em").attr("dy", "0.25em").attr("fill", this.colors.label).text((R) => R.name).on("click", this._click.bind(this));
      });
      const A = w.chartData.columns.length * w.measures.bubbleDiameter;
      this.axis = this._renderGroups(this.matrix.ig.append("g"), (F) => {
        this._bubbleRects = this._renderRect(F, -11, A + 10), this._bubbles = F.append("g").selectAll("g").data((R) => R.cells).join("g").attr("transform", (R, L) => `translate(${w.scales.x(L) + w.measures.bubbleRadius},0)`).call((R) => {
          R.append("circle").attr("class", "bubble").attr("fill", (L) => L.value >= w.chartData.average ? this.colors.above : this.colors.below).attr("opacity", 0.5).attr("stroke-width", 2).attr("cy", w.measures.bubbleRadius).attr("r", 0);
        }).on("click", this._handleClick.bind(this)), this._bubbles.selectAll("circle").transition().ease(An.easeBounce).duration(500).attr("r", (R) => R.value ? w.scales.r(R.value) : 0);
      });
    }
    // this.highlightBubbles(); // TEMP: remove highlighting
    relocateAnnotation(w = !0) {
      if (this._focused) {
        const k = () => this._showAnnotation(null, this._focused);
        this._annotation.hide(), w ? setTimeout(k, this.duration) : k();
      }
    }
    _handleClick(w, k) {
      this.chart, this.onclick && this.onclick(w, k);
    }
    _showAnnotation(w, k) {
    }
    // const
    //     a = this._annotation,
    //     getPosition = (axis, name) => {
    //         const obj = axis.find(d => d.name === name);
    //         return obj ? obj.position : 0;
    //     }
    // if (this.showAnnotation) {
    //     const
    //         cx = c.scales.x(getPosition(c.chartData.columns, d.column)),
    //         cy = c.scales.y(getPosition(c.chartData.rows, d.row)),
    //         r = c.scales.r(d.value),
    //         color = d.value >= c.chartData.level ? this.colors.above : this.colors.below;
    //     this._focused = d;
    //     a.hide();
    //     a.show(
    //         null, this._getTooltipContent(d),
    //         cx + c.measures.bubbleRadius,
    //         cy + c.measures.bubbleRadius + c.measures.padding / 2,
    //         r, d3.color(color).darker(1));
    // }
    _handlePointerEnter(w, k) {
      this.chart, this.onhover && this.onhover(w, k), this.columns.axis.select("line").attr("stroke-width", (A) => A.name === k.column ? 2 : 1), this.columns.text.attr("font-weight", (A) => A.name === k.column ? "bold" : "");
    }
    // if (this._focused == null) {
    //     // if (this.showTooltip) this._tooltip.show(e, this._getTooltipContent(d));
    //     if (this.onhover) this.onhover(e, d);
    //     this.columns.axis.select("line").attr("stroke-width", col => col.name === d.column ? 2 : 1);
    //     this.columns.text.attr("font-weight", col => col.name === d.column ? "bold" : "");
    //     dispatch("message", {selection_type: "cell", row: ("" + d.row) , col: ("" + d.column)})
    //     // Add shadow
    //     this._bubbles.filter(b => b === d)
    //     .call(g => {
    //         // g.select(".bubble").attr("transform", "translate(1,-1.5)");
    //         g.insert("circle", "circle")
    //         .attr("class", "shadow")
    //         .attr("cy", c.measures.bubbleRadius)
    //         .attr("r", d => d.value ? c.scales.r(d.value) : 0)
    //         .attr("fill", d => {
    //             const color = d.value >= c.chartData.level ? this.colors.above : this.colors.below;
    //             return d3.color(color).darker(1);
    //         })
    //     });  // TEMP: remove threshold-based circle coloring
    // }
    _handlePointerMove(w) {
      this.showTooltip && this._tooltip.move(w);
    }
    _handlePointerLeave(w, k) {
      this._focused == null && (this.oncancel && this.oncancel(w, k), this.columns.axis.select("line").attr("stroke-width", 1), this.columns.text.attr("font-weight", ""));
    }
    //         g.select(".bubble").attr("transform", "");
    //     });
    highlightBubbles(w) {
      const k = this.chart.measures.bubbleRadius, A = (K) => this.highlight === P.byRow && ((K.flag & b.rowMin) === b.rowMin || (K.flag & b.rowMax) === b.rowMax), F = (K) => this.highlight === P.matrix && ((K.flag & b.min) === b.min || (K.flag & b.max) === b.max), R = (K) => this.highlight === P.top && (K.flag & b.topGroup) === b.topGroup, L = (K) => this.highlight === P.bottom && (K.flag & b.bottomGroup) === b.bottomGroup, V = this._bubbles.filter((K) => K.value && (A(K) || F(K) || R(K) || L(K)));
      V.select("circle").attr("stroke", (K) => {
        const Q = K.value >= this.chart.chartData.level ? this.colors.above : this.colors.below;
        return An.color(Q).darker(0.75);
      }), w || V.append("text").attr("text-anchor", "middle").attr("y", (K) => {
        const Q = this.chart.scales.r(K.value);
        return this.chart.measures.calculateStringWidth(this._formatValue(K.value)) + 5 > Q * 2 ? k + Q + 12 : k;
      }).attr("dy", "0.3em").attr("fill", this.colors.label).attr("font-weight", "bold").text((K) => this._formatValue(K.value));
    }
    _formatValue(w, k = !0) {
      const A = this.chart.chartData.numberIsPercentage ? ".1%" : k ? ".2s" : ",.2f";
      return An.format(A)(w);
    }
    _initInfoLayer() {
      const w = this, k = this.chart.measures.font;
      if (this.showAnnotation) {
        const F = k.clone().family("system-ui").size("11px").weight("bold");
        this._annotation = new _(this.matrix.svg, F, "none"), A(this._annotation, F);
      }
      this.showTooltip && (this._tooltip = new v(this.matrix.svg, k, "white", 0.7, "#aaa"), A(this._tooltip, k));
      function A(F, R) {
        F.getBBox = (L) => w.chart.measures.getBBox(L, void 0, R), F.calcTextWidth = (L) => w.chart.measures.calculateStringWidth(L, void 0, R), F.calcPosition = (L, V) => w._calcTooltipPosition(L, V);
      }
    }
    _getTooltipContent(w) {
      const k = this.chart.fieldNames;
      return [
        `${k.row}: ${w.row}`,
        `${k.column}: ${w.column}`,
        `${k.value}: ${this._formatValue(w.value, !1)}`,
        `${k.detail}: ${w.detail.slice(0, 50)}...`
      ];
    }
    _calcTooltipPosition(w, k) {
      const A = this.matrix.svg.node().getBoundingClientRect(), F = w.x + A.left, R = w.y + A.top, L = 5, V = F + k.width + L > A.right ? w.x - k.width - L : w.x + L, K = R + k.height + L > A.bottom ? w.y - k.height - L : w.y + L;
      return { left: V, top: K };
    }
    _renderGroups(w, k) {
      const A = this.chart;
      return w.selectAll("g").data(A.chartData.rows).join("g").attr("transform", (F, R) => `translate(0,${A.scales.y(R)})`).call(k).on("click", this._rowClick.bind(this)).on("pointerenter", (F, R) => {
        this._bubbleRects.attr("opacity", (L) => L.name === R.name ? 0.8 : 0.5), this._labelRects.attr("opacity", (L) => L.name === R.name ? 0.8 : 0.5);
      }).on("pointerleave", (F, R) => {
        this._bubbleRects.attr("opacity", 0.5), this._labelRects.attr("opacity", 0.5);
      });
    }
    _rowClick(w, k) {
      this._rowFocused !== k ? (this._bubbleRects.attr("stroke-width", (A) => A.name === k.name ? 2 : 0), this._labelRects.attr("stroke-width", (A) => A.name === k.name ? 2 : 0), this._rowFocused = k, l("message", {
        selection_type: "row",
        row: "" + k.name,
        col: null,
        sortOrder: k.order
      }), this.columns._focused != null && (this.columns.axis.select("line").attr("stroke-width", 1), this.columns.text.attr("font-weight", ""), this.columns._focused = null)) : (this._bubbleRects.attr("stroke-width", 0), this._labelRects.attr("stroke-width", 0), this._rowFocused = null, l("message", {
        selection_type: "row",
        row: null,
        col: null,
        sortOrder: k.order
      }));
    }
    _renderRect(w, k, A) {
      const F = this.chart;
      return w.append("rect").attr("width", A).attr("height", F.measures.bubbleDiameter).attr("x", k).attr("rx", 10).attr("opacity", 0.5).attr("fill", this.colors.row).attr("stroke", An.color(this.colors.row).darker(1)).attr("stroke-width", 0);
    }
    _click(w, k) {
      this._sort(k), this._labelRects.attr("fill", (A) => A.order === y.ascending ? "white" : this.colors.row), this._bubbleRects.attr("fill", (A) => {
        if (A.order === y.none)
          return this.colors.row;
        {
          const F = this.uid(A.order === y.ascending ? "ascending" : "descending");
          return A === k ? this.url(F) : this.colors.row;
        }
      });
    }
    _sort(w) {
      if (this.sortOnAxisClick) {
        let K = function(Q) {
          Q.transition().duration((ie, Le) => Le * R).attr("transform", (ie) => {
            let Le = 0;
            for (let Oe = 0; Oe < F.length; Oe++)
              if (F[Oe].column === ie.name) {
                ie.position = Le = Oe, k.push(Oe);
                break;
              }
            return `translate(${L(Le) + V},0)`;
          });
        };
        const k = [], A = this.chart.chartData, F = w.cells.map((Q) => Q);
        A.resetRows(w), w.order === y.none ? w.order = y.descending : w.order === y.descending ? w.order = y.ascending : w.order = y.none, w.order === y.ascending ? F.sort((Q, ie) => Q.value - ie.value) : w.order === y.descending && F.sort((Q, ie) => ie.value - Q.value);
        const R = this.duration / A.columns.length, L = this.chart.scales.x, V = this.chart.measures.bubbleRadius;
        K(this.columns.axis), K(this.columns.labels), this.relocateAnnotation(), this._bubbles.transition().duration((Q, ie) => ie * R).attr("transform", (Q, ie) => `translate(${L(k[ie]) + V},0)`);
      }
    }
  }
  class P {
    static get matrix() {
      return 0;
    }
    static get byRow() {
      return 1;
    }
    static get top() {
      return 2;
    }
    static get bottom() {
      return 3;
    }
  }
  class T {
    constructor() {
      this.x = null, this.y = null, this.r = null, this._maxX = 0, this._maxY = 0;
    }
    get maxX() {
      return this._maxX;
    }
    get maxY() {
      return this._maxY;
    }
    initialize(w) {
      const k = w.measures, A = w.chartData;
      this.x = (F) => F * k.bubbleDiameter, this.y = (F) => F * (k.bubbleDiameter + k.padding), this.r = An.scaleLinear().domain([A.min, A.max]).range([k.bubbleRadius * 0.2, k.bubbleRadius - 1.5]), this._maxX = this.x(A.columns.length), this._maxY = this.y(A.rows.length);
    }
  }
  class D {
    constructor(w, k) {
      this._chart = w, this._caption = k, this._g = null, this._label = null, this._below = null, this._above = null, this._width = 0, this._min = 0, this._max = 0, this._defaultValue = 0;
    }
    get level() {
      return this._chart.chartData.level;
    }
    set level(w) {
      this._chart.chartData.level = w;
    }
    get defaultLevel() {
      return this._chart.chartData.defaultLevel;
    }
    get isPercent() {
      return this._chart.chartData.numberIsPercentage;
    }
    get height() {
      return this._chart.measures.sliderHeight;
    }
    get rowRenderer() {
      return this._chart.renderer.rows;
    }
    render() {
      const w = this._chart.measures;
      this._initialize(), this._g = An.select(this._chart.partitions.slider).append("svg").attr("width", w.width).attr("height", this.height).append("g"), this._renderLabel(), this._renderColorRects(), this._renderSlider();
    }
    _initialize() {
      const w = this._chart.measures, k = this._chart.chartData;
      this._defaultValue = this.isPercent ? this.defaultLevel * 100 : this._roundUp(this.defaultLevel, 1), this._width = (w.width - w.rowWidth) / 2;
      let A = k.min, F = k.max;
      this.isPercent && (A = A * 100, F = F * 100 + 1, A = A > 0 ? A - 1 : A), this._min = A, this._max = F;
    }
    _renderLabel() {
      this._label = this._g.append("text").attr("x", this._width + 12).attr("y", 10).attr("dy", "0.5em").attr("fill", "black"), this._updateLabel(this._defaultValue);
    }
    _renderColorRects() {
      const { a: w, b: k } = this._getSafeBound(), A = (this._defaultValue - w) / (k - w) * this._width;
      this._below = this._g.append("rect").attr("y", 2).attr("rx", 5).attr("width", A).attr("height", this.height - 2).attr("opacity", 0.5).attr("fill", this._chart.renderer.colors.below), this._above = this._g.append("rect").attr("x", A).attr("y", 2).attr("rx", 5).attr("width", this._width - A).attr("height", this.height - 2).attr("opacity", 0.5).attr("fill", this._chart.renderer.colors.above);
    }
    _renderSlider() {
      const { a: w, b: k } = this._getSafeBound(), A = this._g.append("foreignObject").attr("width", this._width + 2).attr("height", this.height);
      this._slider = A.append("xhtml:input").attr("type", "range").attr("min", w).attr("max", k).style("width", `${this._width - 5}px`).style("height", `${this._height}px`).on("click", (F) => F.stopPropagation()).on("dblclick", (F) => {
        this._slider.node().value = this._defaultValue, this._change(), F.stopPropagation();
      }).on("input", () => this._change()), this._slider.node().value = this._defaultValue;
    }
    _change() {
      const { a: w, b: k } = this._getSafeBound(), A = +this._slider.node().value, F = A < w ? w : A > k ? k : A, R = (F - w) / (k - w) * this._width;
      this._below.attr("width", R), this._above.attr("x", R).attr("width", this._width - R), this._updateLabel(A), this.level = this.isPercent ? A / 100 : A;
      const L = this._chart.renderer.colors;
      this.rowRenderer.bubbles.selectAll("circle").transition().duration(1e3).ease(An.easeBounce).attr("fill", (V) => V.value >= this.level ? L.above : L.below).attr("opacity", 0.5), this.rowRenderer.relocateAnnotation(!1);
    }
    _getSafeBound() {
      const w = this.isPercent ? this._min : this._roundDown(this._min, 2), k = this.isPercent ? this._max : this._roundUp(this._max, 2);
      return { a: w, b: k };
    }
    _roundUp(w, k) {
      const A = w < 0 ? -1 : 1, F = Math.ceil(Math.abs(w)).toString(), R = Math.pow(10, F.length - k);
      return Math.ceil(+F / R) * R * A;
    }
    _roundDown(w, k) {
      const A = w < 0 ? -1 : 1, F = w < 0 ? 1 : 0, R = Math.floor(Math.abs(w)).toString(), L = Math.pow(10, R.length - k);
      return (Math.floor(+R / L) + F) * L * A;
    }
    _updateLabel(w) {
      const k = w.toFixed(0), A = this.isPercent ? `${k}%` : An.format(",.2r")(k);
      this._label.text(`${this._caption} = ${A}`);
    }
  }
  return e.$$set = (M) => {
    "data" in M && n(0, i = M.data), "div" in M && n(1, r = M.div), "numConcepts" in M && n(2, s = M.numConcepts), "numSlices" in M && n(3, o = M.numSlices);
  }, [i, r, s, o];
}
class VP extends Ms {
  constructor(t) {
    super(), $s(this, t, GP, jP, Cs, {
      data: 0,
      div: 1,
      numConcepts: 2,
      numSlices: 3
    });
  }
}
function SS(e, t, n) {
  const i = e.slice();
  return i[56] = t[n], i[58] = n, i;
}
const YP = (e) => ({ row: e[0] & /*c_rows*/
8 }), kS = (e) => ({ row: (
  /*row*/
  e[56]
), n: (
  /*n*/
  e[58]
) });
function AS(e, t, n) {
  const i = e.slice();
  return i[59] = t[n], i[61] = n, i;
}
const XP = (e) => ({ row: e[0] & /*c_rows*/
8 }), CS = (e) => ({ row: (
  /*row*/
  e[56]
), n: (
  /*n*/
  e[58]
) });
function $S(e, t, n) {
  const i = e.slice();
  return i[59] = t[n], i;
}
const KP = (e) => ({
  sortOrder: e[0] & /*sortOrder*/
  2,
  sortBy: e[0] & /*sortBy*/
  1
}), MS = (e) => ({
  sortOrder: (
    /*sortOrder*/
    e[1]
  ),
  sortBy: (
    /*sortBy*/
    e[0]
  )
});
function FS(e, t, n) {
  const i = e.slice();
  return i[59] = t[n], i[64] = t, i[65] = n, i;
}
function TS(e, t, n) {
  const i = e.slice();
  return i[66] = t[n], i;
}
function JP(e) {
  let t, n, i = Rn(
    /*columns*/
    e[4]
  ), r = [];
  for (let o = 0; o < i.length; o += 1)
    r[o] = NS(FS(e, i, o));
  let s = (
    /*showExpandIcon*/
    e[11] && DS()
  );
  return {
    c() {
      t = pe("tr");
      for (let o = 0; o < r.length; o += 1)
        r[o].c();
      n = ft(), s && s.c(), he(t, "class", "svelte-dsaf7t");
    },
    m(o, a) {
      Se(o, t, a);
      for (let l = 0; l < r.length; l += 1)
        r[l] && r[l].m(t, null);
      ve(t, n), s && s.m(t, null);
    },
    p(o, a) {
      if (a[0] & /*asStringArray, columns, classNameInput, filterSelections, classNameSelect, filterValues*/
      75595796) {
        i = Rn(
          /*columns*/
          o[4]
        );
        let l;
        for (l = 0; l < i.length; l += 1) {
          const u = FS(o, i, l);
          r[l] ? r[l].p(u, a) : (r[l] = NS(u), r[l].c(), r[l].m(t, n));
        }
        for (; l < r.length; l += 1)
          r[l].d(1);
        r.length = i.length;
      }
      /*showExpandIcon*/
      o[11] ? s || (s = DS(), s.c(), s.m(t, null)) : s && (s.d(1), s = null);
    },
    d(o) {
      o && _e(t), Ja(r, o), s && s.d();
    }
  };
}
function QP(e) {
  let t, n, i = (
    /*col*/
    (e[59].filterPlaceholder || "") + ""
  ), r, s, o, a, l = Rn(
    /*filterValues*/
    e[23][
      /*col*/
      e[59].key
    ]
  ), u = [];
  for (let f = 0; f < l.length; f += 1)
    u[f] = OS(TS(e, l, f));
  function c() {
    e[44].call(
      t,
      /*col*/
      e[59]
    );
  }
  return {
    c() {
      t = pe("select"), n = pe("option"), r = ei(i);
      for (let f = 0; f < u.length; f += 1)
        u[f].c();
      n.__value = void 0, yf(n, n.__value), he(t, "class", s = ot(
        /*asStringArray*/
        e[26](
          /*classNameSelect*/
          e[15]
        )
      ) + " svelte-dsaf7t"), /*filterSelections*/
      e[2][
        /*col*/
        e[59].key
      ] === void 0 && ng(c);
    },
    m(f, d) {
      Se(f, t, d), ve(t, n), ve(n, r);
      for (let h = 0; h < u.length; h += 1)
        u[h] && u[h].m(t, null);
      bS(
        t,
        /*filterSelections*/
        e[2][
          /*col*/
          e[59].key
        ],
        !0
      ), o || (a = Cr(t, "change", c), o = !0);
    },
    p(f, d) {
      if (e = f, d[0] & /*columns*/
      16 && i !== (i = /*col*/
      (e[59].filterPlaceholder || "") + "") && xs(r, i), d[0] & /*filterValues, columns*/
      8388624) {
        l = Rn(
          /*filterValues*/
          e[23][
            /*col*/
            e[59].key
          ]
        );
        let h;
        for (h = 0; h < l.length; h += 1) {
          const g = TS(e, l, h);
          u[h] ? u[h].p(g, d) : (u[h] = OS(g), u[h].c(), u[h].m(t, null));
        }
        for (; h < u.length; h += 1)
          u[h].d(1);
        u.length = l.length;
      }
      d[0] & /*classNameSelect*/
      32768 && s !== (s = ot(
        /*asStringArray*/
        e[26](
          /*classNameSelect*/
          e[15]
        )
      ) + " svelte-dsaf7t") && he(t, "class", s), d[0] & /*filterSelections, columns, filterValues*/
      8388628 && bS(
        t,
        /*filterSelections*/
        e[2][
          /*col*/
          e[59].key
        ]
      );
    },
    d(f) {
      f && _e(t), Ja(u, f), o = !1, a();
    }
  };
}
function ZP(e) {
  let t, n, i, r, s;
  function o() {
    e[43].call(
      t,
      /*col*/
      e[59]
    );
  }
  return {
    c() {
      t = pe("input"), he(t, "class", n = ot(
        /*asStringArray*/
        e[26](
          /*classNameInput*/
          e[16]
        )
      ) + " svelte-dsaf7t"), he(t, "placeholder", i = /*col*/
      e[59].filterPlaceholder);
    },
    m(a, l) {
      Se(a, t, l), yf(
        t,
        /*filterSelections*/
        e[2][
          /*col*/
          e[59].key
        ]
      ), r || (s = Cr(t, "input", o), r = !0);
    },
    p(a, l) {
      e = a, l[0] & /*classNameInput*/
      65536 && n !== (n = ot(
        /*asStringArray*/
        e[26](
          /*classNameInput*/
          e[16]
        )
      ) + " svelte-dsaf7t") && he(t, "class", n), l[0] & /*columns, filterValues*/
      8388624 && i !== (i = /*col*/
      e[59].filterPlaceholder) && he(t, "placeholder", i), l[0] & /*filterSelections, columns, filterValues*/
      8388628 && t.value !== /*filterSelections*/
      e[2][
        /*col*/
        e[59].key
      ] && yf(
        t,
        /*filterSelections*/
        e[2][
          /*col*/
          e[59].key
        ]
      );
    },
    d(a) {
      a && _e(t), r = !1, s();
    }
  };
}
function OS(e) {
  let t, n = (
    /*option*/
    e[66].name + ""
  ), i, r;
  return {
    c() {
      t = pe("option"), i = ei(n), t.__value = r = /*option*/
      e[66].value, yf(t, t.__value);
    },
    m(s, o) {
      Se(s, t, o), ve(t, i);
    },
    p(s, o) {
      o[0] & /*filterValues, columns*/
      8388624 && n !== (n = /*option*/
      s[66].name + "") && xs(i, n), o[0] & /*filterValues, columns*/
      8388624 && r !== (r = /*option*/
      s[66].value) && (t.__value = r, yf(t, t.__value));
    },
    d(s) {
      s && _e(t);
    }
  };
}
function NS(e) {
  let t, n;
  function i(o, a) {
    if (!/*col*/
    o[59].hideFilterHeader && /*col*/
    o[59].searchValue !== void 0)
      return ZP;
    if (!/*col*/
    o[59].hideFilterHeader && /*filterValues*/
    o[23][
      /*col*/
      o[59].key
    ] !== void 0)
      return QP;
  }
  let r = i(e), s = r && r(e);
  return {
    c() {
      t = pe("th"), s && s.c(), he(t, "class", n = ot(
        /*asStringArray*/
        e[26]([
          /*col*/
          e[59].headerFilterClass
        ])
      ) + " svelte-dsaf7t");
    },
    m(o, a) {
      Se(o, t, a), s && s.m(t, null);
    },
    p(o, a) {
      r === (r = i(o)) && s ? s.p(o, a) : (s && s.d(1), s = r && r(o), s && (s.c(), s.m(t, null))), a[0] & /*columns, filterValues*/
      8388624 && n !== (n = ot(
        /*asStringArray*/
        o[26]([
          /*col*/
          o[59].headerFilterClass
        ])
      ) + " svelte-dsaf7t") && he(t, "class", n);
    },
    d(o) {
      o && _e(t), s && s.d();
    }
  };
}
function DS(e) {
  let t;
  return {
    c() {
      t = pe("th");
    },
    m(n, i) {
      Se(n, t, i);
    },
    d(n) {
      n && _e(t);
    }
  };
}
function eI(e) {
  let t, n;
  return {
    c() {
      t = new Ip(!1), n = Zf(), t.a = n;
    },
    m(i, r) {
      t.m(
        /*iconSortable*/
        e[8],
        i,
        r
      ), Se(i, n, r);
    },
    p(i, r) {
      r[0] & /*iconSortable*/
      256 && t.p(
        /*iconSortable*/
        i[8]
      );
    },
    d(i) {
      i && (_e(n), t.d());
    }
  };
}
function tI(e) {
  let t, n = (
    /*sortOrder*/
    (e[1] === 1 ? (
      /*iconAsc*/
      e[6]
    ) : (
      /*iconDesc*/
      e[7]
    )) + ""
  ), i;
  return {
    c() {
      t = new Ip(!1), i = Zf(), t.a = i;
    },
    m(r, s) {
      t.m(n, r, s), Se(r, i, s);
    },
    p(r, s) {
      s[0] & /*sortOrder, iconAsc, iconDesc*/
      194 && n !== (n = /*sortOrder*/
      (r[1] === 1 ? (
        /*iconAsc*/
        r[6]
      ) : (
        /*iconDesc*/
        r[7]
      )) + "") && t.p(n);
    },
    d(r) {
      r && (_e(i), t.d());
    }
  };
}
function RS(e) {
  let t, n = (
    /*col*/
    e[59].title + ""
  ), i, r, s, o, a;
  function l(h, g) {
    if (
      /*sortBy*/
      h[0] === /*col*/
      h[59].key
    )
      return tI;
    if (
      /*col*/
      h[59].sortable
    )
      return eI;
  }
  let u = l(e), c = u && u(e);
  function f(...h) {
    return (
      /*click_handler*/
      e[45](
        /*col*/
        e[59],
        ...h
      )
    );
  }
  function d(...h) {
    return (
      /*keypress_handler*/
      e[46](
        /*col*/
        e[59],
        ...h
      )
    );
  }
  return {
    c() {
      t = pe("th"), i = ei(n), r = ft(), c && c.c(), he(t, "class", s = ot(
        /*asStringArray*/
        e[26]([
          /*col*/
          e[59].sortable ? "isSortable" : "",
          /*col*/
          e[59].headerClass
        ])
      ) + " svelte-dsaf7t"), he(t, "tabindex", "0");
    },
    m(h, g) {
      Se(h, t, g), ve(t, i), ve(t, r), c && c.m(t, null), o || (a = [
        Cr(t, "click", f),
        Cr(t, "keypress", d)
      ], o = !0);
    },
    p(h, g) {
      e = h, g[0] & /*columns*/
      16 && n !== (n = /*col*/
      e[59].title + "") && xs(i, n), u === (u = l(e)) && c ? c.p(e, g) : (c && c.d(1), c = u && u(e), c && (c.c(), c.m(t, null))), g[0] & /*columns, filterValues*/
      8388624 && s !== (s = ot(
        /*asStringArray*/
        e[26]([
          /*col*/
          e[59].sortable ? "isSortable" : "",
          /*col*/
          e[59].headerClass
        ])
      ) + " svelte-dsaf7t") && he(t, "class", s);
    },
    d(h) {
      h && _e(t), c && c.d(), o = !1, As(a);
    }
  };
}
function LS(e) {
  let t;
  return {
    c() {
      t = pe("th");
    },
    m(n, i) {
      Se(n, t, i);
    },
    d(n) {
      n && _e(t);
    }
  };
}
function nI(e) {
  let t, n, i = Rn(
    /*columns*/
    e[4]
  ), r = [];
  for (let o = 0; o < i.length; o += 1)
    r[o] = RS($S(e, i, o));
  let s = (
    /*showExpandIcon*/
    e[11] && LS()
  );
  return {
    c() {
      t = pe("tr");
      for (let o = 0; o < r.length; o += 1)
        r[o].c();
      n = ft(), s && s.c();
    },
    m(o, a) {
      Se(o, t, a);
      for (let l = 0; l < r.length; l += 1)
        r[l] && r[l].m(t, null);
      ve(t, n), s && s.m(t, null);
    },
    p(o, a) {
      if (a[0] & /*asStringArray, columns, handleClickCol, sortOrder, iconAsc, iconDesc, sortBy, iconSortable*/
      201327059) {
        i = Rn(
          /*columns*/
          o[4]
        );
        let l;
        for (l = 0; l < i.length; l += 1) {
          const u = $S(o, i, l);
          r[l] ? r[l].p(u, a) : (r[l] = RS(u), r[l].c(), r[l].m(t, n));
        }
        for (; l < r.length; l += 1)
          r[l].d(1);
        r.length = i.length;
      }
      /*showExpandIcon*/
      o[11] ? s || (s = LS(), s.c(), s.m(t, null)) : s && (s.d(1), s = null);
    },
    d(o) {
      o && _e(t), Ja(r, o), s && s.d();
    }
  };
}
function iI(e) {
  let t = (
    /*col*/
    (e[59].renderValue ? (
      /*col*/
      e[59].renderValue(
        /*row*/
        e[56],
        /*n*/
        e[58],
        /*colIndex*/
        e[61]
      )
    ) : (
      /*col*/
      e[59].value(
        /*row*/
        e[56],
        /*n*/
        e[58],
        /*colIndex*/
        e[61]
      )
    )) + ""
  ), n;
  return {
    c() {
      n = ei(t);
    },
    m(i, r) {
      Se(i, n, r);
    },
    p(i, r) {
      r[0] & /*columns, c_rows*/
      24 && t !== (t = /*col*/
      (i[59].renderValue ? (
        /*col*/
        i[59].renderValue(
          /*row*/
          i[56],
          /*n*/
          i[58],
          /*colIndex*/
          i[61]
        )
      ) : (
        /*col*/
        i[59].value(
          /*row*/
          i[56],
          /*n*/
          i[58],
          /*colIndex*/
          i[61]
        )
      )) + "") && xs(n, t);
    },
    i: Zn,
    o: Zn,
    d(i) {
      i && _e(n);
    }
  };
}
function rI(e) {
  let t, n = (
    /*col*/
    (e[59].renderValue ? (
      /*col*/
      e[59].renderValue(
        /*row*/
        e[56],
        /*n*/
        e[58],
        /*colIndex*/
        e[61]
      )
    ) : (
      /*col*/
      e[59].value(
        /*row*/
        e[56],
        /*n*/
        e[58],
        /*colIndex*/
        e[61]
      )
    )) + ""
  ), i;
  return {
    c() {
      t = new Ip(!1), i = Zf(), t.a = i;
    },
    m(r, s) {
      t.m(n, r, s), Se(r, i, s);
    },
    p(r, s) {
      s[0] & /*columns, c_rows*/
      24 && n !== (n = /*col*/
      (r[59].renderValue ? (
        /*col*/
        r[59].renderValue(
          /*row*/
          r[56],
          /*n*/
          r[58],
          /*colIndex*/
          r[61]
        )
      ) : (
        /*col*/
        r[59].value(
          /*row*/
          r[56],
          /*n*/
          r[58],
          /*colIndex*/
          r[61]
        )
      )) + "") && t.p(n);
    },
    i: Zn,
    o: Zn,
    d(r) {
      r && (_e(i), t.d());
    }
  };
}
function sI(e) {
  let t, n, i;
  const r = [
    /*col*/
    e[59].renderComponent.props || {},
    { row: (
      /*row*/
      e[56]
    ) },
    { col: (
      /*col*/
      e[59]
    ) }
  ];
  var s = (
    /*col*/
    e[59].renderComponent.component || /*col*/
    e[59].renderComponent
  );
  function o(a, l) {
    let u = {};
    if (l !== void 0 && l[0] & /*columns, c_rows*/
    24)
      u = wS(r, [
        l[0] & /*columns*/
        16 && _S(
          /*col*/
          a[59].renderComponent.props || {}
        ),
        l[0] & /*c_rows*/
        8 && { row: (
          /*row*/
          a[56]
        ) },
        l[0] & /*columns*/
        16 && { col: (
          /*col*/
          a[59]
        ) }
      ]);
    else
      for (let c = 0; c < r.length; c += 1)
        u = F3(u, r[c]);
    return { props: u };
  }
  return s && (t = vS(s, o(e))), {
    c() {
      t && ii(t.$$.fragment), n = Zf();
    },
    m(a, l) {
      t && Ln(t, a, l), Se(a, n, l), i = !0;
    },
    p(a, l) {
      if (l[0] & /*columns*/
      16 && s !== (s = /*col*/
      a[59].renderComponent.component || /*col*/
      a[59].renderComponent)) {
        if (t) {
          bi();
          const u = t;
          Ce(u.$$.fragment, 1, 0, () => {
            Pn(u, 1);
          }), vi();
        }
        s ? (t = vS(s, o(a, l)), ii(t.$$.fragment), ge(t.$$.fragment, 1), Ln(t, n.parentNode, n)) : t = null;
      } else if (s) {
        const u = l[0] & /*columns, c_rows*/
        24 ? wS(r, [
          l[0] & /*columns*/
          16 && _S(
            /*col*/
            a[59].renderComponent.props || {}
          ),
          l[0] & /*c_rows*/
          8 && { row: (
            /*row*/
            a[56]
          ) },
          l[0] & /*columns*/
          16 && { col: (
            /*col*/
            a[59]
          ) }
        ]) : {};
        t.$set(u);
      }
    },
    i(a) {
      i || (t && ge(t.$$.fragment, a), i = !0);
    },
    o(a) {
      t && Ce(t.$$.fragment, a), i = !1;
    },
    d(a) {
      a && _e(n), t && Pn(t, a);
    }
  };
}
function PS(e) {
  let t, n, i, r, s, o, a;
  const l = [sI, rI, iI], u = [];
  function c(h, g) {
    return (
      /*col*/
      h[59].renderComponent ? 0 : (
        /*col*/
        h[59].parseHTML ? 1 : 2
      )
    );
  }
  n = c(e), i = u[n] = l[n](e);
  function f(...h) {
    return (
      /*click_handler_1*/
      e[47](
        /*row*/
        e[56],
        /*col*/
        e[59],
        ...h
      )
    );
  }
  function d(...h) {
    return (
      /*keypress_handler_1*/
      e[48](
        /*row*/
        e[56],
        /*col*/
        e[59],
        ...h
      )
    );
  }
  return {
    c() {
      t = pe("td"), i.c(), he(t, "class", r = ot(
        /*asStringArray*/
        e[26]([
          typeof /*col*/
          e[59].class == "string" ? (
            /*col*/
            e[59].class
          ) : null,
          typeof /*col*/
          e[59].class == "function" ? (
            /*col*/
            e[59].class(
              /*row*/
              e[56],
              /*n*/
              e[58],
              /*colIndex*/
              e[61]
            )
          ) : null,
          /*classNameCell*/
          e[18]
        ])
      ) + " svelte-dsaf7t");
    },
    m(h, g) {
      Se(h, t, g), u[n].m(t, null), s = !0, o || (a = [
        Cr(t, "click", f),
        Cr(t, "keypress", d)
      ], o = !0);
    },
    p(h, g) {
      e = h;
      let p = n;
      n = c(e), n === p ? u[n].p(e, g) : (bi(), Ce(u[p], 1, 1, () => {
        u[p] = null;
      }), vi(), i = u[n], i ? i.p(e, g) : (i = u[n] = l[n](e), i.c()), ge(i, 1), i.m(t, null)), (!s || g[0] & /*columns, c_rows, classNameCell, filterValues*/
      8650776 && r !== (r = ot(
        /*asStringArray*/
        e[26]([
          typeof /*col*/
          e[59].class == "string" ? (
            /*col*/
            e[59].class
          ) : null,
          typeof /*col*/
          e[59].class == "function" ? (
            /*col*/
            e[59].class(
              /*row*/
              e[56],
              /*n*/
              e[58],
              /*colIndex*/
              e[61]
            )
          ) : null,
          /*classNameCell*/
          e[18]
        ])
      ) + " svelte-dsaf7t")) && he(t, "class", r);
    },
    i(h) {
      s || (ge(i), s = !0);
    },
    o(h) {
      Ce(i), s = !1;
    },
    d(h) {
      h && _e(t), u[n].d(), o = !1, As(a);
    }
  };
}
function IS(e) {
  let t, n, i = (
    /*row*/
    (e[56].$expanded ? (
      /*iconExpand*/
      e[9]
    ) : (
      /*iconExpanded*/
      e[10]
    )) + ""
  ), r, s, o;
  function a(...u) {
    return (
      /*click_handler_2*/
      e[49](
        /*row*/
        e[56],
        ...u
      )
    );
  }
  function l(...u) {
    return (
      /*keypress_handler_2*/
      e[50](
        /*row*/
        e[56],
        ...u
      )
    );
  }
  return {
    c() {
      t = pe("td"), n = pe("span"), he(n, "class", "isClickable svelte-dsaf7t"), he(n, "tabindex", "0"), he(n, "role", "button"), he(t, "class", r = ot(
        /*asStringArray*/
        e[26](
          /*classNameCellExpand*/
          e[22]
        )
      ) + " svelte-dsaf7t");
    },
    m(u, c) {
      Se(u, t, c), ve(t, n), n.innerHTML = i, s || (o = [
        Cr(n, "click", a),
        Cr(n, "keypress", l)
      ], s = !0);
    },
    p(u, c) {
      e = u, c[0] & /*c_rows, iconExpand, iconExpanded*/
      1544 && i !== (i = /*row*/
      (e[56].$expanded ? (
        /*iconExpand*/
        e[9]
      ) : (
        /*iconExpanded*/
        e[10]
      )) + "") && (n.innerHTML = i), c[0] & /*classNameCellExpand*/
      4194304 && r !== (r = ot(
        /*asStringArray*/
        e[26](
          /*classNameCellExpand*/
          e[22]
        )
      ) + " svelte-dsaf7t") && he(t, "class", r);
    },
    d(u) {
      u && _e(t), s = !1, As(o);
    }
  };
}
function zS(e) {
  let t, n, i, r;
  const s = (
    /*#slots*/
    e[42].expanded
  ), o = Dv(
    s,
    e,
    /*$$scope*/
    e[41],
    kS
  );
  return {
    c() {
      t = pe("tr"), n = pe("td"), o && o.c(), he(
        n,
        "colspan",
        /*colspan*/
        e[24]
      ), he(t, "class", i = ot(
        /*asStringArray*/
        e[26](
          /*classNameExpandedContent*/
          e[21]
        )
      ) + " svelte-dsaf7t");
    },
    m(a, l) {
      Se(a, t, l), ve(t, n), o && o.m(n, null), r = !0;
    },
    p(a, l) {
      o && o.p && (!r || l[0] & /*c_rows*/
      8 | l[1] & /*$$scope*/
      1024) && Lv(
        o,
        s,
        a,
        /*$$scope*/
        a[41],
        r ? Rv(
          s,
          /*$$scope*/
          a[41],
          l,
          YP
        ) : Pv(
          /*$$scope*/
          a[41]
        ),
        kS
      ), (!r || l[0] & /*colspan*/
      16777216) && he(
        n,
        "colspan",
        /*colspan*/
        a[24]
      ), (!r || l[0] & /*classNameExpandedContent*/
      2097152 && i !== (i = ot(
        /*asStringArray*/
        a[26](
          /*classNameExpandedContent*/
          a[21]
        )
      ) + " svelte-dsaf7t")) && he(t, "class", i);
    },
    i(a) {
      r || (ge(o, a), r = !0);
    },
    o(a) {
      Ce(o, a), r = !1;
    },
    d(a) {
      a && _e(t), o && o.d(a);
    }
  };
}
function oI(e) {
  let t, n, i, r, s, o, a, l, u, c = Rn(
    /*columns*/
    e[4]
  ), f = [];
  for (let y = 0; y < c.length; y += 1)
    f[y] = PS(AS(e, c, y));
  const d = (y) => Ce(f[y], 1, 1, () => {
    f[y] = null;
  });
  let h = (
    /*showExpandIcon*/
    e[11] && IS(e)
  );
  function g(...y) {
    return (
      /*click_handler_3*/
      e[51](
        /*row*/
        e[56],
        ...y
      )
    );
  }
  function p(...y) {
    return (
      /*keypress_handler_3*/
      e[52](
        /*row*/
        e[56],
        ...y
      )
    );
  }
  let m = (
    /*row*/
    e[56].$expanded && zS(e)
  );
  return {
    c() {
      t = pe("tr");
      for (let y = 0; y < f.length; y += 1)
        f[y].c();
      n = ft(), h && h.c(), s = ft(), m && m.c(), o = ft(), he(t, "class", i = ot(
        /*asStringArray*/
        e[26]([
          typeof /*classNameRow*/
          e[17] == "string" ? (
            /*classNameRow*/
            e[17]
          ) : null,
          typeof /*classNameRow*/
          e[17] == "function" ? (
            /*classNameRow*/
            e[17](
              /*row*/
              e[56],
              /*n*/
              e[58]
            )
          ) : null,
          /*row*/
          e[56].$expanded && /*classNameRowExpanded*/
          e[20],
          /*row*/
          e[56].$selected && /*classNameRowSelected*/
          e[19]
        ])
      ) + " svelte-dsaf7t"), he(t, "tabindex", r = /*selectOnClick*/
      e[5] ? "0" : null);
    },
    m(y, b) {
      Se(y, t, b);
      for (let v = 0; v < f.length; v += 1)
        f[v] && f[v].m(t, null);
      ve(t, n), h && h.m(t, null), Se(y, s, b), m && m.m(y, b), Se(y, o, b), a = !0, l || (u = [
        Cr(t, "click", g),
        Cr(t, "keypress", p)
      ], l = !0);
    },
    p(y, b) {
      if (e = y, b[0] & /*asStringArray, columns, c_rows, classNameCell, handleClickCell*/
      1141112856) {
        c = Rn(
          /*columns*/
          e[4]
        );
        let v;
        for (v = 0; v < c.length; v += 1) {
          const _ = AS(e, c, v);
          f[v] ? (f[v].p(_, b), ge(f[v], 1)) : (f[v] = PS(_), f[v].c(), ge(f[v], 1), f[v].m(t, n));
        }
        for (bi(), v = c.length; v < f.length; v += 1)
          d(v);
        vi();
      }
      /*showExpandIcon*/
      e[11] ? h ? h.p(e, b) : (h = IS(e), h.c(), h.m(t, null)) : h && (h.d(1), h = null), (!a || b[0] & /*classNameRow, c_rows, classNameRowExpanded, classNameRowSelected*/
      1703944 && i !== (i = ot(
        /*asStringArray*/
        e[26]([
          typeof /*classNameRow*/
          e[17] == "string" ? (
            /*classNameRow*/
            e[17]
          ) : null,
          typeof /*classNameRow*/
          e[17] == "function" ? (
            /*classNameRow*/
            e[17](
              /*row*/
              e[56],
              /*n*/
              e[58]
            )
          ) : null,
          /*row*/
          e[56].$expanded && /*classNameRowExpanded*/
          e[20],
          /*row*/
          e[56].$selected && /*classNameRowSelected*/
          e[19]
        ])
      ) + " svelte-dsaf7t")) && he(t, "class", i), (!a || b[0] & /*selectOnClick*/
      32 && r !== (r = /*selectOnClick*/
      e[5] ? "0" : null)) && he(t, "tabindex", r), /*row*/
      e[56].$expanded ? m ? (m.p(e, b), b[0] & /*c_rows*/
      8 && ge(m, 1)) : (m = zS(e), m.c(), ge(m, 1), m.m(o.parentNode, o)) : m && (bi(), Ce(m, 1, 1, () => {
        m = null;
      }), vi());
    },
    i(y) {
      if (!a) {
        for (let b = 0; b < c.length; b += 1)
          ge(f[b]);
        ge(m), a = !0;
      }
    },
    o(y) {
      f = f.filter(Boolean);
      for (let b = 0; b < f.length; b += 1)
        Ce(f[b]);
      Ce(m), a = !1;
    },
    d(y) {
      y && (_e(t), _e(s), _e(o)), Ja(f, y), h && h.d(), m && m.d(y), l = !1, As(u);
    }
  };
}
function BS(e) {
  let t;
  const n = (
    /*#slots*/
    e[42].row
  ), i = Dv(
    n,
    e,
    /*$$scope*/
    e[41],
    CS
  ), r = i || oI(e);
  return {
    c() {
      r && r.c();
    },
    m(s, o) {
      r && r.m(s, o), t = !0;
    },
    p(s, o) {
      i ? i.p && (!t || o[0] & /*c_rows*/
      8 | o[1] & /*$$scope*/
      1024) && Lv(
        i,
        n,
        s,
        /*$$scope*/
        s[41],
        t ? Rv(
          n,
          /*$$scope*/
          s[41],
          o,
          XP
        ) : Pv(
          /*$$scope*/
          s[41]
        ),
        CS
      ) : r && r.p && (!t || o[0] & /*classNameExpandedContent, colspan, c_rows, classNameRow, classNameRowExpanded, classNameRowSelected, selectOnClick, classNameCellExpand, iconExpand, iconExpanded, showExpandIcon, columns, classNameCell*/
      25038392 | o[1] & /*$$scope*/
      1024) && r.p(s, t ? o : [-1, -1, -1]);
    },
    i(s) {
      t || (ge(r, s), t = !0);
    },
    o(s) {
      Ce(r, s), t = !1;
    },
    d(s) {
      r && r.d(s);
    }
  };
}
function aI(e) {
  let t, n, i, r, s, o, a, l, u, c = (
    /*showFilterHeader*/
    e[25] && JP(e)
  );
  const f = (
    /*#slots*/
    e[42].header
  ), d = Dv(
    f,
    e,
    /*$$scope*/
    e[41],
    MS
  ), h = d || nI(e);
  let g = Rn(
    /*c_rows*/
    e[3]
  ), p = [];
  for (let y = 0; y < g.length; y += 1)
    p[y] = BS(SS(e, g, y));
  const m = (y) => Ce(p[y], 1, 1, () => {
    p[y] = null;
  });
  return {
    c() {
      t = pe("table"), n = pe("thead"), c && c.c(), i = ft(), h && h.c(), s = ft(), o = pe("tbody");
      for (let y = 0; y < p.length; y += 1)
        p[y].c();
      he(n, "class", r = ot(
        /*asStringArray*/
        e[26](
          /*classNameThead*/
          e[13]
        )
      ) + " svelte-dsaf7t"), he(o, "class", a = ot(
        /*asStringArray*/
        e[26](
          /*classNameTbody*/
          e[14]
        )
      ) + " svelte-dsaf7t"), he(t, "class", l = ot(
        /*asStringArray*/
        e[26](
          /*classNameTable*/
          e[12]
        )
      ) + " svelte-dsaf7t");
    },
    m(y, b) {
      Se(y, t, b), ve(t, n), c && c.m(n, null), ve(n, i), h && h.m(n, null), ve(t, s), ve(t, o);
      for (let v = 0; v < p.length; v += 1)
        p[v] && p[v].m(o, null);
      u = !0;
    },
    p(y, b) {
      if (
        /*showFilterHeader*/
        y[25] && c.p(y, b), d ? d.p && (!u || b[0] & /*sortOrder, sortBy*/
        3 | b[1] & /*$$scope*/
        1024) && Lv(
          d,
          f,
          y,
          /*$$scope*/
          y[41],
          u ? Rv(
            f,
            /*$$scope*/
            y[41],
            b,
            KP
          ) : Pv(
            /*$$scope*/
            y[41]
          ),
          MS
        ) : h && h.p && (!u || b[0] & /*showExpandIcon, columns, sortOrder, iconAsc, iconDesc, sortBy, iconSortable*/
        2515) && h.p(y, u ? b : [-1, -1, -1]), (!u || b[0] & /*classNameThead*/
        8192 && r !== (r = ot(
          /*asStringArray*/
          y[26](
            /*classNameThead*/
            y[13]
          )
        ) + " svelte-dsaf7t")) && he(n, "class", r), b[0] & /*asStringArray, classNameExpandedContent, colspan, c_rows, classNameRow, classNameRowExpanded, classNameRowSelected, selectOnClick, handleClickRow, classNameCellExpand, handleClickExpand, iconExpand, iconExpanded, showExpandIcon, columns, classNameCell, handleClickCell*/
        1971195448 | b[1] & /*$$scope*/
        1024
      ) {
        g = Rn(
          /*c_rows*/
          y[3]
        );
        let v;
        for (v = 0; v < g.length; v += 1) {
          const _ = SS(y, g, v);
          p[v] ? (p[v].p(_, b), ge(p[v], 1)) : (p[v] = BS(_), p[v].c(), ge(p[v], 1), p[v].m(o, null));
        }
        for (bi(), v = g.length; v < p.length; v += 1)
          m(v);
        vi();
      }
      (!u || b[0] & /*classNameTbody*/
      16384 && a !== (a = ot(
        /*asStringArray*/
        y[26](
          /*classNameTbody*/
          y[14]
        )
      ) + " svelte-dsaf7t")) && he(o, "class", a), (!u || b[0] & /*classNameTable*/
      4096 && l !== (l = ot(
        /*asStringArray*/
        y[26](
          /*classNameTable*/
          y[12]
        )
      ) + " svelte-dsaf7t")) && he(t, "class", l);
    },
    i(y) {
      if (!u) {
        ge(h, y);
        for (let b = 0; b < g.length; b += 1)
          ge(p[b]);
        u = !0;
      }
    },
    o(y) {
      Ce(h, y), p = p.filter(Boolean);
      for (let b = 0; b < p.length; b += 1)
        Ce(p[b]);
      u = !1;
    },
    d(y) {
      y && _e(t), c && c.d(), h && h.d(y), Ja(p, y);
    }
  };
}
function lI(e, t, n) {
  let i, { $$slots: r = {}, $$scope: s } = t, { columns: o } = t, { rows: a } = t, { c_rows: l = void 0 } = t, { sortOrders: u = [1, -1] } = t, { sortBy: c = "" } = t, { sortOrder: f = (u == null ? void 0 : u[0]) || 1 } = t, { filterSelections: d = {} } = t, { expanded: h = [] } = t, { selected: g = [] } = t, { expandRowKey: p = null } = t, { rowKey: m = p } = t, { expandSingle: y = !1 } = t, { selectSingle: b = !1 } = t, { selectOnClick: v = !1 } = t, { iconAsc: _ = "▲" } = t, { iconDesc: x = "▼" } = t, { iconSortable: S = "" } = t, { iconExpand: E = "▼" } = t, { iconExpanded: C = "▲" } = t, { showExpandIcon: $ = !1 } = t, { classNameTable: N = "" } = t, { classNameThead: O = "" } = t, { classNameTbody: P = "" } = t, { classNameSelect: T = "" } = t, { classNameInput: D = "" } = t, { classNameRow: M = null } = t, { classNameCell: w = "" } = t, { classNameRowSelected: k = null } = t, { classNameRowExpanded: A = null } = t, { classNameExpandedContent: F = "" } = t, { classNameCellExpand: R = "" } = t;
  const L = Bv();
  let V = () => "";
  if (!Array.isArray(h))
    throw "'expanded' needs to be an array";
  if (!Array.isArray(g))
    throw "'selection' needs to be an array";
  p !== null && console.warn("'expandRowKey' is deprecated in favour of 'rowKey'"), k && !m && console.error("'rowKey' is needed to use 'classNameRowSelected'");
  let K = o.some((z) => !z.hideFilterHeader && (z.filterOptions !== void 0 || z.searchValue !== void 0)), Q = {}, ie;
  const Le = (z) => [].concat(z).filter((re) => re !== null && typeof re == "string" && re !== "").join(" "), Oe = () => {
    n(23, Q = {}), o.forEach((z) => {
      typeof z.filterOptions == "function" ? n(23, Q[z.key] = z.filterOptions(a), Q) : Array.isArray(z.filterOptions) && n(23, Q[z.key] = z.filterOptions.map((re) => ({ name: re, value: re })), Q);
    });
  }, mt = (z) => z === c ? u[(u.findIndex((re) => re === f) + 1) % u.length] : u[0], Z = (z, re) => {
    re.sortable && (n(1, f = mt(re.key)), n(0, c = f ? re.key : void 0)), L("clickCol", { event: z, col: re, key: re.key });
  }, ye = (z, re) => {
    v && (b ? g.includes(re[m]) ? n(32, g = []) : n(32, g = [re[m]]) : g.includes(re[m]) ? n(32, g = g.filter((zt) => zt != re[m])) : n(32, g = [...g, re[m]].sort())), L("clickRow", { event: z, row: re });
  }, xe = (z, re) => {
    re.$expanded = !re.$expanded;
    const zt = re[m];
    y && re.$expanded ? n(31, h = [zt]) : y ? n(31, h = []) : re.$expanded ? n(31, h = [...h, zt]) : n(31, h = h.filter((pS) => pS != zt)), L("clickExpand", { event: z, row: re });
  }, W = (z, re, zt) => {
    L("clickCell", { event: z, row: re, key: zt });
  };
  function yt(z) {
    d[z.key] = this.value, n(2, d), n(23, Q), n(4, o);
  }
  function De(z) {
    d[z.key] = OP(this), n(2, d), n(23, Q), n(4, o);
  }
  const kt = (z, re) => Z(re, z), It = (z, re) => re.key === "Enter" && Z(re, z), Xr = (z, re, zt) => W(zt, z, re.key), qd = (z, re, zt) => zt.key === "Enter" && W(zt, z, re.key), _P = (z, re) => xe(re, z), EP = (z, re) => re.key === "Enter" && xe(re, z), SP = (z, re) => ye(re, z), kP = (z, re) => re.key === "Enter" && ye(re, z);
  return e.$$set = (z) => {
    "columns" in z && n(4, o = z.columns), "rows" in z && n(33, a = z.rows), "c_rows" in z && n(3, l = z.c_rows), "sortOrders" in z && n(34, u = z.sortOrders), "sortBy" in z && n(0, c = z.sortBy), "sortOrder" in z && n(1, f = z.sortOrder), "filterSelections" in z && n(2, d = z.filterSelections), "expanded" in z && n(31, h = z.expanded), "selected" in z && n(32, g = z.selected), "expandRowKey" in z && n(35, p = z.expandRowKey), "rowKey" in z && n(36, m = z.rowKey), "expandSingle" in z && n(37, y = z.expandSingle), "selectSingle" in z && n(38, b = z.selectSingle), "selectOnClick" in z && n(5, v = z.selectOnClick), "iconAsc" in z && n(6, _ = z.iconAsc), "iconDesc" in z && n(7, x = z.iconDesc), "iconSortable" in z && n(8, S = z.iconSortable), "iconExpand" in z && n(9, E = z.iconExpand), "iconExpanded" in z && n(10, C = z.iconExpanded), "showExpandIcon" in z && n(11, $ = z.showExpandIcon), "classNameTable" in z && n(12, N = z.classNameTable), "classNameThead" in z && n(13, O = z.classNameThead), "classNameTbody" in z && n(14, P = z.classNameTbody), "classNameSelect" in z && n(15, T = z.classNameSelect), "classNameInput" in z && n(16, D = z.classNameInput), "classNameRow" in z && n(17, M = z.classNameRow), "classNameCell" in z && n(18, w = z.classNameCell), "classNameRowSelected" in z && n(19, k = z.classNameRowSelected), "classNameRowExpanded" in z && n(20, A = z.classNameRowExpanded), "classNameExpandedContent" in z && n(21, F = z.classNameExpandedContent), "classNameCellExpand" in z && n(22, R = z.classNameCellExpand), "$$scope" in z && n(41, s = z.$$scope);
  }, e.$$.update = () => {
    if (e.$$.dirty[0] & /*columns*/
    16 && (n(40, ie = {}), o.forEach((z) => {
      n(40, ie[z.key] = z, ie);
    })), e.$$.dirty[0] & /*showExpandIcon, columns*/
    2064 && n(24, i = ($ ? 1 : 0) + o.length), e.$$.dirty[0] & /*sortBy*/
    1 | e.$$.dirty[1] & /*columnByKey*/
    512) {
      let z = ie[c];
      z !== void 0 && z.sortable === !0 && typeof z.value == "function" && n(39, V = (re) => z.value(re));
    }
    e.$$.dirty[0] & /*filterSelections, sortBy, sortOrder*/
    7 | e.$$.dirty[1] & /*rows, columnByKey, sortFunction, rowKey, expanded, selected*/
    807 && n(3, l = a.filter((z) => Object.keys(d).every((re) => {
      var mS;
      let zt = null;
      if (ie[re] === void 0)
        return !0;
      if (!((mS = ie[re]) != null && mS.searchValue))
        zt = !1;
      else {
        if (d[re] === "")
          return !0;
        ie[re].searchValue.length === 1 ? zt = (ie[re].searchValue(z) + "").toLocaleLowerCase().indexOf((d[re] + "").toLocaleLowerCase()) >= 0 : ie[re].searchValue.length === 2 && (zt = !!ie[re].searchValue(z, d[re] + ""));
      }
      return zt || d[re] === void 0 || // default to value() if filterValue() not provided in col
      d[re] === (typeof ie[re].filterValue == "function" ? ie[re].filterValue(z) : ie[re].value(z));
    })).map((z) => Object.assign({}, z, {
      // internal row property for sort order
      $sortOn: V(z),
      // internal row property for expanded rows
      $expanded: m !== null && h.indexOf(z[m]) >= 0,
      $selected: m !== null && g.indexOf(z[m]) >= 0
    })).sort((z, re) => {
      if (c) {
        if (z.$sortOn > re.$sortOn)
          return f;
        if (z.$sortOn < re.$sortOn)
          return -f;
      } else
        return 0;
      return 0;
    })), e.$$.dirty[0] & /*columns*/
    16 | e.$$.dirty[1] & /*rows*/
    4 && K && o && a && Oe();
  }, [
    c,
    f,
    d,
    l,
    o,
    v,
    _,
    x,
    S,
    E,
    C,
    $,
    N,
    O,
    P,
    T,
    D,
    M,
    w,
    k,
    A,
    F,
    R,
    Q,
    i,
    K,
    Le,
    Z,
    ye,
    xe,
    W,
    h,
    g,
    a,
    u,
    p,
    m,
    y,
    b,
    V,
    ie,
    s,
    r,
    yt,
    De,
    kt,
    It,
    Xr,
    qd,
    _P,
    EP,
    SP,
    kP
  ];
}
class qv extends Ms {
  constructor(t) {
    super(), $s(
      this,
      t,
      lI,
      aI,
      Cs,
      {
        columns: 4,
        rows: 33,
        c_rows: 3,
        sortOrders: 34,
        sortBy: 0,
        sortOrder: 1,
        filterSelections: 2,
        expanded: 31,
        selected: 32,
        expandRowKey: 35,
        rowKey: 36,
        expandSingle: 37,
        selectSingle: 38,
        selectOnClick: 5,
        iconAsc: 6,
        iconDesc: 7,
        iconSortable: 8,
        iconExpand: 9,
        iconExpanded: 10,
        showExpandIcon: 11,
        classNameTable: 12,
        classNameThead: 13,
        classNameTbody: 14,
        classNameSelect: 15,
        classNameInput: 16,
        classNameRow: 17,
        classNameCell: 18,
        classNameRowSelected: 19,
        classNameRowExpanded: 20,
        classNameExpandedContent: 21,
        classNameCellExpand: 22
      },
      null,
      [-1, -1, -1]
    );
  }
}
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2022 Joachim Wester
 * MIT licensed
 */
var uI = /* @__PURE__ */ function() {
  var e = function(t, n) {
    return e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(i, r) {
      i.__proto__ = r;
    } || function(i, r) {
      for (var s in r)
        r.hasOwnProperty(s) && (i[s] = r[s]);
    }, e(t, n);
  };
  return function(t, n) {
    e(t, n);
    function i() {
      this.constructor = t;
    }
    t.prototype = n === null ? Object.create(n) : (i.prototype = n.prototype, new i());
  };
}(), cI = Object.prototype.hasOwnProperty;
function _y(e, t) {
  return cI.call(e, t);
}
function Ey(e) {
  if (Array.isArray(e)) {
    for (var t = new Array(e.length), n = 0; n < t.length; n++)
      t[n] = "" + n;
    return t;
  }
  if (Object.keys)
    return Object.keys(e);
  var i = [];
  for (var r in e)
    _y(e, r) && i.push(r);
  return i;
}
function Kn(e) {
  switch (typeof e) {
    case "object":
      return JSON.parse(JSON.stringify(e));
    case "undefined":
      return null;
    default:
      return e;
  }
}
function Sy(e) {
  for (var t = 0, n = e.length, i; t < n; ) {
    if (i = e.charCodeAt(t), i >= 48 && i <= 57) {
      t++;
      continue;
    }
    return !1;
  }
  return !0;
}
function ia(e) {
  return e.indexOf("/") === -1 && e.indexOf("~") === -1 ? e : e.replace(/~/g, "~0").replace(/\//g, "~1");
}
function R3(e) {
  return e.replace(/~1/g, "/").replace(/~0/g, "~");
}
function ky(e) {
  if (e === void 0)
    return !0;
  if (e) {
    if (Array.isArray(e)) {
      for (var t = 0, n = e.length; t < n; t++)
        if (ky(e[t]))
          return !0;
    } else if (typeof e == "object") {
      for (var i = Ey(e), r = i.length, s = 0; s < r; s++)
        if (ky(e[i[s]]))
          return !0;
    }
  }
  return !1;
}
function jS(e, t) {
  var n = [e];
  for (var i in t) {
    var r = typeof t[i] == "object" ? JSON.stringify(t[i], null, 2) : t[i];
    typeof r < "u" && n.push(i + ": " + r);
  }
  return n.join(`
`);
}
var L3 = (
  /** @class */
  function(e) {
    uI(t, e);
    function t(n, i, r, s, o) {
      var a = this.constructor, l = e.call(this, jS(n, { name: i, index: r, operation: s, tree: o })) || this;
      return l.name = i, l.index = r, l.operation = s, l.tree = o, Object.setPrototypeOf(l, a.prototype), l.message = jS(n, { name: i, index: r, operation: s, tree: o }), l;
    }
    return t;
  }(Error)
), st = L3, fI = Kn, Nl = {
  add: function(e, t, n) {
    return e[t] = this.value, { newDocument: n };
  },
  remove: function(e, t, n) {
    var i = e[t];
    return delete e[t], { newDocument: n, removed: i };
  },
  replace: function(e, t, n) {
    var i = e[t];
    return e[t] = this.value, { newDocument: n, removed: i };
  },
  move: function(e, t, n) {
    var i = ig(n, this.path);
    i && (i = Kn(i));
    var r = ba(n, { op: "remove", path: this.from }).removed;
    return ba(n, { op: "add", path: this.path, value: r }), { newDocument: n, removed: i };
  },
  copy: function(e, t, n) {
    var i = ig(n, this.from);
    return ba(n, { op: "add", path: this.path, value: Kn(i) }), { newDocument: n };
  },
  test: function(e, t, n) {
    return { newDocument: n, test: vf(e[t], this.value) };
  },
  _get: function(e, t, n) {
    return this.value = e[t], { newDocument: n };
  }
}, dI = {
  add: function(e, t, n) {
    return Sy(t) ? e.splice(t, 0, this.value) : e[t] = this.value, { newDocument: n, index: t };
  },
  remove: function(e, t, n) {
    var i = e.splice(t, 1);
    return { newDocument: n, removed: i[0] };
  },
  replace: function(e, t, n) {
    var i = e[t];
    return e[t] = this.value, { newDocument: n, removed: i };
  },
  move: Nl.move,
  copy: Nl.copy,
  test: Nl.test,
  _get: Nl._get
};
function ig(e, t) {
  if (t == "")
    return e;
  var n = { op: "_get", path: t };
  return ba(e, n), n.value;
}
function ba(e, t, n, i, r, s) {
  if (n === void 0 && (n = !1), i === void 0 && (i = !0), r === void 0 && (r = !0), s === void 0 && (s = 0), n && (typeof n == "function" ? n(t, 0, e, t.path) : rg(t, 0)), t.path === "") {
    var o = { newDocument: e };
    if (t.op === "add")
      return o.newDocument = t.value, o;
    if (t.op === "replace")
      return o.newDocument = t.value, o.removed = e, o;
    if (t.op === "move" || t.op === "copy")
      return o.newDocument = ig(e, t.from), t.op === "move" && (o.removed = e), o;
    if (t.op === "test") {
      if (o.test = vf(e, t.value), o.test === !1)
        throw new st("Test operation failed", "TEST_OPERATION_FAILED", s, t, e);
      return o.newDocument = e, o;
    } else {
      if (t.op === "remove")
        return o.removed = e, o.newDocument = null, o;
      if (t.op === "_get")
        return t.value = e, o;
      if (n)
        throw new st("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", s, t, e);
      return o;
    }
  } else {
    i || (e = Kn(e));
    var a = t.path || "", l = a.split("/"), u = e, c = 1, f = l.length, d = void 0, h = void 0, g = void 0;
    for (typeof n == "function" ? g = n : g = rg; ; ) {
      if (h = l[c], h && h.indexOf("~") != -1 && (h = R3(h)), r && (h == "__proto__" || h == "prototype" && c > 0 && l[c - 1] == "constructor"))
        throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
      if (n && d === void 0 && (u[h] === void 0 ? d = l.slice(0, c).join("/") : c == f - 1 && (d = t.path), d !== void 0 && g(t, 0, e, d)), c++, Array.isArray(u)) {
        if (h === "-")
          h = u.length;
        else {
          if (n && !Sy(h))
            throw new st("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", s, t, e);
          Sy(h) && (h = ~~h);
        }
        if (c >= f) {
          if (n && t.op === "add" && h > u.length)
            throw new st("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", s, t, e);
          var o = dI[t.op].call(t, u, h, e);
          if (o.test === !1)
            throw new st("Test operation failed", "TEST_OPERATION_FAILED", s, t, e);
          return o;
        }
      } else if (c >= f) {
        var o = Nl[t.op].call(t, u, h, e);
        if (o.test === !1)
          throw new st("Test operation failed", "TEST_OPERATION_FAILED", s, t, e);
        return o;
      }
      if (u = u[h], n && c < f && (!u || typeof u != "object"))
        throw new st("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", s, t, e);
    }
  }
}
function zp(e, t, n, i, r) {
  if (i === void 0 && (i = !0), r === void 0 && (r = !0), n && !Array.isArray(t))
    throw new st("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
  i || (e = Kn(e));
  for (var s = new Array(t.length), o = 0, a = t.length; o < a; o++)
    s[o] = ba(e, t[o], n, !0, r, o), e = s[o].newDocument;
  return s.newDocument = e, s;
}
function hI(e, t, n) {
  var i = ba(e, t);
  if (i.test === !1)
    throw new st("Test operation failed", "TEST_OPERATION_FAILED", n, t, e);
  return i.newDocument;
}
function rg(e, t, n, i) {
  if (typeof e != "object" || e === null || Array.isArray(e))
    throw new st("Operation is not an object", "OPERATION_NOT_AN_OBJECT", t, e, n);
  if (Nl[e.op]) {
    if (typeof e.path != "string")
      throw new st("Operation `path` property is not a string", "OPERATION_PATH_INVALID", t, e, n);
    if (e.path.indexOf("/") !== 0 && e.path.length > 0)
      throw new st('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", t, e, n);
    if ((e.op === "move" || e.op === "copy") && typeof e.from != "string")
      throw new st("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", t, e, n);
    if ((e.op === "add" || e.op === "replace" || e.op === "test") && e.value === void 0)
      throw new st("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", t, e, n);
    if ((e.op === "add" || e.op === "replace" || e.op === "test") && ky(e.value))
      throw new st("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", t, e, n);
    if (n) {
      if (e.op == "add") {
        var r = e.path.split("/").length, s = i.split("/").length;
        if (r !== s + 1 && r !== s)
          throw new st("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", t, e, n);
      } else if (e.op === "replace" || e.op === "remove" || e.op === "_get") {
        if (e.path !== i)
          throw new st("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", t, e, n);
      } else if (e.op === "move" || e.op === "copy") {
        var o = { op: "_get", path: e.from, value: void 0 }, a = P3([o], n);
        if (a && a.name === "OPERATION_PATH_UNRESOLVABLE")
          throw new st("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", t, e, n);
      }
    }
  } else
    throw new st("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", t, e, n);
}
function P3(e, t, n) {
  try {
    if (!Array.isArray(e))
      throw new st("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
    if (t)
      zp(Kn(t), Kn(e), n || !0);
    else {
      n = n || rg;
      for (var i = 0; i < e.length; i++)
        n(e[i], i, t, void 0);
    }
  } catch (r) {
    if (r instanceof st)
      return r;
    throw r;
  }
}
function vf(e, t) {
  if (e === t)
    return !0;
  if (e && t && typeof e == "object" && typeof t == "object") {
    var n = Array.isArray(e), i = Array.isArray(t), r, s, o;
    if (n && i) {
      if (s = e.length, s != t.length)
        return !1;
      for (r = s; r-- !== 0; )
        if (!vf(e[r], t[r]))
          return !1;
      return !0;
    }
    if (n != i)
      return !1;
    var a = Object.keys(e);
    if (s = a.length, s !== Object.keys(t).length)
      return !1;
    for (r = s; r-- !== 0; )
      if (!t.hasOwnProperty(a[r]))
        return !1;
    for (r = s; r-- !== 0; )
      if (o = a[r], !vf(e[o], t[o]))
        return !1;
    return !0;
  }
  return e !== e && t !== t;
}
const gI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  JsonPatchError: st,
  _areEquals: vf,
  applyOperation: ba,
  applyPatch: zp,
  applyReducer: hI,
  deepClone: fI,
  getValueByPointer: ig,
  validate: P3,
  validator: rg
}, Symbol.toStringTag, { value: "Module" }));
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2021 Joachim Wester
 * MIT license
 */
var Wv = /* @__PURE__ */ new WeakMap(), pI = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(t) {
      this.observers = /* @__PURE__ */ new Map(), this.obj = t;
    }
    return e;
  }()
), mI = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(t, n) {
      this.callback = t, this.observer = n;
    }
    return e;
  }()
);
function yI(e) {
  return Wv.get(e);
}
function bI(e, t) {
  return e.observers.get(t);
}
function vI(e, t) {
  e.observers.delete(t.callback);
}
function xI(e, t) {
  t.unobserve();
}
function wI(e, t) {
  var n = [], i, r = yI(e);
  if (!r)
    r = new pI(e), Wv.set(e, r);
  else {
    var s = bI(r, t);
    i = s && s.observer;
  }
  if (i)
    return i;
  if (i = {}, r.value = Kn(e), t) {
    i.callback = t, i.next = null;
    var o = function() {
      Ay(i);
    }, a = function() {
      clearTimeout(i.next), i.next = setTimeout(o);
    };
    typeof window < "u" && (window.addEventListener("mouseup", a), window.addEventListener("keyup", a), window.addEventListener("mousedown", a), window.addEventListener("keydown", a), window.addEventListener("change", a));
  }
  return i.patches = n, i.object = e, i.unobserve = function() {
    Ay(i), clearTimeout(i.next), vI(r, i), typeof window < "u" && (window.removeEventListener("mouseup", a), window.removeEventListener("keyup", a), window.removeEventListener("mousedown", a), window.removeEventListener("keydown", a), window.removeEventListener("change", a));
  }, r.observers.set(t, new mI(t, i)), i;
}
function Ay(e, t) {
  t === void 0 && (t = !1);
  var n = Wv.get(e.object);
  Hv(n.value, e.object, e.patches, "", t), e.patches.length && zp(n.value, e.patches);
  var i = e.patches;
  return i.length > 0 && (e.patches = [], e.callback && e.callback(i)), i;
}
function Hv(e, t, n, i, r) {
  if (t !== e) {
    typeof t.toJSON == "function" && (t = t.toJSON());
    for (var s = Ey(t), o = Ey(e), a = !1, l = o.length - 1; l >= 0; l--) {
      var u = o[l], c = e[u];
      if (_y(t, u) && !(t[u] === void 0 && c !== void 0 && Array.isArray(t) === !1)) {
        var f = t[u];
        typeof c == "object" && c != null && typeof f == "object" && f != null && Array.isArray(c) === Array.isArray(f) ? Hv(c, f, n, i + "/" + ia(u), r) : c !== f && (r && n.push({ op: "test", path: i + "/" + ia(u), value: Kn(c) }), n.push({ op: "replace", path: i + "/" + ia(u), value: Kn(f) }));
      } else
        Array.isArray(e) === Array.isArray(t) ? (r && n.push({ op: "test", path: i + "/" + ia(u), value: Kn(c) }), n.push({ op: "remove", path: i + "/" + ia(u) }), a = !0) : (r && n.push({ op: "test", path: i, value: e }), n.push({ op: "replace", path: i, value: t }));
    }
    if (!(!a && s.length == o.length))
      for (var l = 0; l < s.length; l++) {
        var u = s[l];
        !_y(e, u) && t[u] !== void 0 && n.push({ op: "add", path: i + "/" + ia(u), value: Kn(t[u]) });
      }
  }
}
function _I(e, t, n) {
  n === void 0 && (n = !1);
  var i = [];
  return Hv(e, t, i, "", n), i;
}
const EI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  compare: _I,
  generate: Ay,
  observe: wI,
  unobserve: xI
}, Symbol.toStringTag, { value: "Module" }));
Object.assign({}, gI, EI, {
  JsonPatchError: L3,
  deepClone: Kn,
  escapePathComponent: ia,
  unescapePathComponent: R3
});
function I3(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var SI = /("(?:[^\\"]|\\.)*")|[:,]/g, kI = function(t, n) {
  var i, r, s;
  return n = n || {}, i = JSON.stringify(
    [1],
    void 0,
    n.indent === void 0 ? 2 : n.indent
  ).slice(2, -3), r = i === "" ? 1 / 0 : n.maxLength === void 0 ? 80 : n.maxLength, s = n.replacer, function o(a, l, u) {
    var c, f, d, h, g, p, m, y, b, v, _, x;
    if (a && typeof a.toJSON == "function" && (a = a.toJSON()), _ = JSON.stringify(a, s), _ === void 0)
      return _;
    if (m = r - l.length - u, _.length <= m && (b = _.replace(
      SI,
      function(S, E) {
        return E || S + " ";
      }
    ), b.length <= m))
      return b;
    if (s != null && (a = JSON.parse(_), s = void 0), typeof a == "object" && a !== null) {
      if (y = l + i, d = [], f = 0, Array.isArray(a))
        for (v = "[", c = "]", m = a.length; f < m; f++)
          d.push(
            o(a[f], y, f === m - 1 ? 0 : 1) || "null"
          );
      else
        for (v = "{", c = "}", p = Object.keys(a), m = p.length; f < m; f++)
          h = p[f], g = JSON.stringify(h) + ": ", x = o(
            a[h],
            y,
            g.length + (f === m - 1 ? 0 : 1)
          ), x !== void 0 && d.push(g + x);
      if (d.length > 0)
        return [v, i + d.join(`,
` + y), c].join(
          `
` + l
        );
    }
    return _;
  }(t, "", 0);
};
const V0 = /* @__PURE__ */ I3(kI);
function Wn(e, t, n) {
  return e.fields = t || [], e.fname = n, e;
}
function ut(e) {
  return e == null ? null : e.fname;
}
function nn(e) {
  return e == null ? null : e.fields;
}
function z3(e) {
  return e.length === 1 ? AI(e[0]) : CI(e);
}
const AI = (e) => function(t) {
  return t[e];
}, CI = (e) => {
  const t = e.length;
  return function(n) {
    for (let i = 0; i < t; ++i)
      n = n[e[i]];
    return n;
  };
};
function j(e) {
  throw Error(e);
}
function Pr(e) {
  const t = [], n = e.length;
  let i = null, r = 0, s = "", o, a, l;
  e = e + "";
  function u() {
    t.push(s + e.substring(o, a)), s = "", o = a + 1;
  }
  for (o = a = 0; a < n; ++a)
    if (l = e[a], l === "\\")
      s += e.substring(o, a++), o = a;
    else if (l === i)
      u(), i = null, r = -1;
    else {
      if (i)
        continue;
      o === r && l === '"' || o === r && l === "'" ? (o = a + 1, i = l) : l === "." && !r ? a > o ? u() : o = a + 1 : l === "[" ? (a > o && u(), r = o = a + 1) : l === "]" && (r || j("Access path missing open bracket: " + e), r > 0 && u(), r = 0, o = a + 1);
    }
  return r && j("Access path missing closing bracket: " + e), i && j("Access path missing closing quote: " + e), a > o && (a++, u()), t;
}
function _i(e, t, n) {
  const i = Pr(e);
  return e = i.length === 1 ? i[0] : e, Wn((n && n.get || z3)(i), [e], t || e);
}
const ed = _i("id"), an = Wn((e) => e, [], "identity"), Xs = Wn(() => 0, [], "zero"), Nu = Wn(() => 1, [], "one"), Ei = Wn(() => !0, [], "true"), js = Wn(() => !1, [], "false");
function $I(e, t, n) {
  const i = [t].concat([].slice.call(n));
  console[e].apply(console, i);
}
const B3 = 0, Gv = 1, Vv = 2, j3 = 3, U3 = 4;
function Yv(e, t) {
  let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : $I, i = e || B3;
  return {
    level(r) {
      return arguments.length ? (i = +r, this) : i;
    },
    error() {
      return i >= Gv && n(t || "error", "ERROR", arguments), this;
    },
    warn() {
      return i >= Vv && n(t || "warn", "WARN", arguments), this;
    },
    info() {
      return i >= j3 && n(t || "log", "INFO", arguments), this;
    },
    debug() {
      return i >= U3 && n(t || "log", "DEBUG", arguments), this;
    }
  };
}
var U = Array.isArray;
function ne(e) {
  return e === Object(e);
}
const US = (e) => e !== "__proto__";
function Du() {
  for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
    t[n] = arguments[n];
  return t.reduce((i, r) => {
    for (const s in r)
      if (s === "signals")
        i.signals = MI(i.signals, r.signals);
      else {
        const o = s === "legend" ? {
          layout: 1
        } : s === "style" ? !0 : null;
        Ru(i, s, r[s], o);
      }
    return i;
  }, {});
}
function Ru(e, t, n, i) {
  if (!US(t))
    return;
  let r, s;
  if (ne(n) && !U(n)) {
    s = ne(e[t]) ? e[t] : e[t] = {};
    for (r in n)
      i && (i === !0 || i[r]) ? Ru(s, r, n[r]) : US(r) && (s[r] = n[r]);
  } else
    e[t] = n;
}
function MI(e, t) {
  if (e == null)
    return t;
  const n = {}, i = [];
  function r(s) {
    n[s.name] || (n[s.name] = 1, i.push(s));
  }
  return t.forEach(r), e.forEach(r), i;
}
function Te(e) {
  return e[e.length - 1];
}
function Zt(e) {
  return e == null || e === "" ? null : +e;
}
const q3 = (e) => (t) => e * Math.exp(t), W3 = (e) => (t) => Math.log(e * t), H3 = (e) => (t) => Math.sign(t) * Math.log1p(Math.abs(t / e)), G3 = (e) => (t) => Math.sign(t) * Math.expm1(Math.abs(t)) * e, sg = (e) => (t) => t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
function Bp(e, t, n, i) {
  const r = n(e[0]), s = n(Te(e)), o = (s - r) * t;
  return [i(r - o), i(s - o)];
}
function V3(e, t) {
  return Bp(e, t, Zt, an);
}
function Y3(e, t) {
  var n = Math.sign(e[0]);
  return Bp(e, t, W3(n), q3(n));
}
function X3(e, t, n) {
  return Bp(e, t, sg(n), sg(1 / n));
}
function K3(e, t, n) {
  return Bp(e, t, H3(n), G3(n));
}
function jp(e, t, n, i, r) {
  const s = i(e[0]), o = i(Te(e)), a = t != null ? i(t) : (s + o) / 2;
  return [r(a + (s - a) * n), r(a + (o - a) * n)];
}
function Xv(e, t, n) {
  return jp(e, t, n, Zt, an);
}
function Kv(e, t, n) {
  const i = Math.sign(e[0]);
  return jp(e, t, n, W3(i), q3(i));
}
function og(e, t, n, i) {
  return jp(e, t, n, sg(i), sg(1 / i));
}
function Jv(e, t, n, i) {
  return jp(e, t, n, H3(i), G3(i));
}
function J3(e) {
  return 1 + ~~(new Date(e).getMonth() / 3);
}
function Q3(e) {
  return 1 + ~~(new Date(e).getUTCMonth() / 3);
}
function ee(e) {
  return e != null ? U(e) ? e : [e] : [];
}
function Z3(e, t, n) {
  let i = e[0], r = e[1], s;
  return r < i && (s = r, r = i, i = s), s = r - i, s >= n - t ? [t, n] : [i = Math.min(Math.max(i, t), n - s), i + s];
}
function Ee(e) {
  return typeof e == "function";
}
const FI = "descending";
function Qv(e, t, n) {
  n = n || {}, t = ee(t) || [];
  const i = [], r = [], s = {}, o = n.comparator || TI;
  return ee(e).forEach((a, l) => {
    a != null && (i.push(t[l] === FI ? -1 : 1), r.push(a = Ee(a) ? a : _i(a, null, n)), (nn(a) || []).forEach((u) => s[u] = 1));
  }), r.length === 0 ? null : Wn(o(r, i), Object.keys(s));
}
const Up = (e, t) => (e < t || e == null) && t != null ? -1 : (e > t || t == null) && e != null ? 1 : (t = t instanceof Date ? +t : t, (e = e instanceof Date ? +e : e) !== e && t === t ? -1 : t !== t && e === e ? 1 : 0), TI = (e, t) => e.length === 1 ? OI(e[0], t[0]) : NI(e, t, e.length), OI = (e, t) => function(n, i) {
  return Up(e(n), e(i)) * t;
}, NI = (e, t, n) => (t.push(0), function(i, r) {
  let s, o = 0, a = -1;
  for (; o === 0 && ++a < n; )
    s = e[a], o = Up(s(i), s(r));
  return o * t[a];
});
function ln(e) {
  return Ee(e) ? e : () => e;
}
function Zv(e, t) {
  let n;
  return (i) => {
    n && clearTimeout(n), n = setTimeout(() => (t(i), n = null), e);
  };
}
function we(e) {
  for (let t, n, i = 1, r = arguments.length; i < r; ++i) {
    t = arguments[i];
    for (n in t)
      e[n] = t[n];
  }
  return e;
}
function $r(e, t) {
  let n = 0, i, r, s, o;
  if (e && (i = e.length))
    if (t == null) {
      for (r = e[n]; n < i && (r == null || r !== r); r = e[++n])
        ;
      for (s = o = r; n < i; ++n)
        r = e[n], r != null && (r < s && (s = r), r > o && (o = r));
    } else {
      for (r = t(e[n]); n < i && (r == null || r !== r); r = t(e[++n]))
        ;
      for (s = o = r; n < i; ++n)
        r = t(e[n]), r != null && (r < s && (s = r), r > o && (o = r));
    }
  return [s, o];
}
function eF(e, t) {
  const n = e.length;
  let i = -1, r, s, o, a, l;
  if (t == null) {
    for (; ++i < n; )
      if (s = e[i], s != null && s >= s) {
        r = o = s;
        break;
      }
    if (i === n)
      return [-1, -1];
    for (a = l = i; ++i < n; )
      s = e[i], s != null && (r > s && (r = s, a = i), o < s && (o = s, l = i));
  } else {
    for (; ++i < n; )
      if (s = t(e[i], i, e), s != null && s >= s) {
        r = o = s;
        break;
      }
    if (i === n)
      return [-1, -1];
    for (a = l = i; ++i < n; )
      s = t(e[i], i, e), s != null && (r > s && (r = s, a = i), o < s && (o = s, l = i));
  }
  return [a, l];
}
const DI = Object.prototype.hasOwnProperty;
function ce(e, t) {
  return DI.call(e, t);
}
const Wd = {};
function Lu(e) {
  let t = {}, n;
  function i(s) {
    return ce(t, s) && t[s] !== Wd;
  }
  const r = {
    size: 0,
    empty: 0,
    object: t,
    has: i,
    get(s) {
      return i(s) ? t[s] : void 0;
    },
    set(s, o) {
      return i(s) || (++r.size, t[s] === Wd && --r.empty), t[s] = o, this;
    },
    delete(s) {
      return i(s) && (--r.size, ++r.empty, t[s] = Wd), this;
    },
    clear() {
      r.size = r.empty = 0, r.object = t = {};
    },
    test(s) {
      return arguments.length ? (n = s, r) : n;
    },
    clean() {
      const s = {};
      let o = 0;
      for (const a in t) {
        const l = t[a];
        l !== Wd && (!n || !n(l)) && (s[a] = l, ++o);
      }
      r.size = o, r.empty = 0, r.object = t = s;
    }
  };
  return e && Object.keys(e).forEach((s) => {
    r.set(s, e[s]);
  }), r;
}
function tF(e, t, n, i, r, s) {
  if (!n && n !== 0)
    return s;
  const o = +n;
  let a = e[0], l = Te(e), u;
  l < a && (u = a, a = l, l = u), u = Math.abs(t - a);
  const c = Math.abs(l - t);
  return u < c && u <= o ? i : c <= o ? r : s;
}
function Y(e, t, n) {
  const i = e.prototype = Object.create(t.prototype);
  return Object.defineProperty(i, "constructor", {
    value: e,
    writable: !0,
    enumerable: !0,
    configurable: !0
  }), we(i, n);
}
function Dl(e, t, n, i) {
  let r = t[0], s = t[t.length - 1], o;
  return r > s && (o = r, r = s, s = o), n = n === void 0 || n, i = i === void 0 || i, (n ? r <= e : r < e) && (i ? e <= s : e < s);
}
function To(e) {
  return typeof e == "boolean";
}
function so(e) {
  return Object.prototype.toString.call(e) === "[object Date]";
}
function nF(e) {
  return e && Ee(e[Symbol.iterator]);
}
function Re(e) {
  return typeof e == "number";
}
function iF(e) {
  return Object.prototype.toString.call(e) === "[object RegExp]";
}
function te(e) {
  return typeof e == "string";
}
function ex(e, t, n) {
  e && (e = t ? ee(e).map((a) => a.replace(/\\(.)/g, "$1")) : ee(e));
  const i = e && e.length, r = n && n.get || z3, s = (a) => r(t ? [a] : Pr(a));
  let o;
  if (!i)
    o = function() {
      return "";
    };
  else if (i === 1) {
    const a = s(e[0]);
    o = function(l) {
      return "" + a(l);
    };
  } else {
    const a = e.map(s);
    o = function(l) {
      let u = "" + a[0](l), c = 0;
      for (; ++c < i; )
        u += "|" + a[c](l);
      return u;
    };
  }
  return Wn(o, e, "key");
}
function rF(e, t) {
  const n = e[0], i = Te(e), r = +t;
  return r ? r === 1 ? i : n + r * (i - n) : n;
}
const RI = 1e4;
function sF(e) {
  e = +e || RI;
  let t, n, i;
  const r = () => {
    t = {}, n = {}, i = 0;
  }, s = (o, a) => (++i > e && (n = t, t = {}, i = 1), t[o] = a);
  return r(), {
    clear: r,
    has: (o) => ce(t, o) || ce(n, o),
    get: (o) => ce(t, o) ? t[o] : ce(n, o) ? s(o, n[o]) : void 0,
    set: (o, a) => ce(t, o) ? t[o] = a : s(o, a)
  };
}
function oF(e, t, n, i) {
  const r = t.length, s = n.length;
  if (!s)
    return t;
  if (!r)
    return n;
  const o = i || new t.constructor(r + s);
  let a = 0, l = 0, u = 0;
  for (; a < r && l < s; ++u)
    o[u] = e(t[a], n[l]) > 0 ? n[l++] : t[a++];
  for (; a < r; ++a, ++u)
    o[u] = t[a];
  for (; l < s; ++l, ++u)
    o[u] = n[l];
  return o;
}
function Fc(e, t) {
  let n = "";
  for (; --t >= 0; )
    n += e;
  return n;
}
function aF(e, t, n, i) {
  const r = n || " ", s = e + "", o = t - s.length;
  return o <= 0 ? s : i === "left" ? Fc(r, o) + s : i === "center" ? Fc(r, ~~(o / 2)) + s + Fc(r, Math.ceil(o / 2)) : s + Fc(r, o);
}
function td(e) {
  return e && Te(e) - e[0] || 0;
}
function X(e) {
  return U(e) ? "[" + e.map(X) + "]" : ne(e) || te(e) ? (
    // Output valid JSON and JS source strings.
    // See http://timelessrepo.com/json-isnt-a-javascript-subset
    JSON.stringify(e).replace("\u2028", "\\u2028").replace("\u2029", "\\u2029")
  ) : e;
}
function tx(e) {
  return e == null || e === "" ? null : !e || e === "false" || e === "0" ? !1 : !!e;
}
const LI = (e) => Re(e) || so(e) ? e : Date.parse(e);
function nx(e, t) {
  return t = t || LI, e == null || e === "" ? null : t(e);
}
function ix(e) {
  return e == null || e === "" ? null : e + "";
}
function Ji(e) {
  const t = {}, n = e.length;
  for (let i = 0; i < n; ++i)
    t[e[i]] = !0;
  return t;
}
function lF(e, t, n, i) {
  const r = i ?? "…", s = e + "", o = s.length, a = Math.max(0, t - r.length);
  return o <= t ? s : n === "left" ? r + s.slice(o - a) : n === "center" ? s.slice(0, Math.ceil(a / 2)) + r + s.slice(o - ~~(a / 2)) : s.slice(0, a) + r;
}
function Ws(e, t, n) {
  if (e)
    if (t) {
      const i = e.length;
      for (let r = 0; r < i; ++r) {
        const s = t(e[r]);
        s && n(s, r, e);
      }
    } else
      e.forEach(n);
}
var qS = {}, Y0 = {}, X0 = 34, rc = 10, K0 = 13;
function uF(e) {
  return new Function("d", "return {" + e.map(function(t, n) {
    return JSON.stringify(t) + ": d[" + n + '] || ""';
  }).join(",") + "}");
}
function PI(e, t) {
  var n = uF(e);
  return function(i, r) {
    return t(n(i), r, e);
  };
}
function WS(e) {
  var t = /* @__PURE__ */ Object.create(null), n = [];
  return e.forEach(function(i) {
    for (var r in i)
      r in t || n.push(t[r] = r);
  }), n;
}
function Cn(e, t) {
  var n = e + "", i = n.length;
  return i < t ? new Array(t - i + 1).join(0) + n : n;
}
function II(e) {
  return e < 0 ? "-" + Cn(-e, 6) : e > 9999 ? "+" + Cn(e, 6) : Cn(e, 4);
}
function zI(e) {
  var t = e.getUTCHours(), n = e.getUTCMinutes(), i = e.getUTCSeconds(), r = e.getUTCMilliseconds();
  return isNaN(e) ? "Invalid Date" : II(e.getUTCFullYear()) + "-" + Cn(e.getUTCMonth() + 1, 2) + "-" + Cn(e.getUTCDate(), 2) + (r ? "T" + Cn(t, 2) + ":" + Cn(n, 2) + ":" + Cn(i, 2) + "." + Cn(r, 3) + "Z" : i ? "T" + Cn(t, 2) + ":" + Cn(n, 2) + ":" + Cn(i, 2) + "Z" : n || t ? "T" + Cn(t, 2) + ":" + Cn(n, 2) + "Z" : "");
}
function BI(e) {
  var t = new RegExp('["' + e + `
\r]`), n = e.charCodeAt(0);
  function i(f, d) {
    var h, g, p = r(f, function(m, y) {
      if (h)
        return h(m, y - 1);
      g = m, h = d ? PI(m, d) : uF(m);
    });
    return p.columns = g || [], p;
  }
  function r(f, d) {
    var h = [], g = f.length, p = 0, m = 0, y, b = g <= 0, v = !1;
    f.charCodeAt(g - 1) === rc && --g, f.charCodeAt(g - 1) === K0 && --g;
    function _() {
      if (b)
        return Y0;
      if (v)
        return v = !1, qS;
      var S, E = p, C;
      if (f.charCodeAt(E) === X0) {
        for (; p++ < g && f.charCodeAt(p) !== X0 || f.charCodeAt(++p) === X0; )
          ;
        return (S = p) >= g ? b = !0 : (C = f.charCodeAt(p++)) === rc ? v = !0 : C === K0 && (v = !0, f.charCodeAt(p) === rc && ++p), f.slice(E + 1, S - 1).replace(/""/g, '"');
      }
      for (; p < g; ) {
        if ((C = f.charCodeAt(S = p++)) === rc)
          v = !0;
        else if (C === K0)
          v = !0, f.charCodeAt(p) === rc && ++p;
        else if (C !== n)
          continue;
        return f.slice(E, S);
      }
      return b = !0, f.slice(E, g);
    }
    for (; (y = _()) !== Y0; ) {
      for (var x = []; y !== qS && y !== Y0; )
        x.push(y), y = _();
      d && (x = d(x, m++)) == null || h.push(x);
    }
    return h;
  }
  function s(f, d) {
    return f.map(function(h) {
      return d.map(function(g) {
        return c(h[g]);
      }).join(e);
    });
  }
  function o(f, d) {
    return d == null && (d = WS(f)), [d.map(c).join(e)].concat(s(f, d)).join(`
`);
  }
  function a(f, d) {
    return d == null && (d = WS(f)), s(f, d).join(`
`);
  }
  function l(f) {
    return f.map(u).join(`
`);
  }
  function u(f) {
    return f.map(c).join(e);
  }
  function c(f) {
    return f == null ? "" : f instanceof Date ? zI(f) : t.test(f += "") ? '"' + f.replace(/"/g, '""') + '"' : f;
  }
  return {
    parse: i,
    parseRows: r,
    format: o,
    formatBody: a,
    formatRows: l,
    formatRow: u,
    formatValue: c
  };
}
function jI(e) {
  return e;
}
function UI(e) {
  if (e == null)
    return jI;
  var t, n, i = e.scale[0], r = e.scale[1], s = e.translate[0], o = e.translate[1];
  return function(a, l) {
    l || (t = n = 0);
    var u = 2, c = a.length, f = new Array(c);
    for (f[0] = (t += a[0]) * i + s, f[1] = (n += a[1]) * r + o; u < c; )
      f[u] = a[u], ++u;
    return f;
  };
}
function qI(e, t) {
  for (var n, i = e.length, r = i - t; r < --i; )
    n = e[r], e[r++] = e[i], e[i] = n;
}
function WI(e, t) {
  return typeof t == "string" && (t = e.objects[t]), t.type === "GeometryCollection" ? { type: "FeatureCollection", features: t.geometries.map(function(n) {
    return HS(e, n);
  }) } : HS(e, t);
}
function HS(e, t) {
  var n = t.id, i = t.bbox, r = t.properties == null ? {} : t.properties, s = cF(e, t);
  return n == null && i == null ? { type: "Feature", properties: r, geometry: s } : i == null ? { type: "Feature", id: n, properties: r, geometry: s } : { type: "Feature", id: n, bbox: i, properties: r, geometry: s };
}
function cF(e, t) {
  var n = UI(e.transform), i = e.arcs;
  function r(c, f) {
    f.length && f.pop();
    for (var d = i[c < 0 ? ~c : c], h = 0, g = d.length; h < g; ++h)
      f.push(n(d[h], h));
    c < 0 && qI(f, g);
  }
  function s(c) {
    return n(c);
  }
  function o(c) {
    for (var f = [], d = 0, h = c.length; d < h; ++d)
      r(c[d], f);
    return f.length < 2 && f.push(f[0]), f;
  }
  function a(c) {
    for (var f = o(c); f.length < 4; )
      f.push(f[0]);
    return f;
  }
  function l(c) {
    return c.map(a);
  }
  function u(c) {
    var f = c.type, d;
    switch (f) {
      case "GeometryCollection":
        return { type: f, geometries: c.geometries.map(u) };
      case "Point":
        d = s(c.coordinates);
        break;
      case "MultiPoint":
        d = c.coordinates.map(s);
        break;
      case "LineString":
        d = o(c.arcs);
        break;
      case "MultiLineString":
        d = c.arcs.map(o);
        break;
      case "Polygon":
        d = l(c.arcs);
        break;
      case "MultiPolygon":
        d = c.arcs.map(l);
        break;
      default:
        return null;
    }
    return { type: f, coordinates: d };
  }
  return u(t);
}
function HI(e, t) {
  var n = {}, i = {}, r = {}, s = [], o = -1;
  t.forEach(function(u, c) {
    var f = e.arcs[u < 0 ? ~u : u], d;
    f.length < 3 && !f[1][0] && !f[1][1] && (d = t[++o], t[o] = u, t[c] = d);
  }), t.forEach(function(u) {
    var c = a(u), f = c[0], d = c[1], h, g;
    if (h = r[f])
      if (delete r[h.end], h.push(u), h.end = d, g = i[d]) {
        delete i[g.start];
        var p = g === h ? h : h.concat(g);
        i[p.start = h.start] = r[p.end = g.end] = p;
      } else
        i[h.start] = r[h.end] = h;
    else if (h = i[d])
      if (delete i[h.start], h.unshift(u), h.start = f, g = r[f]) {
        delete r[g.end];
        var m = g === h ? h : g.concat(h);
        i[m.start = g.start] = r[m.end = h.end] = m;
      } else
        i[h.start] = r[h.end] = h;
    else
      h = [u], i[h.start = f] = r[h.end = d] = h;
  });
  function a(u) {
    var c = e.arcs[u < 0 ? ~u : u], f = c[0], d;
    return e.transform ? (d = [0, 0], c.forEach(function(h) {
      d[0] += h[0], d[1] += h[1];
    })) : d = c[c.length - 1], u < 0 ? [d, f] : [f, d];
  }
  function l(u, c) {
    for (var f in u) {
      var d = u[f];
      delete c[d.start], delete d.start, delete d.end, d.forEach(function(h) {
        n[h < 0 ? ~h : h] = 1;
      }), s.push(d);
    }
  }
  return l(r, i), l(i, r), t.forEach(function(u) {
    n[u < 0 ? ~u : u] || s.push([u]);
  }), s;
}
function GI(e) {
  return cF(e, VI.apply(this, arguments));
}
function VI(e, t, n) {
  var i, r, s;
  if (arguments.length > 1)
    i = YI(e, t, n);
  else
    for (r = 0, i = new Array(s = e.arcs.length); r < s; ++r)
      i[r] = r;
  return { type: "MultiLineString", arcs: HI(e, i) };
}
function YI(e, t, n) {
  var i = [], r = [], s;
  function o(f) {
    var d = f < 0 ? ~f : f;
    (r[d] || (r[d] = [])).push({ i: f, g: s });
  }
  function a(f) {
    f.forEach(o);
  }
  function l(f) {
    f.forEach(a);
  }
  function u(f) {
    f.forEach(l);
  }
  function c(f) {
    switch (s = f, f.type) {
      case "GeometryCollection":
        f.geometries.forEach(c);
        break;
      case "LineString":
        a(f.arcs);
        break;
      case "MultiLineString":
      case "Polygon":
        l(f.arcs);
        break;
      case "MultiPolygon":
        u(f.arcs);
        break;
    }
  }
  return c(t), r.forEach(n == null ? function(f) {
    i.push(f[0].i);
  } : function(f) {
    n(f[0].g, f[f.length - 1].g) && i.push(f[0].i);
  }), i;
}
function hs(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function XI(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function Pu(e) {
  let t, n, i;
  e.length !== 2 ? (t = hs, n = (a, l) => hs(e(a), l), i = (a, l) => e(a) - l) : (t = e === hs || e === XI ? e : KI, n = e, i = e);
  function r(a, l, u = 0, c = a.length) {
    if (u < c) {
      if (t(l, l) !== 0)
        return c;
      do {
        const f = u + c >>> 1;
        n(a[f], l) < 0 ? u = f + 1 : c = f;
      } while (u < c);
    }
    return u;
  }
  function s(a, l, u = 0, c = a.length) {
    if (u < c) {
      if (t(l, l) !== 0)
        return c;
      do {
        const f = u + c >>> 1;
        n(a[f], l) <= 0 ? u = f + 1 : c = f;
      } while (u < c);
    }
    return u;
  }
  function o(a, l, u = 0, c = a.length) {
    const f = r(a, l, u, c - 1);
    return f > u && i(a[f - 1], l) > -i(a[f], l) ? f - 1 : f;
  }
  return { left: r, center: o, right: s };
}
function KI() {
  return 0;
}
function fF(e) {
  return e === null ? NaN : +e;
}
function* JI(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let i of e)
      (i = t(i, ++n, e)) != null && (i = +i) >= i && (yield i);
  }
}
const dF = Pu(hs), fo = dF.right, QI = dF.left;
Pu(fF).center;
function ZI(e, t) {
  let n = 0, i, r = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (i = o - r, r += i / ++n, s += i * (o - r));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (i = a - r, r += i / ++n, s += i * (a - r));
  }
  if (n > 1)
    return s / (n - 1);
}
function e9(e, t) {
  const n = ZI(e, t);
  return n && Math.sqrt(n);
}
class bn {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let i = 0;
    for (let r = 0; r < this._n && r < 32; r++) {
      const s = n[r], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[i++] = a), t = o;
    }
    return n[i] = t, this._n = i + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, i, r, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (i = o, r = t[--n], o = i + r, s = r - (o - i), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (r = s * 2, i = o + r, r == i - o && (o = i));
    }
    return o;
  }
}
class GS extends Map {
  constructor(t, n = pF) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const [i, r] of t)
        this.set(i, r);
  }
  get(t) {
    return super.get(Cy(this, t));
  }
  has(t) {
    return super.has(Cy(this, t));
  }
  set(t, n) {
    return super.set(hF(this, t), n);
  }
  delete(t) {
    return super.delete(gF(this, t));
  }
}
class ag extends Set {
  constructor(t, n = pF) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const i of t)
        this.add(i);
  }
  has(t) {
    return super.has(Cy(this, t));
  }
  add(t) {
    return super.add(hF(this, t));
  }
  delete(t) {
    return super.delete(gF(this, t));
  }
}
function Cy({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : n;
}
function hF({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : (e.set(i, n), n);
}
function gF({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) && (n = e.get(i), e.delete(i)), n;
}
function pF(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function t9(e, t) {
  return Array.from(t, (n) => e[n]);
}
function n9(e = hs) {
  if (e === hs)
    return mF;
  if (typeof e != "function")
    throw new TypeError("compare is not a function");
  return (t, n) => {
    const i = e(t, n);
    return i || i === 0 ? i : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function mF(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
const i9 = Math.sqrt(50), r9 = Math.sqrt(10), s9 = Math.sqrt(2);
function lg(e, t, n) {
  const i = (t - e) / Math.max(0, n), r = Math.floor(Math.log10(i)), s = i / Math.pow(10, r), o = s >= i9 ? 10 : s >= r9 ? 5 : s >= s9 ? 2 : 1;
  let a, l, u;
  return r < 0 ? (u = Math.pow(10, -r) / o, a = Math.round(e * u), l = Math.round(t * u), a / u < e && ++a, l / u > t && --l, u = -u) : (u = Math.pow(10, r) * o, a = Math.round(e / u), l = Math.round(t / u), a * u < e && ++a, l * u > t && --l), l < a && 0.5 <= n && n < 2 ? lg(e, t, n * 2) : [a, l, u];
}
function $y(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0))
    return [];
  if (e === t)
    return [e];
  const i = t < e, [r, s, o] = i ? lg(t, e, n) : lg(e, t, n);
  if (!(s >= r))
    return [];
  const a = s - r + 1, l = new Array(a);
  if (i)
    if (o < 0)
      for (let u = 0; u < a; ++u)
        l[u] = (s - u) / -o;
    else
      for (let u = 0; u < a; ++u)
        l[u] = (s - u) * o;
  else if (o < 0)
    for (let u = 0; u < a; ++u)
      l[u] = (r + u) / -o;
  else
    for (let u = 0; u < a; ++u)
      l[u] = (r + u) * o;
  return l;
}
function My(e, t, n) {
  return t = +t, e = +e, n = +n, lg(e, t, n)[2];
}
function ho(e, t, n) {
  t = +t, e = +e, n = +n;
  const i = t < e, r = i ? My(t, e, n) : My(e, t, n);
  return (i ? -1 : 1) * (r < 0 ? 1 / -r : r);
}
function va(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n < i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n < r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function Fy(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n > i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n > r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function yF(e, t, n = 0, i = 1 / 0, r) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), i = Math.floor(Math.min(e.length - 1, i)), !(n <= t && t <= i))
    return e;
  for (r = r === void 0 ? mF : n9(r); i > n; ) {
    if (i - n > 600) {
      const l = i - n + 1, u = t - n + 1, c = Math.log(l), f = 0.5 * Math.exp(2 * c / 3), d = 0.5 * Math.sqrt(c * f * (l - f) / l) * (u - l / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - u * f / l + d)), g = Math.min(i, Math.floor(t + (l - u) * f / l + d));
      yF(e, t, h, g, r);
    }
    const s = e[t];
    let o = n, a = i;
    for (sc(e, n, t), r(e[i], s) > 0 && sc(e, n, i); o < a; ) {
      for (sc(e, o, a), ++o, --a; r(e[o], s) < 0; )
        ++o;
      for (; r(e[a], s) > 0; )
        --a;
    }
    r(e[n], s) === 0 ? sc(e, n, a) : (++a, sc(e, a, i)), a <= t && (n = a + 1), t <= a && (i = a - 1);
  }
  return e;
}
function sc(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function Ty(e, t, n) {
  if (e = Float64Array.from(JI(e, n)), !(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return Fy(e);
    if (t >= 1)
      return va(e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = va(yF(e, s).subarray(0, s + 1)), a = Fy(e.subarray(s + 1));
    return o + (a - o) * (r - s);
  }
}
function bF(e, t, n = fF) {
  if (!(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return +n(e[0], 0, e);
    if (t >= 1)
      return +n(e[i - 1], i - 1, e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (r - s);
  }
}
function o9(e, t) {
  let n = 0, i = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && (++n, i += r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (s = +s) >= s && (++n, i += s);
  }
  if (n)
    return i / n;
}
function vF(e, t) {
  return Ty(e, 0.5, t);
}
function* a9(e) {
  for (const t of e)
    yield* t;
}
function xF(e) {
  return Array.from(a9(e));
}
function Jn(e, t, n) {
  e = +e, t = +t, n = (r = arguments.length) < 2 ? (t = e, e = 0, 1) : r < 3 ? 1 : +n;
  for (var i = -1, r = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(r); ++i < r; )
    s[i] = e + i * n;
  return s;
}
function wF(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      (i = +i) && (n += i);
  else {
    let i = -1;
    for (let r of e)
      (r = +t(r, ++i, e)) && (n += r);
  }
  return n;
}
function l9(e, ...t) {
  e = new ag(e), t = t.map(u9);
  e:
    for (const n of e)
      for (const i of t)
        if (!i.has(n)) {
          e.delete(n);
          continue e;
        }
  return e;
}
function u9(e) {
  return e instanceof ag ? e : new ag(e);
}
function c9(...e) {
  const t = new ag();
  for (const n of e)
    for (const i of n)
      t.add(i);
  return t;
}
function f9(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function ug(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0)
    return null;
  var n, i = e.slice(0, n);
  return [
    i.length > 1 ? i[0] + i.slice(2) : i,
    +e.slice(n + 1)
  ];
}
function Zl(e) {
  return e = ug(Math.abs(e)), e ? e[1] : NaN;
}
function d9(e, t) {
  return function(n, i) {
    for (var r = n.length, s = [], o = 0, a = e[0], l = 0; r > 0 && a > 0 && (l + a + 1 > i && (a = Math.max(1, i - l)), s.push(n.substring(r -= a, r + a)), !((l += a + 1) > i)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function h9(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var g9 = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function $a(e) {
  if (!(t = g9.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new rx({
    fill: t[1],
    align: t[2],
    sign: t[3],
    symbol: t[4],
    zero: t[5],
    width: t[6],
    comma: t[7],
    precision: t[8] && t[8].slice(1),
    trim: t[9],
    type: t[10]
  });
}
$a.prototype = rx.prototype;
function rx(e) {
  this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
}
rx.prototype.toString = function() {
  return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
function p9(e) {
  e:
    for (var t = e.length, n = 1, i = -1, r; n < t; ++n)
      switch (e[n]) {
        case ".":
          i = r = n;
          break;
        case "0":
          i === 0 && (i = n), r = n;
          break;
        default:
          if (!+e[n])
            break e;
          i > 0 && (i = 0);
          break;
      }
  return i > 0 ? e.slice(0, i) + e.slice(r + 1) : e;
}
var _F;
function m9(e, t) {
  var n = ug(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1], s = r - (_F = Math.max(-8, Math.min(8, Math.floor(r / 3))) * 3) + 1, o = i.length;
  return s === o ? i : s > o ? i + new Array(s - o + 1).join("0") : s > 0 ? i.slice(0, s) + "." + i.slice(s) : "0." + new Array(1 - s).join("0") + ug(e, Math.max(0, t + s - 1))[0];
}
function VS(e, t) {
  var n = ug(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1];
  return r < 0 ? "0." + new Array(-r).join("0") + i : i.length > r + 1 ? i.slice(0, r + 1) + "." + i.slice(r + 1) : i + new Array(r - i.length + 2).join("0");
}
const YS = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: f9,
  e: (e, t) => e.toExponential(t),
  f: (e, t) => e.toFixed(t),
  g: (e, t) => e.toPrecision(t),
  o: (e) => Math.round(e).toString(8),
  p: (e, t) => VS(e * 100, t),
  r: VS,
  s: m9,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function XS(e) {
  return e;
}
var KS = Array.prototype.map, JS = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function EF(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? XS : d9(KS.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", i = e.currency === void 0 ? "" : e.currency[1] + "", r = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? XS : h9(KS.call(e.numerals, String)), o = e.percent === void 0 ? "%" : e.percent + "", a = e.minus === void 0 ? "−" : e.minus + "", l = e.nan === void 0 ? "NaN" : e.nan + "";
  function u(f) {
    f = $a(f);
    var d = f.fill, h = f.align, g = f.sign, p = f.symbol, m = f.zero, y = f.width, b = f.comma, v = f.precision, _ = f.trim, x = f.type;
    x === "n" ? (b = !0, x = "g") : YS[x] || (v === void 0 && (v = 12), _ = !0, x = "g"), (m || d === "0" && h === "=") && (m = !0, d = "0", h = "=");
    var S = p === "$" ? n : p === "#" && /[boxX]/.test(x) ? "0" + x.toLowerCase() : "", E = p === "$" ? i : /[%p]/.test(x) ? o : "", C = YS[x], $ = /[defgprs%]/.test(x);
    v = v === void 0 ? 6 : /[gprs]/.test(x) ? Math.max(1, Math.min(21, v)) : Math.max(0, Math.min(20, v));
    function N(O) {
      var P = S, T = E, D, M, w;
      if (x === "c")
        T = C(O) + T, O = "";
      else {
        O = +O;
        var k = O < 0 || 1 / O < 0;
        if (O = isNaN(O) ? l : C(Math.abs(O), v), _ && (O = p9(O)), k && +O == 0 && g !== "+" && (k = !1), P = (k ? g === "(" ? g : a : g === "-" || g === "(" ? "" : g) + P, T = (x === "s" ? JS[8 + _F / 3] : "") + T + (k && g === "(" ? ")" : ""), $) {
          for (D = -1, M = O.length; ++D < M; )
            if (w = O.charCodeAt(D), 48 > w || w > 57) {
              T = (w === 46 ? r + O.slice(D + 1) : O.slice(D)) + T, O = O.slice(0, D);
              break;
            }
        }
      }
      b && !m && (O = t(O, 1 / 0));
      var A = P.length + O.length + T.length, F = A < y ? new Array(y - A + 1).join(d) : "";
      switch (b && m && (O = t(F + O, F.length ? y - T.length : 1 / 0), F = ""), h) {
        case "<":
          O = P + O + T + F;
          break;
        case "=":
          O = P + F + O + T;
          break;
        case "^":
          O = F.slice(0, A = F.length >> 1) + P + O + T + F.slice(A);
          break;
        default:
          O = F + P + O + T;
          break;
      }
      return s(O);
    }
    return N.toString = function() {
      return f + "";
    }, N;
  }
  function c(f, d) {
    var h = u((f = $a(f), f.type = "f", f)), g = Math.max(-8, Math.min(8, Math.floor(Zl(d) / 3))) * 3, p = Math.pow(10, -g), m = JS[8 + g / 3];
    return function(y) {
      return h(p * y) + m;
    };
  }
  return {
    format: u,
    formatPrefix: c
  };
}
var Hd, qp, sx;
y9({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function y9(e) {
  return Hd = EF(e), qp = Hd.format, sx = Hd.formatPrefix, Hd;
}
function SF(e) {
  return Math.max(0, -Zl(Math.abs(e)));
}
function kF(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Zl(t) / 3))) * 3 - Zl(Math.abs(e)));
}
function AF(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Zl(t) - Zl(e)) + 1;
}
const J0 = /* @__PURE__ */ new Date(), Q0 = /* @__PURE__ */ new Date();
function Et(e, t, n, i) {
  function r(s) {
    return e(s = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+s)), s;
  }
  return r.floor = (s) => (e(s = /* @__PURE__ */ new Date(+s)), s), r.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), r.round = (s) => {
    const o = r(s), a = r.ceil(s);
    return s - o < a - s ? o : a;
  }, r.offset = (s, o) => (t(s = /* @__PURE__ */ new Date(+s), o == null ? 1 : Math.floor(o)), s), r.range = (s, o, a) => {
    const l = [];
    if (s = r.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0))
      return l;
    let u;
    do
      l.push(u = /* @__PURE__ */ new Date(+s)), t(s, a), e(s);
    while (u < s && s < o);
    return l;
  }, r.filter = (s) => Et((o) => {
    if (o >= o)
      for (; e(o), !s(o); )
        o.setTime(o - 1);
  }, (o, a) => {
    if (o >= o)
      if (a < 0)
        for (; ++a <= 0; )
          for (; t(o, -1), !s(o); )
            ;
      else
        for (; --a >= 0; )
          for (; t(o, 1), !s(o); )
            ;
  }), n && (r.count = (s, o) => (J0.setTime(+s), Q0.setTime(+o), e(J0), e(Q0), Math.floor(n(J0, Q0))), r.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? r.filter(i ? (o) => i(o) % s === 0 : (o) => r.count(0, o) % s === 0) : r)), r;
}
const eu = Et(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
eu.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? Et((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : eu);
eu.range;
const as = 1e3, gi = as * 60, ls = gi * 60, ws = ls * 24, ox = ws * 7, QS = ws * 30, Z0 = ws * 365, us = Et((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * as);
}, (e, t) => (t - e) / as, (e) => e.getUTCSeconds());
us.range;
const Wp = Et((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * as);
}, (e, t) => {
  e.setTime(+e + t * gi);
}, (e, t) => (t - e) / gi, (e) => e.getMinutes());
Wp.range;
const Hp = Et((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * gi);
}, (e, t) => (t - e) / gi, (e) => e.getUTCMinutes());
Hp.range;
const Gp = Et((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * as - e.getMinutes() * gi);
}, (e, t) => {
  e.setTime(+e + t * ls);
}, (e, t) => (t - e) / ls, (e) => e.getHours());
Gp.range;
const Vp = Et((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * ls);
}, (e, t) => (t - e) / ls, (e) => e.getUTCHours());
Vp.range;
const gs = Et(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * gi) / ws,
  (e) => e.getDate() - 1
);
gs.range;
const oo = Et((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ws, (e) => e.getUTCDate() - 1);
oo.range;
const CF = Et((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ws, (e) => Math.floor(e / ws));
CF.range;
function Qa(e) {
  return Et((t) => {
    t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setDate(t.getDate() + n * 7);
  }, (t, n) => (n - t - (n.getTimezoneOffset() - t.getTimezoneOffset()) * gi) / ox);
}
const Iu = Qa(0), cg = Qa(1), b9 = Qa(2), v9 = Qa(3), tu = Qa(4), x9 = Qa(5), w9 = Qa(6);
Iu.range;
cg.range;
b9.range;
v9.range;
tu.range;
x9.range;
w9.range;
function Za(e) {
  return Et((t) => {
    t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setUTCDate(t.getUTCDate() + n * 7);
  }, (t, n) => (n - t) / ox);
}
const zu = Za(0), fg = Za(1), _9 = Za(2), E9 = Za(3), nu = Za(4), S9 = Za(5), k9 = Za(6);
zu.range;
fg.range;
_9.range;
E9.range;
nu.range;
S9.range;
k9.range;
const xf = Et((e) => {
  e.setDate(1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setMonth(e.getMonth() + t);
}, (e, t) => t.getMonth() - e.getMonth() + (t.getFullYear() - e.getFullYear()) * 12, (e) => e.getMonth());
xf.range;
const wf = Et((e) => {
  e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCMonth(e.getUTCMonth() + t);
}, (e, t) => t.getUTCMonth() - e.getUTCMonth() + (t.getUTCFullYear() - e.getUTCFullYear()) * 12, (e) => e.getUTCMonth());
wf.range;
const Mr = Et((e) => {
  e.setMonth(0, 1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setFullYear(e.getFullYear() + t);
}, (e, t) => t.getFullYear() - e.getFullYear(), (e) => e.getFullYear());
Mr.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Et((t) => {
  t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0);
}, (t, n) => {
  t.setFullYear(t.getFullYear() + n * e);
});
Mr.range;
const Fr = Et((e) => {
  e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCFullYear(e.getUTCFullYear() + t);
}, (e, t) => t.getUTCFullYear() - e.getUTCFullYear(), (e) => e.getUTCFullYear());
Fr.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Et((t) => {
  t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0);
}, (t, n) => {
  t.setUTCFullYear(t.getUTCFullYear() + n * e);
});
Fr.range;
function $F(e, t, n, i, r, s) {
  const o = [
    [us, 1, as],
    [us, 5, 5 * as],
    [us, 15, 15 * as],
    [us, 30, 30 * as],
    [s, 1, gi],
    [s, 5, 5 * gi],
    [s, 15, 15 * gi],
    [s, 30, 30 * gi],
    [r, 1, ls],
    [r, 3, 3 * ls],
    [r, 6, 6 * ls],
    [r, 12, 12 * ls],
    [i, 1, ws],
    [i, 2, 2 * ws],
    [n, 1, ox],
    [t, 1, QS],
    [t, 3, 3 * QS],
    [e, 1, Z0]
  ];
  function a(u, c, f) {
    const d = c < u;
    d && ([u, c] = [c, u]);
    const h = f && typeof f.range == "function" ? f : l(u, c, f), g = h ? h.range(u, +c + 1) : [];
    return d ? g.reverse() : g;
  }
  function l(u, c, f) {
    const d = Math.abs(c - u) / f, h = Pu(([, , m]) => m).right(o, d);
    if (h === o.length)
      return e.every(ho(u / Z0, c / Z0, f));
    if (h === 0)
      return eu.every(Math.max(ho(u, c, f), 1));
    const [g, p] = o[d / o[h - 1][2] < o[h][2] / d ? h - 1 : h];
    return g.every(p);
  }
  return [a, l];
}
const [A9, C9] = $F(Fr, wf, zu, CF, Vp, Hp), [$9, M9] = $F(Mr, xf, Iu, gs, Gp, Wp), qt = "year", In = "quarter", rn = "month", xt = "week", zn = "date", Qt = "day", Tr = "dayofyear", ri = "hours", si = "minutes", Si = "seconds", Qi = "milliseconds", ax = [qt, In, rn, xt, zn, Qt, Tr, ri, si, Si, Qi], e1 = ax.reduce((e, t, n) => (e[t] = 1 + n, e), {});
function lx(e) {
  const t = ee(e).slice(), n = {};
  return t.length || j("Missing time unit."), t.forEach((r) => {
    ce(e1, r) ? n[r] = 1 : j(`Invalid time unit: ${r}.`);
  }), (n[xt] || n[Qt] ? 1 : 0) + (n[In] || n[rn] || n[zn] ? 1 : 0) + (n[Tr] ? 1 : 0) > 1 && j(`Incompatible time units: ${e}`), t.sort((r, s) => e1[r] - e1[s]), t;
}
const F9 = {
  [qt]: "%Y ",
  [In]: "Q%q ",
  [rn]: "%b ",
  [zn]: "%d ",
  [xt]: "W%U ",
  [Qt]: "%a ",
  [Tr]: "%j ",
  [ri]: "%H:00",
  [si]: "00:%M",
  [Si]: ":%S",
  [Qi]: ".%L",
  [`${qt}-${rn}`]: "%Y-%m ",
  [`${qt}-${rn}-${zn}`]: "%Y-%m-%d ",
  [`${ri}-${si}`]: "%H:%M"
};
function MF(e, t) {
  const n = we({}, F9, t), i = lx(e), r = i.length;
  let s = "", o = 0, a, l;
  for (o = 0; o < r; )
    for (a = i.length; a > o; --a)
      if (l = i.slice(o, a).join("-"), n[l] != null) {
        s += n[l], o = a;
        break;
      }
  return s.trim();
}
const oa = /* @__PURE__ */ new Date();
function ux(e) {
  return oa.setFullYear(e), oa.setMonth(0), oa.setDate(1), oa.setHours(0, 0, 0, 0), oa;
}
function FF(e) {
  return OF(new Date(e));
}
function TF(e) {
  return Oy(new Date(e));
}
function OF(e) {
  return gs.count(ux(e.getFullYear()) - 1, e);
}
function Oy(e) {
  return Iu.count(ux(e.getFullYear()) - 1, e);
}
function Ny(e) {
  return ux(e).getDay();
}
function T9(e, t, n, i, r, s, o) {
  if (0 <= e && e < 100) {
    const a = new Date(-1, t, n, i, r, s, o);
    return a.setFullYear(e), a;
  }
  return new Date(e, t, n, i, r, s, o);
}
function NF(e) {
  return RF(new Date(e));
}
function DF(e) {
  return Dy(new Date(e));
}
function RF(e) {
  const t = Date.UTC(e.getUTCFullYear(), 0, 1);
  return oo.count(t - 1, e);
}
function Dy(e) {
  const t = Date.UTC(e.getUTCFullYear(), 0, 1);
  return zu.count(t - 1, e);
}
function Ry(e) {
  return oa.setTime(Date.UTC(e, 0, 1)), oa.getUTCDay();
}
function O9(e, t, n, i, r, s, o) {
  if (0 <= e && e < 100) {
    const a = new Date(Date.UTC(-1, t, n, i, r, s, o));
    return a.setUTCFullYear(n.y), a;
  }
  return new Date(Date.UTC(e, t, n, i, r, s, o));
}
function LF(e, t, n, i, r) {
  const s = t || 1, o = Te(e), a = (y, b, v) => (v = v || y, N9(n[v], i[v], y === o && s, b)), l = /* @__PURE__ */ new Date(), u = Ji(e), c = u[qt] ? a(qt) : ln(2012), f = u[rn] ? a(rn) : u[In] ? a(In) : Xs, d = u[xt] && u[Qt] ? a(Qt, 1, xt + Qt) : u[xt] ? a(xt, 1) : u[Qt] ? a(Qt, 1) : u[zn] ? a(zn, 1) : u[Tr] ? a(Tr, 1) : Nu, h = u[ri] ? a(ri) : Xs, g = u[si] ? a(si) : Xs, p = u[Si] ? a(Si) : Xs, m = u[Qi] ? a(Qi) : Xs;
  return function(y) {
    l.setTime(+y);
    const b = c(l);
    return r(b, f(l), d(l, b), h(l), g(l), p(l), m(l));
  };
}
function N9(e, t, n, i) {
  const r = n <= 1 ? e : i ? (s, o) => i + n * Math.floor((e(s, o) - i) / n) : (s, o) => n * Math.floor(e(s, o) / n);
  return t ? (s, o) => t(r(s, o), o) : r;
}
function iu(e, t, n) {
  return t + e * 7 - (n + 6) % 7;
}
const D9 = {
  [qt]: (e) => e.getFullYear(),
  [In]: (e) => Math.floor(e.getMonth() / 3),
  [rn]: (e) => e.getMonth(),
  [zn]: (e) => e.getDate(),
  [ri]: (e) => e.getHours(),
  [si]: (e) => e.getMinutes(),
  [Si]: (e) => e.getSeconds(),
  [Qi]: (e) => e.getMilliseconds(),
  [Tr]: (e) => OF(e),
  [xt]: (e) => Oy(e),
  [xt + Qt]: (e, t) => iu(Oy(e), e.getDay(), Ny(t)),
  [Qt]: (e, t) => iu(1, e.getDay(), Ny(t))
}, R9 = {
  [In]: (e) => 3 * e,
  [xt]: (e, t) => iu(e, 0, Ny(t))
};
function PF(e, t) {
  return LF(e, t || 1, D9, R9, T9);
}
const L9 = {
  [qt]: (e) => e.getUTCFullYear(),
  [In]: (e) => Math.floor(e.getUTCMonth() / 3),
  [rn]: (e) => e.getUTCMonth(),
  [zn]: (e) => e.getUTCDate(),
  [ri]: (e) => e.getUTCHours(),
  [si]: (e) => e.getUTCMinutes(),
  [Si]: (e) => e.getUTCSeconds(),
  [Qi]: (e) => e.getUTCMilliseconds(),
  [Tr]: (e) => RF(e),
  [xt]: (e) => Dy(e),
  [Qt]: (e, t) => iu(1, e.getUTCDay(), Ry(t)),
  [xt + Qt]: (e, t) => iu(Dy(e), e.getUTCDay(), Ry(t))
}, P9 = {
  [In]: (e) => 3 * e,
  [xt]: (e, t) => iu(e, 0, Ry(t))
};
function IF(e, t) {
  return LF(e, t || 1, L9, P9, O9);
}
const I9 = {
  [qt]: Mr,
  [In]: xf.every(3),
  [rn]: xf,
  [xt]: Iu,
  [zn]: gs,
  [Qt]: gs,
  [Tr]: gs,
  [ri]: Gp,
  [si]: Wp,
  [Si]: us,
  [Qi]: eu
}, z9 = {
  [qt]: Fr,
  [In]: wf.every(3),
  [rn]: wf,
  [xt]: zu,
  [zn]: oo,
  [Qt]: oo,
  [Tr]: oo,
  [ri]: Vp,
  [si]: Hp,
  [Si]: us,
  [Qi]: eu
};
function Bu(e) {
  return I9[e];
}
function ju(e) {
  return z9[e];
}
function zF(e, t, n) {
  return e ? e.offset(t, n) : void 0;
}
function BF(e, t, n) {
  return zF(Bu(e), t, n);
}
function jF(e, t, n) {
  return zF(ju(e), t, n);
}
function UF(e, t, n, i) {
  return e ? e.range(t, n, i) : void 0;
}
function qF(e, t, n, i) {
  return UF(Bu(e), t, n, i);
}
function WF(e, t, n, i) {
  return UF(ju(e), t, n, i);
}
const Tc = 1e3, Oc = Tc * 60, Nc = Oc * 60, Yp = Nc * 24, B9 = Yp * 7, ZS = Yp * 30, Ly = Yp * 365, HF = [qt, rn, zn, ri, si, Si, Qi], Dc = HF.slice(0, -1), Rc = Dc.slice(0, -1), Lc = Rc.slice(0, -1), j9 = Lc.slice(0, -1), U9 = [qt, xt], ek = [qt, rn], GF = [qt], oc = [[Dc, 1, Tc], [Dc, 5, 5 * Tc], [Dc, 15, 15 * Tc], [Dc, 30, 30 * Tc], [Rc, 1, Oc], [Rc, 5, 5 * Oc], [Rc, 15, 15 * Oc], [Rc, 30, 30 * Oc], [Lc, 1, Nc], [Lc, 3, 3 * Nc], [Lc, 6, 6 * Nc], [Lc, 12, 12 * Nc], [j9, 1, Yp], [U9, 1, B9], [ek, 1, ZS], [ek, 3, 3 * ZS], [GF, 1, Ly]];
function VF(e) {
  const t = e.extent, n = e.maxbins || 40, i = Math.abs(td(t)) / n;
  let r = Pu((a) => a[2]).right(oc, i), s, o;
  return r === oc.length ? (s = GF, o = ho(t[0] / Ly, t[1] / Ly, n)) : r ? (r = oc[i / oc[r - 1][2] < oc[r][2] / i ? r - 1 : r], s = r[0], o = r[1]) : (s = HF, o = Math.max(ho(t[0], t[1], n), 1)), {
    units: s,
    step: o
  };
}
function t1(e) {
  if (0 <= e.y && e.y < 100) {
    var t = new Date(-1, e.m, e.d, e.H, e.M, e.S, e.L);
    return t.setFullYear(e.y), t;
  }
  return new Date(e.y, e.m, e.d, e.H, e.M, e.S, e.L);
}
function n1(e) {
  if (0 <= e.y && e.y < 100) {
    var t = new Date(Date.UTC(-1, e.m, e.d, e.H, e.M, e.S, e.L));
    return t.setUTCFullYear(e.y), t;
  }
  return new Date(Date.UTC(e.y, e.m, e.d, e.H, e.M, e.S, e.L));
}
function ac(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function YF(e) {
  var t = e.dateTime, n = e.date, i = e.time, r = e.periods, s = e.days, o = e.shortDays, a = e.months, l = e.shortMonths, u = lc(r), c = uc(r), f = lc(s), d = uc(s), h = lc(o), g = uc(o), p = lc(a), m = uc(a), y = lc(l), b = uc(l), v = {
    a: k,
    A,
    b: F,
    B: R,
    c: null,
    d: ok,
    e: ok,
    f: fz,
    g: wz,
    G: Ez,
    H: lz,
    I: uz,
    j: cz,
    L: XF,
    m: dz,
    M: hz,
    p: L,
    q: V,
    Q: uk,
    s: ck,
    S: gz,
    u: pz,
    U: mz,
    V: yz,
    w: bz,
    W: vz,
    x: null,
    X: null,
    y: xz,
    Y: _z,
    Z: Sz,
    "%": lk
  }, _ = {
    a: K,
    A: Q,
    b: ie,
    B: Le,
    c: null,
    d: ak,
    e: ak,
    f: $z,
    g: Iz,
    G: Bz,
    H: kz,
    I: Az,
    j: Cz,
    L: JF,
    m: Mz,
    M: Fz,
    p: Oe,
    q: mt,
    Q: uk,
    s: ck,
    S: Tz,
    u: Oz,
    U: Nz,
    V: Dz,
    w: Rz,
    W: Lz,
    x: null,
    X: null,
    y: Pz,
    Y: zz,
    Z: jz,
    "%": lk
  }, x = {
    a: N,
    A: O,
    b: P,
    B: T,
    c: D,
    d: rk,
    e: rk,
    f: rz,
    g: ik,
    G: nk,
    H: sk,
    I: sk,
    j: ez,
    L: iz,
    m: Z9,
    M: tz,
    p: $,
    q: Q9,
    Q: oz,
    s: az,
    S: nz,
    u: V9,
    U: Y9,
    V: X9,
    w: G9,
    W: K9,
    x: M,
    X: w,
    y: ik,
    Y: nk,
    Z: J9,
    "%": sz
  };
  v.x = S(n, v), v.X = S(i, v), v.c = S(t, v), _.x = S(n, _), _.X = S(i, _), _.c = S(t, _);
  function S(Z, ye) {
    return function(xe) {
      var W = [], yt = -1, De = 0, kt = Z.length, It, Xr, qd;
      for (xe instanceof Date || (xe = /* @__PURE__ */ new Date(+xe)); ++yt < kt; )
        Z.charCodeAt(yt) === 37 && (W.push(Z.slice(De, yt)), (Xr = tk[It = Z.charAt(++yt)]) != null ? It = Z.charAt(++yt) : Xr = It === "e" ? " " : "0", (qd = ye[It]) && (It = qd(xe, Xr)), W.push(It), De = yt + 1);
      return W.push(Z.slice(De, yt)), W.join("");
    };
  }
  function E(Z, ye) {
    return function(xe) {
      var W = ac(1900, void 0, 1), yt = C(W, Z, xe += "", 0), De, kt;
      if (yt != xe.length)
        return null;
      if ("Q" in W)
        return new Date(W.Q);
      if ("s" in W)
        return new Date(W.s * 1e3 + ("L" in W ? W.L : 0));
      if (ye && !("Z" in W) && (W.Z = 0), "p" in W && (W.H = W.H % 12 + W.p * 12), W.m === void 0 && (W.m = "q" in W ? W.q : 0), "V" in W) {
        if (W.V < 1 || W.V > 53)
          return null;
        "w" in W || (W.w = 1), "Z" in W ? (De = n1(ac(W.y, 0, 1)), kt = De.getUTCDay(), De = kt > 4 || kt === 0 ? fg.ceil(De) : fg(De), De = oo.offset(De, (W.V - 1) * 7), W.y = De.getUTCFullYear(), W.m = De.getUTCMonth(), W.d = De.getUTCDate() + (W.w + 6) % 7) : (De = t1(ac(W.y, 0, 1)), kt = De.getDay(), De = kt > 4 || kt === 0 ? cg.ceil(De) : cg(De), De = gs.offset(De, (W.V - 1) * 7), W.y = De.getFullYear(), W.m = De.getMonth(), W.d = De.getDate() + (W.w + 6) % 7);
      } else
        ("W" in W || "U" in W) && ("w" in W || (W.w = "u" in W ? W.u % 7 : "W" in W ? 1 : 0), kt = "Z" in W ? n1(ac(W.y, 0, 1)).getUTCDay() : t1(ac(W.y, 0, 1)).getDay(), W.m = 0, W.d = "W" in W ? (W.w + 6) % 7 + W.W * 7 - (kt + 5) % 7 : W.w + W.U * 7 - (kt + 6) % 7);
      return "Z" in W ? (W.H += W.Z / 100 | 0, W.M += W.Z % 100, n1(W)) : t1(W);
    };
  }
  function C(Z, ye, xe, W) {
    for (var yt = 0, De = ye.length, kt = xe.length, It, Xr; yt < De; ) {
      if (W >= kt)
        return -1;
      if (It = ye.charCodeAt(yt++), It === 37) {
        if (It = ye.charAt(yt++), Xr = x[It in tk ? ye.charAt(yt++) : It], !Xr || (W = Xr(Z, xe, W)) < 0)
          return -1;
      } else if (It != xe.charCodeAt(W++))
        return -1;
    }
    return W;
  }
  function $(Z, ye, xe) {
    var W = u.exec(ye.slice(xe));
    return W ? (Z.p = c.get(W[0].toLowerCase()), xe + W[0].length) : -1;
  }
  function N(Z, ye, xe) {
    var W = h.exec(ye.slice(xe));
    return W ? (Z.w = g.get(W[0].toLowerCase()), xe + W[0].length) : -1;
  }
  function O(Z, ye, xe) {
    var W = f.exec(ye.slice(xe));
    return W ? (Z.w = d.get(W[0].toLowerCase()), xe + W[0].length) : -1;
  }
  function P(Z, ye, xe) {
    var W = y.exec(ye.slice(xe));
    return W ? (Z.m = b.get(W[0].toLowerCase()), xe + W[0].length) : -1;
  }
  function T(Z, ye, xe) {
    var W = p.exec(ye.slice(xe));
    return W ? (Z.m = m.get(W[0].toLowerCase()), xe + W[0].length) : -1;
  }
  function D(Z, ye, xe) {
    return C(Z, t, ye, xe);
  }
  function M(Z, ye, xe) {
    return C(Z, n, ye, xe);
  }
  function w(Z, ye, xe) {
    return C(Z, i, ye, xe);
  }
  function k(Z) {
    return o[Z.getDay()];
  }
  function A(Z) {
    return s[Z.getDay()];
  }
  function F(Z) {
    return l[Z.getMonth()];
  }
  function R(Z) {
    return a[Z.getMonth()];
  }
  function L(Z) {
    return r[+(Z.getHours() >= 12)];
  }
  function V(Z) {
    return 1 + ~~(Z.getMonth() / 3);
  }
  function K(Z) {
    return o[Z.getUTCDay()];
  }
  function Q(Z) {
    return s[Z.getUTCDay()];
  }
  function ie(Z) {
    return l[Z.getUTCMonth()];
  }
  function Le(Z) {
    return a[Z.getUTCMonth()];
  }
  function Oe(Z) {
    return r[+(Z.getUTCHours() >= 12)];
  }
  function mt(Z) {
    return 1 + ~~(Z.getUTCMonth() / 3);
  }
  return {
    format: function(Z) {
      var ye = S(Z += "", v);
      return ye.toString = function() {
        return Z;
      }, ye;
    },
    parse: function(Z) {
      var ye = E(Z += "", !1);
      return ye.toString = function() {
        return Z;
      }, ye;
    },
    utcFormat: function(Z) {
      var ye = S(Z += "", _);
      return ye.toString = function() {
        return Z;
      }, ye;
    },
    utcParse: function(Z) {
      var ye = E(Z += "", !0);
      return ye.toString = function() {
        return Z;
      }, ye;
    }
  };
}
var tk = { "-": "", _: " ", 0: "0" }, Lt = /^\s*\d+/, q9 = /^%/, W9 = /[\\^$*+?|[\]().{}]/g;
function Ie(e, t, n) {
  var i = e < 0 ? "-" : "", r = (i ? -e : e) + "", s = r.length;
  return i + (s < n ? new Array(n - s + 1).join(t) + r : r);
}
function H9(e) {
  return e.replace(W9, "\\$&");
}
function lc(e) {
  return new RegExp("^(?:" + e.map(H9).join("|") + ")", "i");
}
function uc(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function G9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 1));
  return i ? (e.w = +i[0], n + i[0].length) : -1;
}
function V9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 1));
  return i ? (e.u = +i[0], n + i[0].length) : -1;
}
function Y9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.U = +i[0], n + i[0].length) : -1;
}
function X9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.V = +i[0], n + i[0].length) : -1;
}
function K9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.W = +i[0], n + i[0].length) : -1;
}
function nk(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 4));
  return i ? (e.y = +i[0], n + i[0].length) : -1;
}
function ik(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.y = +i[0] + (+i[0] > 68 ? 1900 : 2e3), n + i[0].length) : -1;
}
function J9(e, t, n) {
  var i = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return i ? (e.Z = i[1] ? 0 : -(i[2] + (i[3] || "00")), n + i[0].length) : -1;
}
function Q9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 1));
  return i ? (e.q = i[0] * 3 - 3, n + i[0].length) : -1;
}
function Z9(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.m = i[0] - 1, n + i[0].length) : -1;
}
function rk(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.d = +i[0], n + i[0].length) : -1;
}
function ez(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 3));
  return i ? (e.m = 0, e.d = +i[0], n + i[0].length) : -1;
}
function sk(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.H = +i[0], n + i[0].length) : -1;
}
function tz(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.M = +i[0], n + i[0].length) : -1;
}
function nz(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 2));
  return i ? (e.S = +i[0], n + i[0].length) : -1;
}
function iz(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 3));
  return i ? (e.L = +i[0], n + i[0].length) : -1;
}
function rz(e, t, n) {
  var i = Lt.exec(t.slice(n, n + 6));
  return i ? (e.L = Math.floor(i[0] / 1e3), n + i[0].length) : -1;
}
function sz(e, t, n) {
  var i = q9.exec(t.slice(n, n + 1));
  return i ? n + i[0].length : -1;
}
function oz(e, t, n) {
  var i = Lt.exec(t.slice(n));
  return i ? (e.Q = +i[0], n + i[0].length) : -1;
}
function az(e, t, n) {
  var i = Lt.exec(t.slice(n));
  return i ? (e.s = +i[0], n + i[0].length) : -1;
}
function ok(e, t) {
  return Ie(e.getDate(), t, 2);
}
function lz(e, t) {
  return Ie(e.getHours(), t, 2);
}
function uz(e, t) {
  return Ie(e.getHours() % 12 || 12, t, 2);
}
function cz(e, t) {
  return Ie(1 + gs.count(Mr(e), e), t, 3);
}
function XF(e, t) {
  return Ie(e.getMilliseconds(), t, 3);
}
function fz(e, t) {
  return XF(e, t) + "000";
}
function dz(e, t) {
  return Ie(e.getMonth() + 1, t, 2);
}
function hz(e, t) {
  return Ie(e.getMinutes(), t, 2);
}
function gz(e, t) {
  return Ie(e.getSeconds(), t, 2);
}
function pz(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function mz(e, t) {
  return Ie(Iu.count(Mr(e) - 1, e), t, 2);
}
function KF(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? tu(e) : tu.ceil(e);
}
function yz(e, t) {
  return e = KF(e), Ie(tu.count(Mr(e), e) + (Mr(e).getDay() === 4), t, 2);
}
function bz(e) {
  return e.getDay();
}
function vz(e, t) {
  return Ie(cg.count(Mr(e) - 1, e), t, 2);
}
function xz(e, t) {
  return Ie(e.getFullYear() % 100, t, 2);
}
function wz(e, t) {
  return e = KF(e), Ie(e.getFullYear() % 100, t, 2);
}
function _z(e, t) {
  return Ie(e.getFullYear() % 1e4, t, 4);
}
function Ez(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? tu(e) : tu.ceil(e), Ie(e.getFullYear() % 1e4, t, 4);
}
function Sz(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Ie(t / 60 | 0, "0", 2) + Ie(t % 60, "0", 2);
}
function ak(e, t) {
  return Ie(e.getUTCDate(), t, 2);
}
function kz(e, t) {
  return Ie(e.getUTCHours(), t, 2);
}
function Az(e, t) {
  return Ie(e.getUTCHours() % 12 || 12, t, 2);
}
function Cz(e, t) {
  return Ie(1 + oo.count(Fr(e), e), t, 3);
}
function JF(e, t) {
  return Ie(e.getUTCMilliseconds(), t, 3);
}
function $z(e, t) {
  return JF(e, t) + "000";
}
function Mz(e, t) {
  return Ie(e.getUTCMonth() + 1, t, 2);
}
function Fz(e, t) {
  return Ie(e.getUTCMinutes(), t, 2);
}
function Tz(e, t) {
  return Ie(e.getUTCSeconds(), t, 2);
}
function Oz(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function Nz(e, t) {
  return Ie(zu.count(Fr(e) - 1, e), t, 2);
}
function QF(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? nu(e) : nu.ceil(e);
}
function Dz(e, t) {
  return e = QF(e), Ie(nu.count(Fr(e), e) + (Fr(e).getUTCDay() === 4), t, 2);
}
function Rz(e) {
  return e.getUTCDay();
}
function Lz(e, t) {
  return Ie(fg.count(Fr(e) - 1, e), t, 2);
}
function Pz(e, t) {
  return Ie(e.getUTCFullYear() % 100, t, 2);
}
function Iz(e, t) {
  return e = QF(e), Ie(e.getUTCFullYear() % 100, t, 2);
}
function zz(e, t) {
  return Ie(e.getUTCFullYear() % 1e4, t, 4);
}
function Bz(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? nu(e) : nu.ceil(e), Ie(e.getUTCFullYear() % 1e4, t, 4);
}
function jz() {
  return "+0000";
}
function lk() {
  return "%";
}
function uk(e) {
  return +e;
}
function ck(e) {
  return Math.floor(+e / 1e3);
}
var ml, cx, ZF, fx, eT;
Uz({
  dateTime: "%x, %X",
  date: "%-m/%-d/%Y",
  time: "%-I:%M:%S %p",
  periods: ["AM", "PM"],
  days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
});
function Uz(e) {
  return ml = YF(e), cx = ml.format, ZF = ml.parse, fx = ml.utcFormat, eT = ml.utcParse, ml;
}
function Pc(e) {
  const t = {};
  return (n) => t[n] || (t[n] = e(n));
}
function qz(e, t) {
  return (n) => {
    const i = e(n), r = i.indexOf(t);
    if (r < 0)
      return i;
    let s = Wz(i, r);
    const o = s < i.length ? i.slice(s) : "";
    for (; --s > r; )
      if (i[s] !== "0") {
        ++s;
        break;
      }
    return i.slice(0, s) + o;
  };
}
function Wz(e, t) {
  let n = e.lastIndexOf("e"), i;
  if (n > 0)
    return n;
  for (n = e.length; --n > t; )
    if (i = e.charCodeAt(n), i >= 48 && i <= 57)
      return n + 1;
}
function tT(e) {
  const t = Pc(e.format), n = e.formatPrefix;
  return {
    format: t,
    formatPrefix: n,
    formatFloat(i) {
      const r = $a(i || ",");
      if (r.precision == null) {
        switch (r.precision = 12, r.type) {
          case "%":
            r.precision -= 2;
            break;
          case "e":
            r.precision -= 1;
            break;
        }
        return qz(
          t(r),
          // number format
          t(".1f")(1)[1]
          // decimal point character
        );
      } else
        return t(r);
    },
    formatSpan(i, r, s, o) {
      o = $a(o ?? ",f");
      const a = ho(i, r, s), l = Math.max(Math.abs(i), Math.abs(r));
      let u;
      if (o.precision == null)
        switch (o.type) {
          case "s":
            return isNaN(u = kF(a, l)) || (o.precision = u), n(o, l);
          case "":
          case "e":
          case "g":
          case "p":
          case "r": {
            isNaN(u = AF(a, l)) || (o.precision = u - (o.type === "e"));
            break;
          }
          case "f":
          case "%": {
            isNaN(u = SF(a)) || (o.precision = u - (o.type === "%") * 2);
            break;
          }
        }
      return t(o);
    }
  };
}
let Py;
nT();
function nT() {
  return Py = tT({
    format: qp,
    formatPrefix: sx
  });
}
function iT(e) {
  return tT(EF(e));
}
function dg(e) {
  return arguments.length ? Py = iT(e) : Py;
}
function fk(e, t, n) {
  n = n || {}, ne(n) || j(`Invalid time multi-format specifier: ${n}`);
  const i = t(Si), r = t(si), s = t(ri), o = t(zn), a = t(xt), l = t(rn), u = t(In), c = t(qt), f = e(n[Qi] || ".%L"), d = e(n[Si] || ":%S"), h = e(n[si] || "%I:%M"), g = e(n[ri] || "%I %p"), p = e(n[zn] || n[Qt] || "%a %d"), m = e(n[xt] || "%b %d"), y = e(n[rn] || "%B"), b = e(n[In] || "%B"), v = e(n[qt] || "%Y");
  return (_) => (i(_) < _ ? f : r(_) < _ ? d : s(_) < _ ? h : o(_) < _ ? g : l(_) < _ ? a(_) < _ ? p : m : c(_) < _ ? u(_) < _ ? y : b : v)(_);
}
function rT(e) {
  const t = Pc(e.format), n = Pc(e.utcFormat);
  return {
    timeFormat: (i) => te(i) ? t(i) : fk(t, Bu, i),
    utcFormat: (i) => te(i) ? n(i) : fk(n, ju, i),
    timeParse: Pc(e.parse),
    utcParse: Pc(e.utcParse)
  };
}
let Iy;
sT();
function sT() {
  return Iy = rT({
    format: cx,
    parse: ZF,
    utcFormat: fx,
    utcParse: eT
  });
}
function oT(e) {
  return rT(YF(e));
}
function _f(e) {
  return arguments.length ? Iy = oT(e) : Iy;
}
const zy = (e, t) => we({}, e, t);
function aT(e, t) {
  const n = e ? iT(e) : dg(), i = t ? oT(t) : _f();
  return zy(n, i);
}
function dx(e, t) {
  const n = arguments.length;
  return n && n !== 2 && j("defaultLocale expects either zero or two arguments."), n ? zy(dg(e), _f(t)) : zy(dg(), _f());
}
function Hz() {
  return nT(), sT(), dx();
}
const Gz = /^(data:|([A-Za-z]+:)?\/\/)/, Vz = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i, Yz = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g, dk = "file://";
function Xz(e, t) {
  return (n) => ({
    options: n || {},
    sanitize: Jz,
    load: Kz,
    fileAccess: !!t,
    file: Qz(t),
    http: e7(e)
  });
}
async function Kz(e, t) {
  const n = await this.sanitize(e, t), i = n.href;
  return n.localFile ? this.file(i) : this.http(i, t);
}
async function Jz(e, t) {
  t = we({}, this.options, t);
  const n = this.fileAccess, i = {
    href: null
  };
  let r, s, o;
  const a = Vz.test(e.replace(Yz, ""));
  (e == null || typeof e != "string" || !a) && j("Sanitize failure, invalid URI: " + X(e));
  const l = Gz.test(e);
  return (o = t.baseURL) && !l && (!e.startsWith("/") && !o.endsWith("/") && (e = "/" + e), e = o + e), s = (r = e.startsWith(dk)) || t.mode === "file" || t.mode !== "http" && !l && n, r ? e = e.slice(dk.length) : e.startsWith("//") && (t.defaultProtocol === "file" ? (e = e.slice(2), s = !0) : e = (t.defaultProtocol || "http") + ":" + e), Object.defineProperty(i, "localFile", {
    value: !!s
  }), i.href = e, t.target && (i.target = t.target + ""), t.rel && (i.rel = t.rel + ""), t.context === "image" && t.crossOrigin && (i.crossOrigin = t.crossOrigin + ""), i;
}
function Qz(e) {
  return e ? (t) => new Promise((n, i) => {
    e.readFile(t, (r, s) => {
      r ? i(r) : n(s);
    });
  }) : Zz;
}
async function Zz() {
  j("No file system access.");
}
function e7(e) {
  return e ? async function(t, n) {
    const i = we({}, this.options.http, n), r = n && n.response, s = await e(t, i);
    return s.ok ? Ee(s[r]) ? s[r]() : s.text() : j(s.status + "" + s.statusText);
  } : t7;
}
async function t7() {
  j("No HTTP fetch method available.");
}
const n7 = (e) => e != null && e === e, i7 = (e) => e === "true" || e === "false" || e === !0 || e === !1, r7 = (e) => !Number.isNaN(Date.parse(e)), lT = (e) => !Number.isNaN(+e) && !(e instanceof Date), s7 = (e) => lT(e) && Number.isInteger(+e), By = {
  boolean: tx,
  integer: Zt,
  number: Zt,
  date: nx,
  string: ix,
  unknown: an
}, Gd = [i7, s7, lT, r7], o7 = ["boolean", "integer", "number", "date"];
function uT(e, t) {
  if (!e || !e.length)
    return "unknown";
  const n = e.length, i = Gd.length, r = Gd.map((s, o) => o + 1);
  for (let s = 0, o = 0, a, l; s < n; ++s)
    for (l = t ? e[s][t] : e[s], a = 0; a < i; ++a)
      if (r[a] && n7(l) && !Gd[a](l) && (r[a] = 0, ++o, o === Gd.length))
        return "string";
  return o7[r.reduce((s, o) => s === 0 ? o : s, 0) - 1];
}
function cT(e, t) {
  return t.reduce((n, i) => (n[i] = uT(e, i), n), {});
}
function hk(e) {
  const t = function(n, i) {
    const r = {
      delimiter: e
    };
    return hx(n, i ? we(i, r) : r);
  };
  return t.responseType = "text", t;
}
function hx(e, t) {
  return t.header && (e = t.header.map(X).join(t.delimiter) + `
` + e), BI(t.delimiter).parse(e + "");
}
hx.responseType = "text";
function a7(e) {
  return typeof Buffer == "function" && Ee(Buffer.isBuffer) ? Buffer.isBuffer(e) : !1;
}
function gx(e, t) {
  const n = t && t.property ? _i(t.property) : an;
  return ne(e) && !a7(e) ? l7(n(e), t) : n(JSON.parse(e));
}
gx.responseType = "json";
function l7(e, t) {
  return !U(e) && nF(e) && (e = [...e]), t && t.copy ? JSON.parse(JSON.stringify(e)) : e;
}
const u7 = {
  interior: (e, t) => e !== t,
  exterior: (e, t) => e === t
};
function fT(e, t) {
  let n, i, r, s;
  return e = gx(e, t), t && t.feature ? (n = WI, r = t.feature) : t && t.mesh ? (n = GI, r = t.mesh, s = u7[t.filter]) : j("Missing TopoJSON feature or mesh parameter."), i = (i = e.objects[r]) ? n(e, i, s) : j("Invalid TopoJSON object: " + r), i && i.features || [i];
}
fT.responseType = "json";
const Oh = {
  dsv: hx,
  csv: hk(","),
  tsv: hk("	"),
  json: gx,
  topojson: fT
};
function px(e, t) {
  return arguments.length > 1 ? (Oh[e] = t, this) : ce(Oh, e) ? Oh[e] : null;
}
function dT(e) {
  const t = px(e);
  return t && t.responseType || "text";
}
function hT(e, t, n, i) {
  t = t || {};
  const r = px(t.type || "json");
  return r || j("Unknown data format type: " + t.type), e = r(e, t), t.parse && c7(e, t.parse, n, i), ce(e, "columns") && delete e.columns, e;
}
function c7(e, t, n, i) {
  if (!e.length)
    return;
  const r = _f();
  n = n || r.timeParse, i = i || r.utcParse;
  let s = e.columns || Object.keys(e[0]), o, a, l, u, c, f;
  t === "auto" && (t = cT(e, s)), s = Object.keys(t);
  const d = s.map((h) => {
    const g = t[h];
    let p, m;
    if (g && (g.startsWith("date:") || g.startsWith("utc:")))
      return p = g.split(/:(.+)?/, 2), m = p[1], (m[0] === "'" && m[m.length - 1] === "'" || m[0] === '"' && m[m.length - 1] === '"') && (m = m.slice(1, -1)), (p[0] === "utc" ? i : n)(m);
    if (!By[g])
      throw Error("Illegal format pattern: " + h + ":" + g);
    return By[g];
  });
  for (l = 0, c = e.length, f = s.length; l < c; ++l)
    for (o = e[l], u = 0; u < f; ++u)
      a = s[u], o[a] = d[u](o[a]);
}
const Xp = Xz(
  typeof fetch < "u" && fetch,
  // use built-in fetch API
  null
  // no file system access
);
function Kp(e) {
  const t = e || an, n = [], i = {};
  return n.add = (r) => {
    const s = t(r);
    return i[s] || (i[s] = 1, n.push(r)), n;
  }, n.remove = (r) => {
    const s = t(r);
    if (i[s]) {
      i[s] = 0;
      const o = n.indexOf(r);
      o >= 0 && n.splice(o, 1);
    }
    return n;
  }, n;
}
async function Nh(e, t) {
  try {
    await t(e);
  } catch (n) {
    e.error(n);
  }
}
const gT = Symbol("vega_id");
let f7 = 1;
function Jp(e) {
  return !!(e && le(e));
}
function le(e) {
  return e[gT];
}
function pT(e, t) {
  return e[gT] = t, e;
}
function je(e) {
  const t = e === Object(e) ? e : {
    data: e
  };
  return le(t) ? t : pT(t, f7++);
}
function mx(e) {
  return Qp(e, je({}));
}
function Qp(e, t) {
  for (const n in e)
    t[n] = e[n];
  return t;
}
function mT(e, t) {
  return pT(t, le(e));
}
function el(e, t) {
  return e ? t ? (n, i) => e(n, i) || le(t(n)) - le(t(i)) : (n, i) => e(n, i) || le(n) - le(i) : null;
}
function yT(e) {
  return e && e.constructor === tl;
}
function tl() {
  const e = [], t = [], n = [], i = [], r = [];
  let s = null, o = !1;
  return {
    constructor: tl,
    insert(a) {
      const l = ee(a), u = l.length;
      for (let c = 0; c < u; ++c)
        e.push(l[c]);
      return this;
    },
    remove(a) {
      const l = Ee(a) ? i : t, u = ee(a), c = u.length;
      for (let f = 0; f < c; ++f)
        l.push(u[f]);
      return this;
    },
    modify(a, l, u) {
      const c = {
        field: l,
        value: ln(u)
      };
      return Ee(a) ? (c.filter = a, r.push(c)) : (c.tuple = a, n.push(c)), this;
    },
    encode(a, l) {
      return Ee(a) ? r.push({
        filter: a,
        field: l
      }) : n.push({
        tuple: a,
        field: l
      }), this;
    },
    clean(a) {
      return s = a, this;
    },
    reflow() {
      return o = !0, this;
    },
    pulse(a, l) {
      const u = {}, c = {};
      let f, d, h, g, p, m;
      for (f = 0, d = l.length; f < d; ++f)
        u[le(l[f])] = 1;
      for (f = 0, d = t.length; f < d; ++f)
        p = t[f], u[le(p)] = -1;
      for (f = 0, d = i.length; f < d; ++f)
        g = i[f], l.forEach((b) => {
          g(b) && (u[le(b)] = -1);
        });
      for (f = 0, d = e.length; f < d; ++f)
        p = e[f], m = le(p), u[m] ? u[m] = 1 : a.add.push(je(e[f]));
      for (f = 0, d = l.length; f < d; ++f)
        p = l[f], u[le(p)] < 0 && a.rem.push(p);
      function y(b, v, _) {
        _ ? b[v] = _(b) : a.encode = v, o || (c[le(b)] = b);
      }
      for (f = 0, d = n.length; f < d; ++f)
        h = n[f], p = h.tuple, g = h.field, m = u[le(p)], m > 0 && (y(p, g, h.value), a.modifies(g));
      for (f = 0, d = r.length; f < d; ++f)
        h = r[f], g = h.filter, l.forEach((b) => {
          g(b) && u[le(b)] > 0 && y(b, h.field, h.value);
        }), a.modifies(h.field);
      if (o)
        a.mod = t.length || i.length ? l.filter((b) => u[le(b)] > 0) : l.slice();
      else
        for (m in c)
          a.mod.push(c[m]);
      return (s || s == null && (t.length || i.length)) && a.clean(!0), a;
    }
  };
}
const Dh = "_:mod:_";
function Zp() {
  Object.defineProperty(this, Dh, {
    writable: !0,
    value: {}
  });
}
Zp.prototype = {
  /**
   * Set a parameter value. If the parameter value changes, the parameter
   * will be recorded as modified.
   * @param {string} name - The parameter name.
   * @param {number} index - The index into an array-value parameter. Ignored if
   *   the argument is undefined, null or less than zero.
   * @param {*} value - The parameter value to set.
   * @param {boolean} [force=false] - If true, records the parameter as modified
   *   even if the value is unchanged.
   * @return {Parameters} - This parameter object.
   */
  set(e, t, n, i) {
    const r = this, s = r[e], o = r[Dh];
    return t != null && t >= 0 ? (s[t] !== n || i) && (s[t] = n, o[t + ":" + e] = -1, o[e] = -1) : (s !== n || i) && (r[e] = n, o[e] = U(n) ? 1 + n.length : -1), r;
  },
  /**
   * Tests if one or more parameters has been modified. If invoked with no
   * arguments, returns true if any parameter value has changed. If the first
   * argument is array, returns trues if any parameter name in the array has
   * changed. Otherwise, tests if the given name and optional array index has
   * changed.
   * @param {string} name - The parameter name to test.
   * @param {number} [index=undefined] - The parameter array index to test.
   * @return {boolean} - Returns true if a queried parameter was modified.
   */
  modified(e, t) {
    const n = this[Dh];
    if (arguments.length) {
      if (U(e)) {
        for (let i = 0; i < e.length; ++i)
          if (n[e[i]])
            return !0;
        return !1;
      }
    } else {
      for (const i in n)
        if (n[i])
          return !0;
      return !1;
    }
    return t != null && t >= 0 ? t + 1 < n[e] || !!n[t + ":" + e] : !!n[e];
  },
  /**
   * Clears the modification records. After calling this method,
   * all parameters are considered unmodified.
   */
  clear() {
    return this[Dh] = {}, this;
  }
};
let d7 = 0;
const h7 = "pulse", g7 = new Zp(), p7 = 1, m7 = 2;
function Xe(e, t, n, i) {
  this.id = ++d7, this.value = e, this.stamp = -1, this.rank = -1, this.qrank = -1, this.flags = 0, t && (this._update = t), n && this.parameters(n, i);
}
function gk(e) {
  return function(t) {
    const n = this.flags;
    return arguments.length === 0 ? !!(n & e) : (this.flags = t ? n | e : n & ~e, this);
  };
}
Xe.prototype = {
  /**
   * Returns a list of target operators dependent on this operator.
   * If this list does not exist, it is created and then returned.
   * @return {UniqueList}
   */
  targets() {
    return this._targets || (this._targets = Kp(ed));
  },
  /**
   * Sets the value of this operator.
   * @param {*} value - the value to set.
   * @return {Number} Returns 1 if the operator value has changed
   *   according to strict equality, returns 0 otherwise.
   */
  set(e) {
    return this.value !== e ? (this.value = e, 1) : 0;
  },
  /**
   * Indicates that operator evaluation should be skipped on the next pulse.
   * This operator will still propagate incoming pulses, but its update function
   * will not be invoked. The skip flag is reset after every pulse, so calling
   * this method will affect processing of the next pulse only.
   */
  skip: gk(p7),
  /**
   * Indicates that this operator's value has been modified on its most recent
   * pulse. Normally modification is checked via strict equality; however, in
   * some cases it is more efficient to update the internal state of an object.
   * In those cases, the modified flag can be used to trigger propagation. Once
   * set, the modification flag persists across pulses until unset. The flag can
   * be used with the last timestamp to test if a modification is recent.
   */
  modified: gk(m7),
  /**
   * Sets the parameters for this operator. The parameter values are analyzed for
   * operator instances. If found, this operator will be added as a dependency
   * of the parameterizing operator. Operator values are dynamically marshalled
   * from each operator parameter prior to evaluation. If a parameter value is
   * an array, the array will also be searched for Operator instances. However,
   * the search does not recurse into sub-arrays or object properties.
   * @param {object} params - A hash of operator parameters.
   * @param {boolean} [react=true] - A flag indicating if this operator should
   *   automatically update (react) when parameter values change. In other words,
   *   this flag determines if the operator registers itself as a listener on
   *   any upstream operators included in the parameters.
   * @param {boolean} [initonly=false] - A flag indicating if this operator
   *   should calculate an update only upon its initial evaluation, then
   *   deregister dependencies and suppress all future update invocations.
   * @return {Operator[]} - An array of upstream dependencies.
   */
  parameters(e, t, n) {
    t = t !== !1;
    const i = this._argval = this._argval || new Zp(), r = this._argops = this._argops || [], s = [];
    let o, a, l, u;
    const c = (f, d, h) => {
      h instanceof Xe ? (h !== this && (t && h.targets().add(this), s.push(h)), r.push({
        op: h,
        name: f,
        index: d
      })) : i.set(f, d, h);
    };
    for (o in e)
      if (a = e[o], o === h7)
        ee(a).forEach((f) => {
          f instanceof Xe ? f !== this && (f.targets().add(this), s.push(f)) : j("Pulse parameters must be operator instances.");
        }), this.source = a;
      else if (U(a))
        for (i.set(o, -1, Array(l = a.length)), u = 0; u < l; ++u)
          c(o, u, a[u]);
      else
        c(o, -1, a);
    return this.marshall().clear(), n && (r.initonly = !0), s;
  },
  /**
   * Internal method for marshalling parameter values.
   * Visits each operator dependency to pull the latest value.
   * @return {Parameters} A Parameters object to pass to the update function.
   */
  marshall(e) {
    const t = this._argval || g7, n = this._argops;
    let i, r, s, o;
    if (n) {
      const a = n.length;
      for (r = 0; r < a; ++r)
        i = n[r], s = i.op, o = s.modified() && s.stamp === e, t.set(i.name, i.index, s.value, o);
      if (n.initonly) {
        for (r = 0; r < a; ++r)
          i = n[r], i.op.targets().remove(this);
        this._argops = null, this._update = null;
      }
    }
    return t;
  },
  /**
   * Detach this operator from the dataflow.
   * Unregisters listeners on upstream dependencies.
   */
  detach() {
    const e = this._argops;
    let t, n, i, r;
    if (e)
      for (t = 0, n = e.length; t < n; ++t)
        i = e[t], r = i.op, r._targets && r._targets.remove(this);
    this.pulse = null, this.source = null;
  },
  /**
   * Delegate method to perform operator processing.
   * Subclasses can override this method to perform custom processing.
   * By default, it marshalls parameters and calls the update function
   * if that function is defined. If the update function does not
   * change the operator value then StopPropagation is returned.
   * If no update function is defined, this method does nothing.
   * @param {Pulse} pulse - the current dataflow pulse.
   * @return The output pulse or StopPropagation. A falsy return value
   *   (including undefined) will let the input pulse pass through.
   */
  evaluate(e) {
    const t = this._update;
    if (t) {
      const n = this.marshall(e.stamp), i = t.call(this, n, e);
      if (n.clear(), i !== this.value)
        this.value = i;
      else if (!this.modified())
        return e.StopPropagation;
    }
  },
  /**
   * Run this operator for the current pulse. If this operator has already
   * been run at (or after) the pulse timestamp, returns StopPropagation.
   * Internally, this method calls {@link evaluate} to perform processing.
   * If {@link evaluate} returns a falsy value, the input pulse is returned.
   * This method should NOT be overridden, instead overrride {@link evaluate}.
   * @param {Pulse} pulse - the current dataflow pulse.
   * @return the output pulse for this operator (or StopPropagation)
   */
  run(e) {
    if (e.stamp < this.stamp)
      return e.StopPropagation;
    let t;
    return this.skip() ? (this.skip(!1), t = 0) : t = this.evaluate(e), this.pulse = t || e;
  }
};
function y7(e, t, n, i) {
  let r = 1, s;
  return e instanceof Xe ? s = e : e && e.prototype instanceof Xe ? s = new e() : Ee(e) ? s = new Xe(null, e) : (r = 0, s = new Xe(e, t)), this.rank(s), r && (i = n, n = t), n && this.connect(s, s.parameters(n, i)), this.touch(s), s;
}
function b7(e, t) {
  const n = e.rank, i = t.length;
  for (let r = 0; r < i; ++r)
    if (n < t[r].rank) {
      this.rerank(e);
      return;
    }
}
let v7 = 0;
function em(e, t, n) {
  this.id = ++v7, this.value = null, n && (this.receive = n), e && (this._filter = e), t && (this._apply = t);
}
function Us(e, t, n) {
  return new em(e, t, n);
}
em.prototype = {
  _filter: Ei,
  _apply: an,
  targets() {
    return this._targets || (this._targets = Kp(ed));
  },
  consume(e) {
    return arguments.length ? (this._consume = !!e, this) : !!this._consume;
  },
  receive(e) {
    if (this._filter(e)) {
      const t = this.value = this._apply(e), n = this._targets, i = n ? n.length : 0;
      for (let r = 0; r < i; ++r)
        n[r].receive(t);
      this._consume && (e.preventDefault(), e.stopPropagation());
    }
  },
  filter(e) {
    const t = Us(e);
    return this.targets().add(t), t;
  },
  apply(e) {
    const t = Us(null, e);
    return this.targets().add(t), t;
  },
  merge() {
    const e = Us();
    this.targets().add(e);
    for (let t = 0, n = arguments.length; t < n; ++t)
      arguments[t].targets().add(e);
    return e;
  },
  throttle(e) {
    let t = -1;
    return this.filter(() => {
      const n = Date.now();
      return n - t > e ? (t = n, 1) : 0;
    });
  },
  debounce(e) {
    const t = Us();
    return this.targets().add(Us(null, null, Zv(e, (n) => {
      const i = n.dataflow;
      t.receive(n), i && i.run && i.run();
    }))), t;
  },
  between(e, t) {
    let n = !1;
    return e.targets().add(Us(null, null, () => n = !0)), t.targets().add(Us(null, null, () => n = !1)), this.filter(() => n);
  },
  detach() {
    this._filter = Ei, this._targets = null;
  }
};
function x7(e, t, n, i) {
  const r = this, s = Us(n, i), o = function(u) {
    u.dataflow = r;
    try {
      s.receive(u);
    } catch (c) {
      r.error(c);
    } finally {
      r.run();
    }
  };
  let a;
  typeof e == "string" && typeof document < "u" ? a = document.querySelectorAll(e) : a = ee(e);
  const l = a.length;
  for (let u = 0; u < l; ++u)
    a[u].addEventListener(t, o);
  return s;
}
function w7(e, t) {
  const n = this.locale();
  return hT(e, t, n.timeParse, n.utcParse);
}
function _7(e, t, n) {
  return t = this.parse(t, n), this.pulse(e, this.changeset().insert(t));
}
async function E7(e, t) {
  const n = this;
  let i = 0, r;
  try {
    r = await n.loader().load(e, {
      context: "dataflow",
      response: dT(t && t.type)
    });
    try {
      r = n.parse(r, t);
    } catch (s) {
      i = -2, n.warn("Data ingestion failed", e, s);
    }
  } catch (s) {
    i = -1, n.warn("Loading failed", e, s);
  }
  return {
    data: r,
    status: i
  };
}
async function S7(e, t, n) {
  const i = this, r = i._pending || k7(i);
  r.requests += 1;
  const s = await i.request(t, n);
  return i.pulse(e, i.changeset().remove(Ei).insert(s.data || [])), r.done(), s;
}
function k7(e) {
  let t;
  const n = new Promise((i) => t = i);
  return n.requests = 0, n.done = () => {
    --n.requests === 0 && (e._pending = null, t(e));
  }, e._pending = n;
}
const A7 = {
  skip: !0
};
function C7(e, t, n, i, r) {
  return (e instanceof Xe ? M7 : $7)(this, e, t, n, i, r), this;
}
function $7(e, t, n, i, r, s) {
  const o = we({}, s, A7);
  let a, l;
  Ee(n) || (n = ln(n)), i === void 0 ? a = (u) => e.touch(n(u)) : Ee(i) ? (l = new Xe(null, i, r, !1), a = (u) => {
    l.evaluate(u);
    const c = n(u), f = l.value;
    yT(f) ? e.pulse(c, f, s) : e.update(c, f, o);
  }) : a = (u) => e.update(n(u), i, o), t.apply(a);
}
function M7(e, t, n, i, r, s) {
  if (i === void 0)
    t.targets().add(n);
  else {
    const o = s || {}, a = new Xe(null, F7(n, i), r, !1);
    a.modified(o.force), a.rank = t.rank, t.targets().add(a), n && (a.skip(!0), a.value = n.value, a.targets().add(n), e.connect(n, [a]));
  }
}
function F7(e, t) {
  return t = Ee(t) ? t : ln(t), e ? function(n, i) {
    const r = t(n, i);
    return e.skip() || (e.skip(r !== this.value).value = r), r;
  } : t;
}
function T7(e) {
  e.rank = ++this._rank;
}
function O7(e) {
  const t = [e];
  let n, i, r;
  for (; t.length; )
    if (this.rank(n = t.pop()), i = n._targets)
      for (r = i.length; --r >= 0; )
        t.push(n = i[r]), n === e && j("Cycle detected in dataflow graph.");
}
const hg = {}, gr = 1, Hs = 2, es = 4, N7 = gr | Hs, pk = gr | es, yl = gr | Hs | es, mk = 8, cc = 16, yk = 32, bk = 64;
function ao(e, t, n) {
  this.dataflow = e, this.stamp = t ?? -1, this.add = [], this.rem = [], this.mod = [], this.fields = null, this.encode = n || null;
}
function i1(e, t) {
  const n = [];
  return Ws(e, t, (i) => n.push(i)), n;
}
function vk(e, t) {
  const n = {};
  return e.visit(t, (i) => {
    n[le(i)] = 1;
  }), (i) => n[le(i)] ? null : i;
}
function Vd(e, t) {
  return e ? (n, i) => e(n, i) && t(n, i) : t;
}
ao.prototype = {
  /**
   * Sentinel value indicating pulse propagation should stop.
   */
  StopPropagation: hg,
  /**
   * Boolean flag indicating ADD (added) tuples.
   */
  ADD: gr,
  /**
   * Boolean flag indicating REM (removed) tuples.
   */
  REM: Hs,
  /**
   * Boolean flag indicating MOD (modified) tuples.
   */
  MOD: es,
  /**
   * Boolean flag indicating ADD (added) and REM (removed) tuples.
   */
  ADD_REM: N7,
  /**
   * Boolean flag indicating ADD (added) and MOD (modified) tuples.
   */
  ADD_MOD: pk,
  /**
   * Boolean flag indicating ADD, REM and MOD tuples.
   */
  ALL: yl,
  /**
   * Boolean flag indicating all tuples in a data source
   * except for the ADD, REM and MOD tuples.
   */
  REFLOW: mk,
  /**
   * Boolean flag indicating a 'pass-through' to a
   * backing data source, ignoring ADD, REM and MOD tuples.
   */
  SOURCE: cc,
  /**
   * Boolean flag indicating that source data should be
   * suppressed when creating a forked pulse.
   */
  NO_SOURCE: yk,
  /**
   * Boolean flag indicating that field modifications should be
   * suppressed when creating a forked pulse.
   */
  NO_FIELDS: bk,
  /**
   * Creates a new pulse based on the values of this pulse.
   * The dataflow, time stamp and field modification values are copied over.
   * By default, new empty ADD, REM and MOD arrays are created.
   * @param {number} flags - Integer of boolean flags indicating which (if any)
   *   tuple arrays should be copied to the new pulse. The supported flag values
   *   are ADD, REM and MOD. Array references are copied directly: new array
   *   instances are not created.
   * @return {Pulse} - The forked pulse instance.
   * @see init
   */
  fork(e) {
    return new ao(this.dataflow).init(this, e);
  },
  /**
   * Creates a copy of this pulse with new materialized array
   * instances for the ADD, REM, MOD, and SOURCE arrays.
   * The dataflow, time stamp and field modification values are copied over.
   * @return {Pulse} - The cloned pulse instance.
   * @see init
   */
  clone() {
    const e = this.fork(yl);
    return e.add = e.add.slice(), e.rem = e.rem.slice(), e.mod = e.mod.slice(), e.source && (e.source = e.source.slice()), e.materialize(yl | cc);
  },
  /**
   * Returns a pulse that adds all tuples from a backing source. This is
   * useful for cases where operators are added to a dataflow after an
   * upstream data pipeline has already been processed, ensuring that
   * new operators can observe all tuples within a stream.
   * @return {Pulse} - A pulse instance with all source tuples included
   *   in the add array. If the current pulse already has all source
   *   tuples in its add array, it is returned directly. If the current
   *   pulse does not have a backing source, it is returned directly.
   */
  addAll() {
    let e = this;
    return !e.source || e.add === e.rem || !e.rem.length && e.source.length === e.add.length || (e = new ao(this.dataflow).init(this), e.add = e.source, e.rem = []), e;
  },
  /**
   * Initialize this pulse based on the values of another pulse. This method
   * is used internally by {@link fork} to initialize a new forked tuple.
   * The dataflow, time stamp and field modification values are copied over.
   * By default, new empty ADD, REM and MOD arrays are created.
   * @param {Pulse} src - The source pulse to copy from.
   * @param {number} flags - Integer of boolean flags indicating which (if any)
   *   tuple arrays should be copied to the new pulse. The supported flag values
   *   are ADD, REM and MOD. Array references are copied directly: new array
   *   instances are not created. By default, source data arrays are copied
   *   to the new pulse. Use the NO_SOURCE flag to enforce a null source.
   * @return {Pulse} - Returns this Pulse instance.
   */
  init(e, t) {
    const n = this;
    return n.stamp = e.stamp, n.encode = e.encode, e.fields && !(t & bk) && (n.fields = e.fields), t & gr ? (n.addF = e.addF, n.add = e.add) : (n.addF = null, n.add = []), t & Hs ? (n.remF = e.remF, n.rem = e.rem) : (n.remF = null, n.rem = []), t & es ? (n.modF = e.modF, n.mod = e.mod) : (n.modF = null, n.mod = []), t & yk ? (n.srcF = null, n.source = null) : (n.srcF = e.srcF, n.source = e.source, e.cleans && (n.cleans = e.cleans)), n;
  },
  /**
   * Schedules a function to run after pulse propagation completes.
   * @param {function} func - The function to run.
   */
  runAfter(e) {
    this.dataflow.runAfter(e);
  },
  /**
   * Indicates if tuples have been added, removed or modified.
   * @param {number} [flags] - The tuple types (ADD, REM or MOD) to query.
   *   Defaults to ALL, returning true if any tuple type has changed.
   * @return {boolean} - Returns true if one or more queried tuple types have
   *   changed, false otherwise.
   */
  changed(e) {
    const t = e || yl;
    return t & gr && this.add.length || t & Hs && this.rem.length || t & es && this.mod.length;
  },
  /**
   * Forces a "reflow" of tuple values, such that all tuples in the backing
   * source are added to the MOD set, unless already present in the ADD set.
   * @param {boolean} [fork=false] - If true, returns a forked copy of this
   *   pulse, and invokes reflow on that derived pulse.
   * @return {Pulse} - The reflowed pulse instance.
   */
  reflow(e) {
    if (e)
      return this.fork(yl).reflow();
    const t = this.add.length, n = this.source && this.source.length;
    return n && n !== t && (this.mod = this.source, t && this.filter(es, vk(this, gr))), this;
  },
  /**
   * Get/set metadata to pulse requesting garbage collection
   * to reclaim currently unused resources.
   */
  clean(e) {
    return arguments.length ? (this.cleans = !!e, this) : this.cleans;
  },
  /**
   * Marks one or more data field names as modified to assist dependency
   * tracking and incremental processing by transform operators.
   * @param {string|Array<string>} _ - The field(s) to mark as modified.
   * @return {Pulse} - This pulse instance.
   */
  modifies(e) {
    const t = this.fields || (this.fields = {});
    return U(e) ? e.forEach((n) => t[n] = !0) : t[e] = !0, this;
  },
  /**
   * Checks if one or more data fields have been modified during this pulse
   * propagation timestamp.
   * @param {string|Array<string>} _ - The field(s) to check for modified.
   * @param {boolean} nomod - If true, will check the modified flag even if
   *   no mod tuples exist. If false (default), mod tuples must be present.
   * @return {boolean} - Returns true if any of the provided fields has been
   *   marked as modified, false otherwise.
   */
  modified(e, t) {
    const n = this.fields;
    return (t || this.mod.length) && n ? arguments.length ? U(e) ? e.some((i) => n[i]) : n[e] : !!n : !1;
  },
  /**
   * Adds a filter function to one more tuple sets. Filters are applied to
   * backing tuple arrays, to determine the actual set of tuples considered
   * added, removed or modified. They can be used to delay materialization of
   * a tuple set in order to avoid expensive array copies. In addition, the
   * filter functions can serve as value transformers: unlike standard predicate
   * function (which return boolean values), Pulse filters should return the
   * actual tuple value to process. If a tuple set is already filtered, the
   * new filter function will be appended into a conjuntive ('and') query.
   * @param {number} flags - Flags indicating the tuple set(s) to filter.
   * @param {function(*):object} filter - Filter function that will be applied
   *   to the tuple set array, and should return a data tuple if the value
   *   should be included in the tuple set, and falsy (or null) otherwise.
   * @return {Pulse} - Returns this pulse instance.
   */
  filter(e, t) {
    const n = this;
    return e & gr && (n.addF = Vd(n.addF, t)), e & Hs && (n.remF = Vd(n.remF, t)), e & es && (n.modF = Vd(n.modF, t)), e & cc && (n.srcF = Vd(n.srcF, t)), n;
  },
  /**
   * Materialize one or more tuple sets in this pulse. If the tuple set(s) have
   * a registered filter function, it will be applied and the tuple set(s) will
   * be replaced with materialized tuple arrays.
   * @param {number} flags - Flags indicating the tuple set(s) to materialize.
   * @return {Pulse} - Returns this pulse instance.
   */
  materialize(e) {
    e = e || yl;
    const t = this;
    return e & gr && t.addF && (t.add = i1(t.add, t.addF), t.addF = null), e & Hs && t.remF && (t.rem = i1(t.rem, t.remF), t.remF = null), e & es && t.modF && (t.mod = i1(t.mod, t.modF), t.modF = null), e & cc && t.srcF && (t.source = t.source.filter(t.srcF), t.srcF = null), t;
  },
  /**
   * Visit one or more tuple sets in this pulse.
   * @param {number} flags - Flags indicating the tuple set(s) to visit.
   *   Legal values are ADD, REM, MOD and SOURCE (if a backing data source
   *   has been set).
   * @param {function(object):*} - Visitor function invoked per-tuple.
   * @return {Pulse} - Returns this pulse instance.
   */
  visit(e, t) {
    const n = this, i = t;
    if (e & cc)
      return Ws(n.source, n.srcF, i), n;
    e & gr && Ws(n.add, n.addF, i), e & Hs && Ws(n.rem, n.remF, i), e & es && Ws(n.mod, n.modF, i);
    const r = n.source;
    if (e & mk && r) {
      const s = n.add.length + n.mod.length;
      s === r.length || (s ? Ws(r, vk(n, pk), i) : Ws(r, n.srcF, i));
    }
    return n;
  }
};
function yx(e, t, n, i) {
  const r = this;
  let s = 0;
  this.dataflow = e, this.stamp = t, this.fields = null, this.encode = i || null, this.pulses = n;
  for (const o of n)
    if (o.stamp === t) {
      if (o.fields) {
        const a = r.fields || (r.fields = {});
        for (const l in o.fields)
          a[l] = 1;
      }
      o.changed(r.ADD) && (s |= r.ADD), o.changed(r.REM) && (s |= r.REM), o.changed(r.MOD) && (s |= r.MOD);
    }
  this.changes = s;
}
Y(yx, ao, {
  /**
   * Creates a new pulse based on the values of this pulse.
   * The dataflow, time stamp and field modification values are copied over.
   * @return {Pulse}
   */
  fork(e) {
    const t = new ao(this.dataflow).init(this, e & this.NO_FIELDS);
    return e !== void 0 && (e & t.ADD && this.visit(t.ADD, (n) => t.add.push(n)), e & t.REM && this.visit(t.REM, (n) => t.rem.push(n)), e & t.MOD && this.visit(t.MOD, (n) => t.mod.push(n))), t;
  },
  changed(e) {
    return this.changes & e;
  },
  modified(e) {
    const t = this, n = t.fields;
    return n && t.changes & t.MOD ? U(e) ? e.some((i) => n[i]) : n[e] : 0;
  },
  filter() {
    j("MultiPulse does not support filtering.");
  },
  materialize() {
    j("MultiPulse does not support materialization.");
  },
  visit(e, t) {
    const n = this, i = n.pulses, r = i.length;
    let s = 0;
    if (e & n.SOURCE)
      for (; s < r; ++s)
        i[s].visit(e, t);
    else
      for (; s < r; ++s)
        i[s].stamp === n.stamp && i[s].visit(e, t);
    return n;
  }
});
async function D7(e, t, n) {
  const i = this, r = [];
  if (i._pulse)
    return bT(i);
  if (i._pending && await i._pending, t && await Nh(i, t), !i._touched.length)
    return i.debug("Dataflow invoked, but nothing to do."), i;
  const s = ++i._clock;
  i._pulse = new ao(i, s, e), i._touched.forEach((c) => i._enqueue(c, !0)), i._touched = Kp(ed);
  let o = 0, a, l, u;
  try {
    for (; i._heap.size() > 0; ) {
      if (a = i._heap.pop(), a.rank !== a.qrank) {
        i._enqueue(a, !0);
        continue;
      }
      l = a.run(i._getPulse(a, e)), l.then ? l = await l : l.async && (r.push(l.async), l = hg), l !== hg && a._targets && a._targets.forEach((c) => i._enqueue(c)), ++o;
    }
  } catch (c) {
    i._heap.clear(), u = c;
  }
  if (i._input = {}, i._pulse = null, i.debug(`Pulse ${s}: ${o} operators`), u && (i._postrun = [], i.error(u)), i._postrun.length) {
    const c = i._postrun.sort((f, d) => d.priority - f.priority);
    i._postrun = [];
    for (let f = 0; f < c.length; ++f)
      await Nh(i, c[f].callback);
  }
  return n && await Nh(i, n), r.length && Promise.all(r).then((c) => i.runAsync(null, () => {
    c.forEach((f) => {
      try {
        f(i);
      } catch (d) {
        i.error(d);
      }
    });
  })), i;
}
async function R7(e, t, n) {
  for (; this._running; )
    await this._running;
  const i = () => this._running = null;
  return (this._running = this.evaluate(e, t, n)).then(i, i), this._running;
}
function L7(e, t, n) {
  return this._pulse ? bT(this) : (this.evaluate(e, t, n), this);
}
function P7(e, t, n) {
  if (this._pulse || t)
    this._postrun.push({
      priority: n || 0,
      callback: e
    });
  else
    try {
      e(this);
    } catch (i) {
      this.error(i);
    }
}
function bT(e) {
  return e.error("Dataflow already running. Use runAsync() to chain invocations."), e;
}
function I7(e, t) {
  const n = e.stamp < this._clock;
  n && (e.stamp = this._clock), (n || t) && (e.qrank = e.rank, this._heap.push(e));
}
function z7(e, t) {
  const n = e.source, i = this._clock;
  return n && U(n) ? new yx(this, i, n.map((r) => r.pulse), t) : this._input[e.id] || B7(this._pulse, n && n.pulse);
}
function B7(e, t) {
  return t && t.stamp === e.stamp ? t : (e = e.fork(), t && t !== hg && (e.source = t.source), e);
}
const bx = {
  skip: !1,
  force: !1
};
function j7(e, t) {
  const n = t || bx;
  return this._pulse ? this._enqueue(e) : this._touched.add(e), n.skip && e.skip(!0), this;
}
function U7(e, t, n) {
  const i = n || bx;
  return (e.set(t) || i.force) && this.touch(e, i), this;
}
function q7(e, t, n) {
  this.touch(e, n || bx);
  const i = new ao(this, this._clock + (this._pulse ? 0 : 1)), r = e.pulse && e.pulse.source || [];
  return i.target = e, this._input[e.id] = t.pulse(i, r), this;
}
function W7(e) {
  let t = [];
  return {
    clear: () => t = [],
    size: () => t.length,
    peek: () => t[0],
    push: (n) => (t.push(n), vT(t, 0, t.length - 1, e)),
    pop: () => {
      const n = t.pop();
      let i;
      return t.length ? (i = t[0], t[0] = n, H7(t, 0, e)) : i = n, i;
    }
  };
}
function vT(e, t, n, i) {
  let r, s;
  const o = e[n];
  for (; n > t; ) {
    if (s = n - 1 >> 1, r = e[s], i(o, r) < 0) {
      e[n] = r, n = s;
      continue;
    }
    break;
  }
  return e[n] = o;
}
function H7(e, t, n) {
  const i = t, r = e.length, s = e[t];
  let o = (t << 1) + 1, a;
  for (; o < r; )
    a = o + 1, a < r && n(e[o], e[a]) >= 0 && (o = a), e[t] = e[o], t = o, o = (t << 1) + 1;
  return e[t] = s, vT(e, i, t, n);
}
function jl() {
  this.logger(Yv()), this.logLevel(Gv), this._clock = 0, this._rank = 0, this._locale = dx();
  try {
    this._loader = Xp();
  } catch {
  }
  this._touched = Kp(ed), this._input = {}, this._pulse = null, this._heap = W7((e, t) => e.qrank - t.qrank), this._postrun = [];
}
function fc(e) {
  return function() {
    return this._log[e].apply(this, arguments);
  };
}
jl.prototype = {
  /**
   * The current timestamp of this dataflow. This value reflects the
   * timestamp of the previous dataflow run. The dataflow is initialized
   * with a stamp value of 0. The initial run of the dataflow will have
   * a timestap of 1, and so on. This value will match the
   * {@link Pulse.stamp} property.
   * @return {number} - The current timestamp value.
   */
  stamp() {
    return this._clock;
  },
  /**
   * Gets or sets the loader instance to use for data file loading. A
   * loader object must provide a "load" method for loading files and a
   * "sanitize" method for checking URL/filename validity. Both methods
   * should accept a URI and options hash as arguments, and return a Promise
   * that resolves to the loaded file contents (load) or a hash containing
   * sanitized URI data with the sanitized url assigned to the "href" property
   * (sanitize).
   * @param {object} _ - The loader instance to use.
   * @return {object|Dataflow} - If no arguments are provided, returns
   *   the current loader instance. Otherwise returns this Dataflow instance.
   */
  loader(e) {
    return arguments.length ? (this._loader = e, this) : this._loader;
  },
  /**
   * Gets or sets the locale instance to use for formatting and parsing
   * string values. The locale object should be provided by the
   * vega-format library, and include methods such as format, timeFormat,
   * utcFormat, timeParse, and utcParse.
   * @param {object} _ - The locale instance to use.
   * @return {object|Dataflow} - If no arguments are provided, returns
   *   the current locale instance. Otherwise returns this Dataflow instance.
   */
  locale(e) {
    return arguments.length ? (this._locale = e, this) : this._locale;
  },
  /**
   * Get or set the logger instance used to log messages. If no arguments are
   * provided, returns the current logger instance. Otherwise, sets the logger
   * and return this Dataflow instance. Provided loggers must support the full
   * API of logger objects generated by the vega-util logger method. Note that
   * by default the log level of the new logger will be used; use the logLevel
   * method to adjust the log level as needed.
   */
  logger(e) {
    return arguments.length ? (this._log = e, this) : this._log;
  },
  /**
   * Logs an error message. By default, logged messages are written to console
   * output. The message will only be logged if the current log level is high
   * enough to permit error messages.
   */
  error: fc("error"),
  /**
   * Logs a warning message. By default, logged messages are written to console
   * output. The message will only be logged if the current log level is high
   * enough to permit warning messages.
   */
  warn: fc("warn"),
  /**
   * Logs a information message. By default, logged messages are written to
   * console output. The message will only be logged if the current log level is
   * high enough to permit information messages.
   */
  info: fc("info"),
  /**
   * Logs a debug message. By default, logged messages are written to console
   * output. The message will only be logged if the current log level is high
   * enough to permit debug messages.
   */
  debug: fc("debug"),
  /**
   * Get or set the current log level. If an argument is provided, it
   * will be used as the new log level.
   * @param {number} [level] - Should be one of None, Warn, Info
   * @return {number} - The current log level.
   */
  logLevel: fc("level"),
  /**
   * Empty entry threshold for garbage cleaning. Map data structures will
   * perform cleaning once the number of empty entries exceeds this value.
   */
  cleanThreshold: 1e4,
  // OPERATOR REGISTRATION
  add: y7,
  connect: b7,
  rank: T7,
  rerank: O7,
  // OPERATOR UPDATES
  pulse: q7,
  touch: j7,
  update: U7,
  changeset: tl,
  // DATA LOADING
  ingest: _7,
  parse: w7,
  preload: S7,
  request: E7,
  // EVENT HANDLING
  events: x7,
  on: C7,
  // PULSE PROPAGATION
  evaluate: D7,
  run: L7,
  runAsync: R7,
  runAfter: P7,
  _enqueue: I7,
  _getPulse: z7
};
function I(e, t) {
  Xe.call(this, e, null, t);
}
Y(I, Xe, {
  /**
   * Overrides {@link Operator.evaluate} for transform operators.
   * Internally, this method calls {@link evaluate} to perform processing.
   * If {@link evaluate} returns a falsy value, the input pulse is returned.
   * This method should NOT be overridden, instead overrride {@link evaluate}.
   * @param {Pulse} pulse - the current dataflow pulse.
   * @return the output pulse for this operator (or StopPropagation)
   */
  run(e) {
    if (e.stamp < this.stamp)
      return e.StopPropagation;
    let t;
    return this.skip() ? this.skip(!1) : t = this.evaluate(e), t = t || e, t.then ? t = t.then((n) => this.pulse = n) : t !== e.StopPropagation && (this.pulse = t), t;
  },
  /**
   * Overrides {@link Operator.evaluate} for transform operators.
   * Marshalls parameter values and then invokes {@link transform}.
   * @param {Pulse} pulse - the current dataflow pulse.
   * @return {Pulse} The output pulse (or StopPropagation). A falsy return
       value (including undefined) will let the input pulse pass through.
  */
  evaluate(e) {
    const t = this.marshall(e.stamp), n = this.transform(t, e);
    return t.clear(), n;
  },
  /**
   * Process incoming pulses.
   * Subclasses should override this method to implement transforms.
   * @param {Parameters} _ - The operator parameter values.
   * @param {Pulse} pulse - The current dataflow pulse.
   * @return {Pulse} The output pulse (or StopPropagation). A falsy return
   *   value (including undefined) will let the input pulse pass through.
   */
  transform() {
  }
});
const ru = {};
function xT(e) {
  const t = wT(e);
  return t && t.Definition || null;
}
function wT(e) {
  return e = e && e.toLowerCase(), ce(ru, e) ? ru[e] : null;
}
function* _T(e, t) {
  if (t == null)
    for (let n of e)
      n != null && n !== "" && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let i of e)
      i = t(i, ++n, e), i != null && i !== "" && (i = +i) >= i && (yield i);
  }
}
function vx(e, t, n) {
  const i = Float64Array.from(_T(e, n));
  return i.sort(hs), t.map((r) => bF(i, r));
}
function xx(e, t) {
  return vx(e, [0.25, 0.5, 0.75], t);
}
function wx(e, t) {
  const n = e.length, i = e9(e, t), r = xx(e, t), s = (r[2] - r[0]) / 1.34;
  return 1.06 * (Math.min(i, s) || i || Math.abs(r[0]) || 1) * Math.pow(n, -0.2);
}
function ET(e) {
  const t = e.maxbins || 20, n = e.base || 10, i = Math.log(n), r = e.divide || [5, 2];
  let s = e.extent[0], o = e.extent[1], a, l, u, c, f, d;
  const h = e.span || o - s || Math.abs(s) || 1;
  if (e.step)
    a = e.step;
  else if (e.steps) {
    for (c = h / t, f = 0, d = e.steps.length; f < d && e.steps[f] < c; ++f)
      ;
    a = e.steps[Math.max(0, f - 1)];
  } else {
    for (l = Math.ceil(Math.log(t) / i), u = e.minstep || 0, a = Math.max(u, Math.pow(n, Math.round(Math.log(h) / i) - l)); Math.ceil(h / a) > t; )
      a *= n;
    for (f = 0, d = r.length; f < d; ++f)
      c = a / r[f], c >= u && h / c <= t && (a = c);
  }
  c = Math.log(a);
  const g = c >= 0 ? 0 : ~~(-c / i) + 1, p = Math.pow(n, -g - 1);
  return (e.nice || e.nice === void 0) && (c = Math.floor(s / a + p) * a, s = s < c ? c - a : c, o = Math.ceil(o / a) * a), {
    start: s,
    stop: o === s ? s + a : o,
    step: a
  };
}
var ki = Math.random;
function G7(e) {
  ki = e;
}
function ST(e, t, n, i) {
  if (!e.length)
    return [void 0, void 0];
  const r = Float64Array.from(_T(e, i)), s = r.length, o = t;
  let a, l, u, c;
  for (u = 0, c = Array(o); u < o; ++u) {
    for (a = 0, l = 0; l < s; ++l)
      a += r[~~(ki() * s)];
    c[u] = a / s;
  }
  return c.sort(hs), [Ty(c, n / 2), Ty(c, 1 - n / 2)];
}
function kT(e, t, n, i) {
  i = i || ((d) => d);
  const r = e.length, s = new Float64Array(r);
  let o = 0, a = 1, l = i(e[0]), u = l, c = l + t, f;
  for (; a < r; ++a) {
    if (f = i(e[a]), f >= c) {
      for (u = (l + u) / 2; o < a; ++o)
        s[o] = u;
      c = f + t, l = f;
    }
    u = f;
  }
  for (u = (l + u) / 2; o < a; ++o)
    s[o] = u;
  return n ? V7(s, t + t / 4) : s;
}
function V7(e, t) {
  const n = e.length;
  let i = 0, r = 1, s, o;
  for (; e[i] === e[r]; )
    ++r;
  for (; r < n; ) {
    for (s = r + 1; e[r] === e[s]; )
      ++s;
    if (e[r] - e[r - 1] < t) {
      for (o = r + (i + s - r - r >> 1); o < r; )
        e[o++] = e[r];
      for (; o > r; )
        e[o--] = e[i];
    }
    i = r, r = s;
  }
  return e;
}
function Y7(e) {
  return function() {
    return e = (1103515245 * e + 12345) % 2147483647, e / 2147483647;
  };
}
function X7(e, t) {
  t == null && (t = e, e = 0);
  let n, i, r;
  const s = {
    min(o) {
      return arguments.length ? (n = o || 0, r = i - n, s) : n;
    },
    max(o) {
      return arguments.length ? (i = o || 0, r = i - n, s) : i;
    },
    sample() {
      return n + Math.floor(r * ki());
    },
    pdf(o) {
      return o === Math.floor(o) && o >= n && o < i ? 1 / r : 0;
    },
    cdf(o) {
      const a = Math.floor(o);
      return a < n ? 0 : a >= i ? 1 : (a - n + 1) / r;
    },
    icdf(o) {
      return o >= 0 && o <= 1 ? n - 1 + Math.floor(o * r) : NaN;
    }
  };
  return s.min(e).max(t);
}
const AT = Math.sqrt(2 * Math.PI), K7 = Math.SQRT2;
let dc = NaN;
function tm(e, t) {
  e = e || 0, t = t ?? 1;
  let n = 0, i = 0, r, s;
  if (dc === dc)
    n = dc, dc = NaN;
  else {
    do
      n = ki() * 2 - 1, i = ki() * 2 - 1, r = n * n + i * i;
    while (r === 0 || r > 1);
    s = Math.sqrt(-2 * Math.log(r) / r), n *= s, dc = i * s;
  }
  return e + n * t;
}
function _x(e, t, n) {
  n = n ?? 1;
  const i = (e - (t || 0)) / n;
  return Math.exp(-0.5 * i * i) / (n * AT);
}
function nm(e, t, n) {
  t = t || 0, n = n ?? 1;
  const i = (e - t) / n, r = Math.abs(i);
  let s;
  if (r > 37)
    s = 0;
  else {
    const o = Math.exp(-r * r / 2);
    let a;
    r < 7.07106781186547 ? (a = 0.0352624965998911 * r + 0.700383064443688, a = a * r + 6.37396220353165, a = a * r + 33.912866078383, a = a * r + 112.079291497871, a = a * r + 221.213596169931, a = a * r + 220.206867912376, s = o * a, a = 0.0883883476483184 * r + 1.75566716318264, a = a * r + 16.064177579207, a = a * r + 86.7807322029461, a = a * r + 296.564248779674, a = a * r + 637.333633378831, a = a * r + 793.826512519948, a = a * r + 440.413735824752, s = s / a) : (a = r + 0.65, a = r + 4 / a, a = r + 3 / a, a = r + 2 / a, a = r + 1 / a, s = o / a / 2.506628274631);
  }
  return i > 0 ? 1 - s : s;
}
function im(e, t, n) {
  return e < 0 || e > 1 ? NaN : (t || 0) + (n ?? 1) * K7 * J7(2 * e - 1);
}
function J7(e) {
  let t = -Math.log((1 - e) * (1 + e)), n;
  return t < 6.25 ? (t -= 3.125, n = -364441206401782e-35, n = -16850591381820166e-35 + n * t, n = 128584807152564e-32 + n * t, n = 11157877678025181e-33 + n * t, n = -1333171662854621e-31 + n * t, n = 20972767875968562e-33 + n * t, n = 6637638134358324e-30 + n * t, n = -4054566272975207e-29 + n * t, n = -8151934197605472e-29 + n * t, n = 26335093153082323e-28 + n * t, n = -12975133253453532e-27 + n * t, n = -5415412054294628e-26 + n * t, n = 10512122733215323e-25 + n * t, n = -4112633980346984e-24 + n * t, n = -29070369957882005e-24 + n * t, n = 42347877827932404e-23 + n * t, n = -13654692000834679e-22 + n * t, n = -13882523362786469e-21 + n * t, n = 18673420803405714e-20 + n * t, n = -740702534166267e-18 + n * t, n = -0.006033670871430149 + n * t, n = 0.24015818242558962 + n * t, n = 1.6536545626831027 + n * t) : t < 16 ? (t = Math.sqrt(t) - 3.25, n = 22137376921775787e-25, n = 9075656193888539e-23 + n * t, n = -27517406297064545e-23 + n * t, n = 18239629214389228e-24 + n * t, n = 15027403968909828e-22 + n * t, n = -4013867526981546e-21 + n * t, n = 29234449089955446e-22 + n * t, n = 12475304481671779e-21 + n * t, n = -47318229009055734e-21 + n * t, n = 6828485145957318e-20 + n * t, n = 24031110387097894e-21 + n * t, n = -3550375203628475e-19 + n * t, n = 9532893797373805e-19 + n * t, n = -0.0016882755560235047 + n * t, n = 0.002491442096107851 + n * t, n = -0.003751208507569241 + n * t, n = 0.005370914553590064 + n * t, n = 1.0052589676941592 + n * t, n = 3.0838856104922208 + n * t) : Number.isFinite(t) ? (t = Math.sqrt(t) - 5, n = -27109920616438573e-27, n = -2555641816996525e-25 + n * t, n = 15076572693500548e-25 + n * t, n = -3789465440126737e-24 + n * t, n = 761570120807834e-23 + n * t, n = -1496002662714924e-23 + n * t, n = 2914795345090108e-23 + n * t, n = -6771199775845234e-23 + n * t, n = 22900482228026655e-23 + n * t, n = -99298272942317e-20 + n * t, n = 4526062597223154e-21 + n * t, n = -1968177810553167e-20 + n * t, n = 7599527703001776e-20 + n * t, n = -21503011930044477e-20 + n * t, n = -13871931833623122e-20 + n * t, n = 1.0103004648645344 + n * t, n = 4.849906401408584 + n * t) : n = 1 / 0, n * e;
}
function Ex(e, t) {
  let n, i;
  const r = {
    mean(s) {
      return arguments.length ? (n = s || 0, r) : n;
    },
    stdev(s) {
      return arguments.length ? (i = s ?? 1, r) : i;
    },
    sample: () => tm(n, i),
    pdf: (s) => _x(s, n, i),
    cdf: (s) => nm(s, n, i),
    icdf: (s) => im(s, n, i)
  };
  return r.mean(e).stdev(t);
}
function Sx(e, t) {
  const n = Ex();
  let i = 0;
  const r = {
    data(s) {
      return arguments.length ? (e = s, i = s ? s.length : 0, r.bandwidth(t)) : e;
    },
    bandwidth(s) {
      return arguments.length ? (t = s, !t && e && (t = wx(e)), r) : t;
    },
    sample() {
      return e[~~(ki() * i)] + t * n.sample();
    },
    pdf(s) {
      let o = 0, a = 0;
      for (; a < i; ++a)
        o += n.pdf((s - e[a]) / t);
      return o / t / i;
    },
    cdf(s) {
      let o = 0, a = 0;
      for (; a < i; ++a)
        o += n.cdf((s - e[a]) / t);
      return o / i;
    },
    icdf() {
      throw Error("KDE icdf not supported.");
    }
  };
  return r.data(e);
}
function kx(e, t) {
  return e = e || 0, t = t ?? 1, Math.exp(e + tm() * t);
}
function Ax(e, t, n) {
  if (e <= 0)
    return 0;
  t = t || 0, n = n ?? 1;
  const i = (Math.log(e) - t) / n;
  return Math.exp(-0.5 * i * i) / (n * AT * e);
}
function Cx(e, t, n) {
  return nm(Math.log(e), t, n);
}
function $x(e, t, n) {
  return Math.exp(im(e, t, n));
}
function CT(e, t) {
  let n, i;
  const r = {
    mean(s) {
      return arguments.length ? (n = s || 0, r) : n;
    },
    stdev(s) {
      return arguments.length ? (i = s ?? 1, r) : i;
    },
    sample: () => kx(n, i),
    pdf: (s) => Ax(s, n, i),
    cdf: (s) => Cx(s, n, i),
    icdf: (s) => $x(s, n, i)
  };
  return r.mean(e).stdev(t);
}
function $T(e, t) {
  let n = 0, i;
  function r(o) {
    const a = [];
    let l = 0, u;
    for (u = 0; u < n; ++u)
      l += a[u] = o[u] == null ? 1 : +o[u];
    for (u = 0; u < n; ++u)
      a[u] /= l;
    return a;
  }
  const s = {
    weights(o) {
      return arguments.length ? (i = r(t = o || []), s) : t;
    },
    distributions(o) {
      return arguments.length ? (o ? (n = o.length, e = o) : (n = 0, e = []), s.weights(t)) : e;
    },
    sample() {
      const o = ki();
      let a = e[n - 1], l = i[0], u = 0;
      for (; u < n - 1; l += i[++u])
        if (o < l) {
          a = e[u];
          break;
        }
      return a.sample();
    },
    pdf(o) {
      let a = 0, l = 0;
      for (; l < n; ++l)
        a += i[l] * e[l].pdf(o);
      return a;
    },
    cdf(o) {
      let a = 0, l = 0;
      for (; l < n; ++l)
        a += i[l] * e[l].cdf(o);
      return a;
    },
    icdf() {
      throw Error("Mixture icdf not supported.");
    }
  };
  return s.distributions(e).weights(t);
}
function Mx(e, t) {
  return t == null && (t = e ?? 1, e = 0), e + (t - e) * ki();
}
function Fx(e, t, n) {
  return n == null && (n = t ?? 1, t = 0), e >= t && e <= n ? 1 / (n - t) : 0;
}
function Tx(e, t, n) {
  return n == null && (n = t ?? 1, t = 0), e < t ? 0 : e > n ? 1 : (e - t) / (n - t);
}
function Ox(e, t, n) {
  return n == null && (n = t ?? 1, t = 0), e >= 0 && e <= 1 ? t + e * (n - t) : NaN;
}
function MT(e, t) {
  let n, i;
  const r = {
    min(s) {
      return arguments.length ? (n = s || 0, r) : n;
    },
    max(s) {
      return arguments.length ? (i = s ?? 1, r) : i;
    },
    sample: () => Mx(n, i),
    pdf: (s) => Fx(s, n, i),
    cdf: (s) => Tx(s, n, i),
    icdf: (s) => Ox(s, n, i)
  };
  return t == null && (t = e ?? 1, e = 0), r.min(e).max(t);
}
function Nx(e, t, n) {
  let i = 0, r = 0;
  for (const s of e) {
    const o = n(s);
    t(s) == null || o == null || isNaN(o) || (i += (o - i) / ++r);
  }
  return {
    coef: [i],
    predict: () => i,
    rSquared: 0
  };
}
function nd(e, t, n, i) {
  const r = i - e * e, s = Math.abs(r) < 1e-24 ? 0 : (n - e * t) / r;
  return [t - s * e, s];
}
function rm(e, t, n, i) {
  e = e.filter((h) => {
    let g = t(h), p = n(h);
    return g != null && (g = +g) >= g && p != null && (p = +p) >= p;
  }), i && e.sort((h, g) => t(h) - t(g));
  const r = e.length, s = new Float64Array(r), o = new Float64Array(r);
  let a = 0, l = 0, u = 0, c, f, d;
  for (d of e)
    s[a] = c = +t(d), o[a] = f = +n(d), ++a, l += (c - l) / a, u += (f - u) / a;
  for (a = 0; a < r; ++a)
    s[a] -= l, o[a] -= u;
  return [s, o, l, u];
}
function id(e, t, n, i) {
  let r = -1, s, o;
  for (const a of e)
    s = t(a), o = n(a), s != null && (s = +s) >= s && o != null && (o = +o) >= o && i(s, o, ++r);
}
function Uu(e, t, n, i, r) {
  let s = 0, o = 0;
  return id(e, t, n, (a, l) => {
    const u = l - r(a), c = l - i;
    s += u * u, o += c * c;
  }), 1 - s / o;
}
function Dx(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0, a = 0;
  id(e, t, n, (c, f) => {
    ++a, i += (c - i) / a, r += (f - r) / a, s += (c * f - s) / a, o += (c * c - o) / a;
  });
  const l = nd(i, r, s, o), u = (c) => l[0] + l[1] * c;
  return {
    coef: l,
    predict: u,
    rSquared: Uu(e, t, n, r, u)
  };
}
function FT(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0, a = 0;
  id(e, t, n, (c, f) => {
    ++a, c = Math.log(c), i += (c - i) / a, r += (f - r) / a, s += (c * f - s) / a, o += (c * c - o) / a;
  });
  const l = nd(i, r, s, o), u = (c) => l[0] + l[1] * Math.log(c);
  return {
    coef: l,
    predict: u,
    rSquared: Uu(e, t, n, r, u)
  };
}
function TT(e, t, n) {
  const [i, r, s, o] = rm(e, t, n);
  let a = 0, l = 0, u = 0, c = 0, f = 0, d, h, g;
  id(e, t, n, (b, v) => {
    d = i[f++], h = Math.log(v), g = d * v, a += (v * h - a) / f, l += (g - l) / f, u += (g * h - u) / f, c += (d * g - c) / f;
  });
  const [p, m] = nd(l / o, a / o, u / o, c / o), y = (b) => Math.exp(p + m * (b - s));
  return {
    coef: [Math.exp(p - m * s), m],
    predict: y,
    rSquared: Uu(e, t, n, o, y)
  };
}
function OT(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0, a = 0, l = 0;
  id(e, t, n, (f, d) => {
    const h = Math.log(f), g = Math.log(d);
    ++l, i += (h - i) / l, r += (g - r) / l, s += (h * g - s) / l, o += (h * h - o) / l, a += (d - a) / l;
  });
  const u = nd(i, r, s, o), c = (f) => u[0] * Math.pow(f, u[1]);
  return u[0] = Math.exp(u[0]), {
    coef: u,
    predict: c,
    rSquared: Uu(e, t, n, a, c)
  };
}
function Rx(e, t, n) {
  const [i, r, s, o] = rm(e, t, n), a = i.length;
  let l = 0, u = 0, c = 0, f = 0, d = 0, h, g, p, m;
  for (h = 0; h < a; )
    g = i[h], p = r[h++], m = g * g, l += (m - l) / h, u += (m * g - u) / h, c += (m * m - c) / h, f += (g * p - f) / h, d += (m * p - d) / h;
  const y = c - l * l, b = l * y - u * u, v = (d * l - f * u) / b, _ = (f * y - d * u) / b, x = -v * l, S = (E) => (E = E - s, v * E * E + _ * E + x + o);
  return {
    coef: [x - _ * s + v * s * s + o, _ - 2 * v * s, v],
    predict: S,
    rSquared: Uu(e, t, n, o, S)
  };
}
function NT(e, t, n, i) {
  if (i === 0)
    return Nx(e, t, n);
  if (i === 1)
    return Dx(e, t, n);
  if (i === 2)
    return Rx(e, t, n);
  const [r, s, o, a] = rm(e, t, n), l = r.length, u = [], c = [], f = i + 1;
  let d, h, g, p, m;
  for (d = 0; d < f; ++d) {
    for (g = 0, p = 0; g < l; ++g)
      p += Math.pow(r[g], d) * s[g];
    for (u.push(p), m = new Float64Array(f), h = 0; h < f; ++h) {
      for (g = 0, p = 0; g < l; ++g)
        p += Math.pow(r[g], d + h);
      m[h] = p;
    }
    c.push(m);
  }
  c.push(u);
  const y = Z7(c), b = (v) => {
    v -= o;
    let _ = a + y[0] + y[1] * v + y[2] * v * v;
    for (d = 3; d < f; ++d)
      _ += y[d] * Math.pow(v, d);
    return _;
  };
  return {
    coef: Q7(f, y, -o, a),
    predict: b,
    rSquared: Uu(e, t, n, a, b)
  };
}
function Q7(e, t, n, i) {
  const r = Array(e);
  let s, o, a, l;
  for (s = 0; s < e; ++s)
    r[s] = 0;
  for (s = e - 1; s >= 0; --s)
    for (a = t[s], l = 1, r[s] += a, o = 1; o <= s; ++o)
      l *= (s + 1 - o) / o, r[s - o] += a * Math.pow(n, o) * l;
  return r[0] += i, r;
}
function Z7(e) {
  const t = e.length - 1, n = [];
  let i, r, s, o, a;
  for (i = 0; i < t; ++i) {
    for (o = i, r = i + 1; r < t; ++r)
      Math.abs(e[i][r]) > Math.abs(e[i][o]) && (o = r);
    for (s = i; s < t + 1; ++s)
      a = e[s][i], e[s][i] = e[s][o], e[s][o] = a;
    for (r = i + 1; r < t; ++r)
      for (s = t; s >= i; s--)
        e[s][r] -= e[s][i] * e[i][r] / e[i][i];
  }
  for (r = t - 1; r >= 0; --r) {
    for (a = 0, s = r + 1; s < t; ++s)
      a += e[s][r] * n[s];
    n[r] = (e[t][r] - a) / e[r][r];
  }
  return n;
}
const xk = 2, wk = 1e-12;
function DT(e, t, n, i) {
  const [r, s, o, a] = rm(e, t, n, !0), l = r.length, u = Math.max(2, ~~(i * l)), c = new Float64Array(l), f = new Float64Array(l), d = new Float64Array(l).fill(1);
  for (let h = -1; ++h <= xk; ) {
    const g = [0, u - 1];
    for (let m = 0; m < l; ++m) {
      const y = r[m], b = g[0], v = g[1], _ = y - r[b] > r[v] - y ? b : v;
      let x = 0, S = 0, E = 0, C = 0, $ = 0;
      const N = 1 / Math.abs(r[_] - y || 1);
      for (let T = b; T <= v; ++T) {
        const D = r[T], M = s[T], w = eB(Math.abs(y - D) * N) * d[T], k = D * w;
        x += w, S += k, E += M * w, C += M * k, $ += D * k;
      }
      const [O, P] = nd(S / x, E / x, C / x, $ / x);
      c[m] = O + P * y, f[m] = Math.abs(s[m] - c[m]), tB(r, m + 1, g);
    }
    if (h === xk)
      break;
    const p = vF(f);
    if (Math.abs(p) < wk)
      break;
    for (let m = 0, y, b; m < l; ++m)
      y = f[m] / (6 * p), d[m] = y >= 1 ? wk : (b = 1 - y * y) * b;
  }
  return nB(r, c, o, a);
}
function eB(e) {
  return (e = 1 - e * e * e) * e * e;
}
function tB(e, t, n) {
  const i = e[t];
  let r = n[0], s = n[1] + 1;
  if (!(s >= e.length))
    for (; t > r && e[s] - i <= i - e[r]; )
      n[0] = ++r, n[1] = s, ++s;
}
function nB(e, t, n, i) {
  const r = e.length, s = [];
  let o = 0, a = 0, l = [], u;
  for (; o < r; ++o)
    u = e[o] + n, l[0] === u ? l[1] += (t[o] - l[1]) / ++a : (a = 0, l[1] += i, l = [u, t[o]], s.push(l));
  return l[1] += i, s;
}
const iB = 0.5 * Math.PI / 180;
function sm(e, t, n, i) {
  n = n || 25, i = Math.max(n, i || 200);
  const r = (p) => [p, e(p)], s = t[0], o = t[1], a = o - s, l = a / i, u = [r(s)], c = [];
  if (n === i) {
    for (let p = 1; p < i; ++p)
      u.push(r(s + p / n * a));
    return u.push(r(o)), u;
  } else {
    c.push(r(o));
    for (let p = n; --p > 0; )
      c.push(r(s + p / n * a));
  }
  let f = u[0], d = c[c.length - 1];
  const h = 1 / a, g = rB(f[1], c);
  for (; d; ) {
    const p = r((f[0] + d[0]) / 2);
    p[0] - f[0] >= l && sB(f, p, d, h, g) > iB ? c.push(p) : (f = d, u.push(d), c.pop()), d = c[c.length - 1];
  }
  return u;
}
function rB(e, t) {
  let n = e, i = e;
  const r = t.length;
  for (let s = 0; s < r; ++s) {
    const o = t[s][1];
    o < n && (n = o), o > i && (i = o);
  }
  return 1 / (i - n);
}
function sB(e, t, n, i, r) {
  const s = Math.atan2(r * (n[1] - e[1]), i * (n[0] - e[0])), o = Math.atan2(r * (t[1] - e[1]), i * (t[0] - e[0]));
  return Math.abs(s - o);
}
function oB(e) {
  return (t) => {
    const n = e.length;
    let i = 1, r = String(e[0](t));
    for (; i < n; ++i)
      r += "|" + e[i](t);
    return r;
  };
}
function jy(e) {
  return !e || !e.length ? function() {
    return "";
  } : e.length === 1 ? e[0] : oB(e);
}
function RT(e, t, n) {
  return n || e + (t ? "_" + t : "");
}
const r1 = () => {
}, aB = {
  init: r1,
  add: r1,
  rem: r1,
  idx: 0
}, Ef = {
  values: {
    init: (e) => e.cell.store = !0,
    value: (e) => e.cell.data.values(),
    idx: -1
  },
  count: {
    value: (e) => e.cell.num
  },
  __count__: {
    value: (e) => e.missing + e.valid
  },
  missing: {
    value: (e) => e.missing
  },
  valid: {
    value: (e) => e.valid
  },
  sum: {
    init: (e) => e.sum = 0,
    value: (e) => e.valid ? e.sum : void 0,
    add: (e, t) => e.sum += +t,
    rem: (e, t) => e.sum -= t
  },
  product: {
    init: (e) => e.product = 1,
    value: (e) => e.valid ? e.product : void 0,
    add: (e, t) => e.product *= t,
    rem: (e, t) => e.product /= t
  },
  mean: {
    init: (e) => e.mean = 0,
    value: (e) => e.valid ? e.mean : void 0,
    add: (e, t) => (e.mean_d = t - e.mean, e.mean += e.mean_d / e.valid),
    rem: (e, t) => (e.mean_d = t - e.mean, e.mean -= e.valid ? e.mean_d / e.valid : e.mean)
  },
  average: {
    value: (e) => e.valid ? e.mean : void 0,
    req: ["mean"],
    idx: 1
  },
  variance: {
    init: (e) => e.dev = 0,
    value: (e) => e.valid > 1 ? e.dev / (e.valid - 1) : void 0,
    add: (e, t) => e.dev += e.mean_d * (t - e.mean),
    rem: (e, t) => e.dev -= e.mean_d * (t - e.mean),
    req: ["mean"],
    idx: 1
  },
  variancep: {
    value: (e) => e.valid > 1 ? e.dev / e.valid : void 0,
    req: ["variance"],
    idx: 2
  },
  stdev: {
    value: (e) => e.valid > 1 ? Math.sqrt(e.dev / (e.valid - 1)) : void 0,
    req: ["variance"],
    idx: 2
  },
  stdevp: {
    value: (e) => e.valid > 1 ? Math.sqrt(e.dev / e.valid) : void 0,
    req: ["variance"],
    idx: 2
  },
  stderr: {
    value: (e) => e.valid > 1 ? Math.sqrt(e.dev / (e.valid * (e.valid - 1))) : void 0,
    req: ["variance"],
    idx: 2
  },
  distinct: {
    value: (e) => e.cell.data.distinct(e.get),
    req: ["values"],
    idx: 3
  },
  ci0: {
    value: (e) => e.cell.data.ci0(e.get),
    req: ["values"],
    idx: 3
  },
  ci1: {
    value: (e) => e.cell.data.ci1(e.get),
    req: ["values"],
    idx: 3
  },
  median: {
    value: (e) => e.cell.data.q2(e.get),
    req: ["values"],
    idx: 3
  },
  q1: {
    value: (e) => e.cell.data.q1(e.get),
    req: ["values"],
    idx: 3
  },
  q3: {
    value: (e) => e.cell.data.q3(e.get),
    req: ["values"],
    idx: 3
  },
  min: {
    init: (e) => e.min = void 0,
    value: (e) => e.min = Number.isNaN(e.min) ? e.cell.data.min(e.get) : e.min,
    add: (e, t) => {
      (t < e.min || e.min === void 0) && (e.min = t);
    },
    rem: (e, t) => {
      t <= e.min && (e.min = NaN);
    },
    req: ["values"],
    idx: 4
  },
  max: {
    init: (e) => e.max = void 0,
    value: (e) => e.max = Number.isNaN(e.max) ? e.cell.data.max(e.get) : e.max,
    add: (e, t) => {
      (t > e.max || e.max === void 0) && (e.max = t);
    },
    rem: (e, t) => {
      t >= e.max && (e.max = NaN);
    },
    req: ["values"],
    idx: 4
  },
  argmin: {
    init: (e) => e.argmin = void 0,
    value: (e) => e.argmin || e.cell.data.argmin(e.get),
    add: (e, t, n) => {
      t < e.min && (e.argmin = n);
    },
    rem: (e, t) => {
      t <= e.min && (e.argmin = void 0);
    },
    req: ["min", "values"],
    idx: 3
  },
  argmax: {
    init: (e) => e.argmax = void 0,
    value: (e) => e.argmax || e.cell.data.argmax(e.get),
    add: (e, t, n) => {
      t > e.max && (e.argmax = n);
    },
    rem: (e, t) => {
      t >= e.max && (e.argmax = void 0);
    },
    req: ["max", "values"],
    idx: 3
  },
  exponential: {
    init: (e, t) => {
      e.exp = 0, e.exp_r = t;
    },
    value: (e) => e.valid ? e.exp * (1 - e.exp_r) / (1 - e.exp_r ** e.valid) : void 0,
    add: (e, t) => e.exp = e.exp_r * e.exp + t,
    rem: (e, t) => e.exp = (e.exp - t / e.exp_r ** (e.valid - 1)) / e.exp_r
  },
  exponentialb: {
    value: (e) => e.valid ? e.exp * (1 - e.exp_r) : void 0,
    req: ["exponential"],
    idx: 1
  }
}, rd = Object.keys(Ef).filter((e) => e !== "__count__");
function lB(e, t) {
  return (n, i) => we({
    name: e,
    aggregate_param: i,
    out: n || e
  }, aB, t);
}
[...rd, "__count__"].forEach((e) => {
  Ef[e] = lB(e, Ef[e]);
});
function LT(e, t, n) {
  return Ef[e](n, t);
}
function PT(e, t) {
  return e.idx - t.idx;
}
function uB(e) {
  const t = {};
  e.forEach((i) => t[i.name] = i);
  const n = (i) => {
    i.req && i.req.forEach((r) => {
      t[r] || n(t[r] = Ef[r]());
    });
  };
  return e.forEach(n), Object.values(t).sort(PT);
}
function cB() {
  this.valid = 0, this.missing = 0, this._ops.forEach((e) => e.aggregate_param == null ? e.init(this) : e.init(this, e.aggregate_param));
}
function fB(e, t) {
  if (e == null || e === "") {
    ++this.missing;
    return;
  }
  e === e && (++this.valid, this._ops.forEach((n) => n.add(this, e, t)));
}
function dB(e, t) {
  if (e == null || e === "") {
    --this.missing;
    return;
  }
  e === e && (--this.valid, this._ops.forEach((n) => n.rem(this, e, t)));
}
function hB(e) {
  return this._out.forEach((t) => e[t.out] = t.value(this)), e;
}
function IT(e, t) {
  const n = t || an, i = uB(e), r = e.slice().sort(PT);
  function s(o) {
    this._ops = i, this._out = r, this.cell = o, this.init();
  }
  return s.prototype.init = cB, s.prototype.add = fB, s.prototype.rem = dB, s.prototype.set = hB, s.prototype.get = n, s.fields = e.map((o) => o.out), s;
}
function Lx(e) {
  this._key = e ? _i(e) : le, this.reset();
}
const Gt = Lx.prototype;
Gt.reset = function() {
  this._add = [], this._rem = [], this._ext = null, this._get = null, this._q = null;
};
Gt.add = function(e) {
  this._add.push(e);
};
Gt.rem = function(e) {
  this._rem.push(e);
};
Gt.values = function() {
  if (this._get = null, this._rem.length === 0)
    return this._add;
  const e = this._add, t = this._rem, n = this._key, i = e.length, r = t.length, s = Array(i - r), o = {};
  let a, l, u;
  for (a = 0; a < r; ++a)
    o[n(t[a])] = 1;
  for (a = 0, l = 0; a < i; ++a)
    o[n(u = e[a])] ? o[n(u)] = 0 : s[l++] = u;
  return this._rem = [], this._add = s;
};
Gt.distinct = function(e) {
  const t = this.values(), n = {};
  let i = t.length, r = 0, s;
  for (; --i >= 0; )
    s = e(t[i]) + "", ce(n, s) || (n[s] = 1, ++r);
  return r;
};
Gt.extent = function(e) {
  if (this._get !== e || !this._ext) {
    const t = this.values(), n = eF(t, e);
    this._ext = [t[n[0]], t[n[1]]], this._get = e;
  }
  return this._ext;
};
Gt.argmin = function(e) {
  return this.extent(e)[0] || {};
};
Gt.argmax = function(e) {
  return this.extent(e)[1] || {};
};
Gt.min = function(e) {
  const t = this.extent(e)[0];
  return t != null ? e(t) : void 0;
};
Gt.max = function(e) {
  const t = this.extent(e)[1];
  return t != null ? e(t) : void 0;
};
Gt.quartile = function(e) {
  return (this._get !== e || !this._q) && (this._q = xx(this.values(), e), this._get = e), this._q;
};
Gt.q1 = function(e) {
  return this.quartile(e)[0];
};
Gt.q2 = function(e) {
  return this.quartile(e)[1];
};
Gt.q3 = function(e) {
  return this.quartile(e)[2];
};
Gt.ci = function(e) {
  return (this._get !== e || !this._ci) && (this._ci = ST(this.values(), 1e3, 0.05, e), this._get = e), this._ci;
};
Gt.ci0 = function(e) {
  return this.ci(e)[0];
};
Gt.ci1 = function(e) {
  return this.ci(e)[1];
};
function go(e) {
  I.call(this, null, e), this._adds = [], this._mods = [], this._alen = 0, this._mlen = 0, this._drop = !0, this._cross = !1, this._dims = [], this._dnames = [], this._measures = [], this._countOnly = !1, this._counts = null, this._prev = null, this._inputs = null, this._outputs = null;
}
go.Definition = {
  type: "Aggregate",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "ops",
    type: "enum",
    array: !0,
    values: rd
  }, {
    name: "aggregate_params",
    type: "number",
    null: !0,
    array: !0
  }, {
    name: "fields",
    type: "field",
    null: !0,
    array: !0
  }, {
    name: "as",
    type: "string",
    null: !0,
    array: !0
  }, {
    name: "drop",
    type: "boolean",
    default: !0
  }, {
    name: "cross",
    type: "boolean",
    default: !1
  }, {
    name: "key",
    type: "field"
  }]
};
Y(go, I, {
  transform(e, t) {
    const n = this, i = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = e.modified();
    return n.stamp = i.stamp, n.value && (r || t.modified(n._inputs, !0)) ? (n._prev = n.value, n.value = r ? n.init(e) : /* @__PURE__ */ Object.create(null), t.visit(t.SOURCE, (s) => n.add(s))) : (n.value = n.value || n.init(e), t.visit(t.REM, (s) => n.rem(s)), t.visit(t.ADD, (s) => n.add(s))), i.modifies(n._outputs), n._drop = e.drop !== !1, e.cross && n._dims.length > 1 && (n._drop = !1, n.cross()), t.clean() && n._drop && i.clean(!0).runAfter(() => this.clean()), n.changes(i);
  },
  cross() {
    const e = this, t = e.value, n = e._dnames, i = n.map(() => ({})), r = n.length;
    function s(a) {
      let l, u, c, f;
      for (l in a)
        for (c = a[l].tuple, u = 0; u < r; ++u)
          i[u][f = c[n[u]]] = f;
    }
    s(e._prev), s(t);
    function o(a, l, u) {
      const c = n[u], f = i[u++];
      for (const d in f) {
        const h = a ? a + "|" + d : d;
        l[c] = f[d], u < r ? o(h, l, u) : t[h] || e.cell(h, l);
      }
    }
    o("", {}, 0);
  },
  init(e) {
    const t = this._inputs = [], n = this._outputs = [], i = {};
    function r(b) {
      const v = ee(nn(b)), _ = v.length;
      let x = 0, S;
      for (; x < _; ++x)
        i[S = v[x]] || (i[S] = 1, t.push(S));
    }
    this._dims = ee(e.groupby), this._dnames = this._dims.map((b) => {
      const v = ut(b);
      return r(b), n.push(v), v;
    }), this.cellkey = e.key ? e.key : jy(this._dims), this._countOnly = !0, this._counts = [], this._measures = [];
    const s = e.fields || [null], o = e.ops || ["count"], a = e.aggregate_params || [null], l = e.as || [], u = s.length, c = {};
    let f, d, h, g, p, m, y;
    for (u !== o.length && j("Unmatched number of fields and aggregate ops."), y = 0; y < u; ++y) {
      if (f = s[y], d = o[y], h = a[y] || null, f == null && d !== "count" && j("Null aggregate field specified."), p = ut(f), m = RT(d, p, l[y]), n.push(m), d === "count") {
        this._counts.push(m);
        continue;
      }
      g = c[p], g || (r(f), g = c[p] = [], g.field = f, this._measures.push(g)), d !== "count" && (this._countOnly = !1), g.push(LT(d, h, m));
    }
    return this._measures = this._measures.map((b) => IT(b, b.field)), /* @__PURE__ */ Object.create(null);
  },
  // -- Cell Management -----
  cellkey: jy(),
  cell(e, t) {
    let n = this.value[e];
    return n ? n.num === 0 && this._drop && n.stamp < this.stamp ? (n.stamp = this.stamp, this._adds[this._alen++] = n) : n.stamp < this.stamp && (n.stamp = this.stamp, this._mods[this._mlen++] = n) : (n = this.value[e] = this.newcell(e, t), this._adds[this._alen++] = n), n;
  },
  newcell(e, t) {
    const n = {
      key: e,
      num: 0,
      agg: null,
      tuple: this.newtuple(t, this._prev && this._prev[e]),
      stamp: this.stamp,
      store: !1
    };
    if (!this._countOnly) {
      const i = this._measures, r = i.length;
      n.agg = Array(r);
      for (let s = 0; s < r; ++s)
        n.agg[s] = new i[s](n);
    }
    return n.store && (n.data = new Lx()), n;
  },
  newtuple(e, t) {
    const n = this._dnames, i = this._dims, r = i.length, s = {};
    for (let o = 0; o < r; ++o)
      s[n[o]] = i[o](e);
    return t ? mT(t.tuple, s) : je(s);
  },
  clean() {
    const e = this.value;
    for (const t in e)
      e[t].num === 0 && delete e[t];
  },
  // -- Process Tuples -----
  add(e) {
    const t = this.cellkey(e), n = this.cell(t, e);
    if (n.num += 1, this._countOnly)
      return;
    n.store && n.data.add(e);
    const i = n.agg;
    for (let r = 0, s = i.length; r < s; ++r)
      i[r].add(i[r].get(e), e);
  },
  rem(e) {
    const t = this.cellkey(e), n = this.cell(t, e);
    if (n.num -= 1, this._countOnly)
      return;
    n.store && n.data.rem(e);
    const i = n.agg;
    for (let r = 0, s = i.length; r < s; ++r)
      i[r].rem(i[r].get(e), e);
  },
  celltuple(e) {
    const t = e.tuple, n = this._counts;
    e.store && e.data.values();
    for (let i = 0, r = n.length; i < r; ++i)
      t[n[i]] = e.num;
    if (!this._countOnly) {
      const i = e.agg;
      for (let r = 0, s = i.length; r < s; ++r)
        i[r].set(t);
    }
    return t;
  },
  changes(e) {
    const t = this._adds, n = this._mods, i = this._prev, r = this._drop, s = e.add, o = e.rem, a = e.mod;
    let l, u, c, f;
    if (i)
      for (u in i)
        l = i[u], (!r || l.num) && o.push(l.tuple);
    for (c = 0, f = this._alen; c < f; ++c)
      s.push(this.celltuple(t[c])), t[c] = null;
    for (c = 0, f = this._mlen; c < f; ++c)
      l = n[c], (l.num === 0 && r ? o : a).push(this.celltuple(l)), n[c] = null;
    return this._alen = this._mlen = 0, this._prev = null, e;
  }
});
const gB = 1e-14;
function Px(e) {
  I.call(this, null, e);
}
Px.Definition = {
  type: "Bin",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "interval",
    type: "boolean",
    default: !0
  }, {
    name: "anchor",
    type: "number"
  }, {
    name: "maxbins",
    type: "number",
    default: 20
  }, {
    name: "base",
    type: "number",
    default: 10
  }, {
    name: "divide",
    type: "number",
    array: !0,
    default: [5, 2]
  }, {
    name: "extent",
    type: "number",
    array: !0,
    length: 2,
    required: !0
  }, {
    name: "span",
    type: "number"
  }, {
    name: "step",
    type: "number"
  }, {
    name: "steps",
    type: "number",
    array: !0
  }, {
    name: "minstep",
    type: "number",
    default: 0
  }, {
    name: "nice",
    type: "boolean",
    default: !0
  }, {
    name: "name",
    type: "string"
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["bin0", "bin1"]
  }]
};
Y(Px, I, {
  transform(e, t) {
    const n = e.interval !== !1, i = this._bins(e), r = i.start, s = i.step, o = e.as || ["bin0", "bin1"], a = o[0], l = o[1];
    let u;
    return e.modified() ? (t = t.reflow(!0), u = t.SOURCE) : u = t.modified(nn(e.field)) ? t.ADD_MOD : t.ADD, t.visit(u, n ? (c) => {
      const f = i(c);
      c[a] = f, c[l] = f == null ? null : r + s * (1 + (f - r) / s);
    } : (c) => c[a] = i(c)), t.modifies(n ? o : a);
  },
  _bins(e) {
    if (this.value && !e.modified())
      return this.value;
    const t = e.field, n = ET(e), i = n.step;
    let r = n.start, s = r + Math.ceil((n.stop - r) / i) * i, o, a;
    (o = e.anchor) != null && (a = o - (r + i * Math.floor((o - r) / i)), r += a, s += a);
    const l = function(u) {
      let c = Zt(t(u));
      return c == null ? null : c < r ? -1 / 0 : c > s ? 1 / 0 : (c = Math.max(r, Math.min(c, s - i)), r + i * Math.floor(gB + (c - r) / i));
    };
    return l.start = r, l.stop = n.stop, l.step = i, this.value = Wn(l, nn(t), e.name || "bin_" + ut(t));
  }
});
function zT(e, t, n) {
  const i = e;
  let r = t || [], s = n || [], o = {}, a = 0;
  return {
    add: (l) => s.push(l),
    remove: (l) => o[i(l)] = ++a,
    size: () => r.length,
    data: (l, u) => (a && (r = r.filter((c) => !o[i(c)]), o = {}, a = 0), u && l && r.sort(l), s.length && (r = l ? oF(l, r, s.sort(l)) : r.concat(s), s = []), r)
  };
}
function Ix(e) {
  I.call(this, [], e);
}
Ix.Definition = {
  type: "Collect",
  metadata: {
    source: !0
  },
  params: [{
    name: "sort",
    type: "compare"
  }]
};
Y(Ix, I, {
  transform(e, t) {
    const n = t.fork(t.ALL), i = zT(le, this.value, n.materialize(n.ADD).add), r = e.sort, s = t.changed() || r && (e.modified("sort") || t.modified(r.fields));
    return n.visit(n.REM, i.remove), this.modified(s), this.value = n.source = i.data(el(r), s), t.source && t.source.root && (this.value.root = t.source.root), n;
  }
});
function BT(e) {
  Xe.call(this, null, pB, e);
}
Y(BT, Xe);
function pB(e) {
  return this.value && !e.modified() ? this.value : Qv(e.fields, e.orders);
}
function zx(e) {
  I.call(this, null, e);
}
zx.Definition = {
  type: "CountPattern",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "case",
    type: "enum",
    values: ["upper", "lower", "mixed"],
    default: "mixed"
  }, {
    name: "pattern",
    type: "string",
    default: '[\\w"]+'
  }, {
    name: "stopwords",
    type: "string",
    default: ""
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["text", "count"]
  }]
};
function mB(e, t, n) {
  switch (t) {
    case "upper":
      e = e.toUpperCase();
      break;
    case "lower":
      e = e.toLowerCase();
      break;
  }
  return e.match(n);
}
Y(zx, I, {
  transform(e, t) {
    const n = (f) => (d) => {
      for (var h = mB(a(d), e.case, s) || [], g, p = 0, m = h.length; p < m; ++p)
        o.test(g = h[p]) || f(g);
    }, i = this._parameterCheck(e, t), r = this._counts, s = this._match, o = this._stop, a = e.field, l = e.as || ["text", "count"], u = n((f) => r[f] = 1 + (r[f] || 0)), c = n((f) => r[f] -= 1);
    return i ? t.visit(t.SOURCE, u) : (t.visit(t.ADD, u), t.visit(t.REM, c)), this._finish(t, l);
  },
  _parameterCheck(e, t) {
    let n = !1;
    return (e.modified("stopwords") || !this._stop) && (this._stop = new RegExp("^" + (e.stopwords || "") + "$", "i"), n = !0), (e.modified("pattern") || !this._match) && (this._match = new RegExp(e.pattern || "[\\w']+", "g"), n = !0), (e.modified("field") || t.modified(e.field.fields)) && (n = !0), n && (this._counts = {}), n;
  },
  _finish(e, t) {
    const n = this._counts, i = this._tuples || (this._tuples = {}), r = t[0], s = t[1], o = e.fork(e.NO_SOURCE | e.NO_FIELDS);
    let a, l, u;
    for (a in n)
      l = i[a], u = n[a] || 0, !l && u ? (i[a] = l = je({}), l[r] = a, l[s] = u, o.add.push(l)) : u === 0 ? (l && o.rem.push(l), n[a] = null, i[a] = null) : l[s] !== u && (l[s] = u, o.mod.push(l));
    return o.modifies(t);
  }
});
function Bx(e) {
  I.call(this, null, e);
}
Bx.Definition = {
  type: "Cross",
  metadata: {
    generates: !0
  },
  params: [{
    name: "filter",
    type: "expr"
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["a", "b"]
  }]
};
Y(Bx, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE), i = e.as || ["a", "b"], r = i[0], s = i[1], o = !this.value || t.changed(t.ADD_REM) || e.modified("as") || e.modified("filter");
    let a = this.value;
    return o ? (a && (n.rem = a), a = t.materialize(t.SOURCE).source, n.add = this.value = yB(a, r, s, e.filter || Ei)) : n.mod = a, n.source = this.value, n.modifies(i);
  }
});
function yB(e, t, n, i) {
  for (var r = [], s = {}, o = e.length, a = 0, l, u; a < o; ++a)
    for (s[t] = u = e[a], l = 0; l < o; ++l)
      s[n] = e[l], i(s) && (r.push(je(s)), s = {}, s[t] = u);
  return r;
}
const _k = {
  kde: Sx,
  mixture: $T,
  normal: Ex,
  lognormal: CT,
  uniform: MT
}, bB = "distributions", Ek = "function", vB = "field";
function jT(e, t) {
  const n = e[Ek];
  ce(_k, n) || j("Unknown distribution function: " + n);
  const i = _k[n]();
  for (const r in e)
    r === vB ? i.data((e.from || t()).map(e[r])) : r === bB ? i[r](e[r].map((s) => jT(s, t))) : typeof i[r] === Ek && i[r](e[r]);
  return i;
}
function jx(e) {
  I.call(this, null, e);
}
const UT = [{
  key: {
    function: "normal"
  },
  params: [{
    name: "mean",
    type: "number",
    default: 0
  }, {
    name: "stdev",
    type: "number",
    default: 1
  }]
}, {
  key: {
    function: "lognormal"
  },
  params: [{
    name: "mean",
    type: "number",
    default: 0
  }, {
    name: "stdev",
    type: "number",
    default: 1
  }]
}, {
  key: {
    function: "uniform"
  },
  params: [{
    name: "min",
    type: "number",
    default: 0
  }, {
    name: "max",
    type: "number",
    default: 1
  }]
}, {
  key: {
    function: "kde"
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "from",
    type: "data"
  }, {
    name: "bandwidth",
    type: "number",
    default: 0
  }]
}], xB = {
  key: {
    function: "mixture"
  },
  params: [{
    name: "distributions",
    type: "param",
    array: !0,
    params: UT
  }, {
    name: "weights",
    type: "number",
    array: !0
  }]
};
jx.Definition = {
  type: "Density",
  metadata: {
    generates: !0
  },
  params: [{
    name: "extent",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "steps",
    type: "number"
  }, {
    name: "minsteps",
    type: "number",
    default: 25
  }, {
    name: "maxsteps",
    type: "number",
    default: 200
  }, {
    name: "method",
    type: "string",
    default: "pdf",
    values: ["pdf", "cdf"]
  }, {
    name: "distribution",
    type: "param",
    params: UT.concat(xB)
  }, {
    name: "as",
    type: "string",
    array: !0,
    default: ["value", "density"]
  }]
};
Y(jx, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE | t.NO_FIELDS);
    if (!this.value || t.changed() || e.modified()) {
      const i = jT(e.distribution, wB(t)), r = e.steps || e.minsteps || 25, s = e.steps || e.maxsteps || 200;
      let o = e.method || "pdf";
      o !== "pdf" && o !== "cdf" && j("Invalid density method: " + o), !e.extent && !i.data && j("Missing density extent parameter."), o = i[o];
      const a = e.as || ["value", "density"], l = e.extent || $r(i.data()), u = sm(o, l, r, s).map((c) => {
        const f = {};
        return f[a[0]] = c[0], f[a[1]] = c[1], je(f);
      });
      this.value && (n.rem = this.value), this.value = n.add = n.source = u;
    }
    return n;
  }
});
function wB(e) {
  return () => e.materialize(e.SOURCE).source;
}
function qT(e, t) {
  return e ? e.map((n, i) => t[i] || ut(n)) : null;
}
function Ux(e, t, n) {
  const i = [], r = (f) => f(l);
  let s, o, a, l, u, c;
  if (t == null)
    i.push(e.map(n));
  else
    for (s = {}, o = 0, a = e.length; o < a; ++o)
      l = e[o], u = t.map(r), c = s[u], c || (s[u] = c = [], c.dims = u, i.push(c)), c.push(n(l));
  return i;
}
const WT = "bin";
function qx(e) {
  I.call(this, null, e);
}
qx.Definition = {
  type: "DotBin",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "step",
    type: "number"
  }, {
    name: "smooth",
    type: "boolean",
    default: !1
  }, {
    name: "as",
    type: "string",
    default: WT
  }]
};
const _B = (e, t) => td($r(e, t)) / 30;
Y(qx, I, {
  transform(e, t) {
    if (this.value && !(e.modified() || t.changed()))
      return t;
    const n = t.materialize(t.SOURCE).source, i = Ux(t.source, e.groupby, an), r = e.smooth || !1, s = e.field, o = e.step || _B(n, s), a = el((g, p) => s(g) - s(p)), l = e.as || WT, u = i.length;
    let c = 1 / 0, f = -1 / 0, d = 0, h;
    for (; d < u; ++d) {
      const g = i[d].sort(a);
      h = -1;
      for (const p of kT(g, o, r, s))
        p < c && (c = p), p > f && (f = p), g[++h][l] = p;
    }
    return this.value = {
      start: c,
      stop: f,
      step: o
    }, t.reflow(!0).modifies(l);
  }
});
function HT(e) {
  Xe.call(this, null, EB, e), this.modified(!0);
}
Y(HT, Xe);
function EB(e) {
  const t = e.expr;
  return this.value && !e.modified("expr") ? this.value : Wn((n) => t(n, e), nn(t), ut(t));
}
function Wx(e) {
  I.call(this, [void 0, void 0], e);
}
Wx.Definition = {
  type: "Extent",
  metadata: {},
  params: [{
    name: "field",
    type: "field",
    required: !0
  }]
};
Y(Wx, I, {
  transform(e, t) {
    const n = this.value, i = e.field, r = t.changed() || t.modified(i.fields) || e.modified("field");
    let s = n[0], o = n[1];
    if ((r || s == null) && (s = 1 / 0, o = -1 / 0), t.visit(r ? t.SOURCE : t.ADD, (a) => {
      const l = Zt(i(a));
      l != null && (l < s && (s = l), l > o && (o = l));
    }), !Number.isFinite(s) || !Number.isFinite(o)) {
      let a = ut(i);
      a && (a = ` for field "${a}"`), t.dataflow.warn(`Infinite extent${a}: [${s}, ${o}]`), s = o = void 0;
    }
    this.value = [s, o];
  }
});
function Hx(e, t) {
  Xe.call(this, e), this.parent = t, this.count = 0;
}
Y(Hx, Xe, {
  /**
   * Routes pulses from this subflow to a target transform.
   * @param {Transform} target - A transform that receives the subflow of tuples.
   */
  connect(e) {
    return this.detachSubflow = e.detachSubflow, this.targets().add(e), e.source = this;
  },
  /**
   * Add an 'add' tuple to the subflow pulse.
   * @param {Tuple} t - The tuple being added.
   */
  add(e) {
    this.count += 1, this.value.add.push(e);
  },
  /**
   * Add a 'rem' tuple to the subflow pulse.
   * @param {Tuple} t - The tuple being removed.
   */
  rem(e) {
    this.count -= 1, this.value.rem.push(e);
  },
  /**
   * Add a 'mod' tuple to the subflow pulse.
   * @param {Tuple} t - The tuple being modified.
   */
  mod(e) {
    this.value.mod.push(e);
  },
  /**
   * Re-initialize this operator's pulse value.
   * @param {Pulse} pulse - The pulse to copy from.
   * @see Pulse.init
   */
  init(e) {
    this.value.init(e, e.NO_SOURCE);
  },
  /**
   * Evaluate this operator. This method overrides the
   * default behavior to simply return the contained pulse value.
   * @return {Pulse}
   */
  evaluate() {
    return this.value;
  }
});
function om(e) {
  I.call(this, {}, e), this._keys = Lu();
  const t = this._targets = [];
  t.active = 0, t.forEach = (n) => {
    for (let i = 0, r = t.active; i < r; ++i)
      n(t[i], i, t);
  };
}
Y(om, I, {
  activate(e) {
    this._targets[this._targets.active++] = e;
  },
  // parent argument provided by PreFacet subclass
  subflow(e, t, n, i) {
    const r = this.value;
    let s = ce(r, e) && r[e], o, a;
    return s ? s.value.stamp < n.stamp && (s.init(n), this.activate(s)) : (a = i || (a = this._group[e]) && a.tuple, o = n.dataflow, s = new Hx(n.fork(n.NO_SOURCE), this), o.add(s).connect(t(o, e, a)), r[e] = s, this.activate(s)), s;
  },
  clean() {
    const e = this.value;
    let t = 0;
    for (const n in e)
      if (e[n].count === 0) {
        const i = e[n].detachSubflow;
        i && i(), delete e[n], ++t;
      }
    if (t) {
      const n = this._targets.filter((i) => i && i.count > 0);
      this.initTargets(n);
    }
  },
  initTargets(e) {
    const t = this._targets, n = t.length, i = e ? e.length : 0;
    let r = 0;
    for (; r < i; ++r)
      t[r] = e[r];
    for (; r < n && t[r] != null; ++r)
      t[r] = null;
    t.active = i;
  },
  transform(e, t) {
    const n = t.dataflow, i = e.key, r = e.subflow, s = this._keys, o = e.modified("key"), a = (l) => this.subflow(l, r, t);
    return this._group = e.group || {}, this.initTargets(), t.visit(t.REM, (l) => {
      const u = le(l), c = s.get(u);
      c !== void 0 && (s.delete(u), a(c).rem(l));
    }), t.visit(t.ADD, (l) => {
      const u = i(l);
      s.set(le(l), u), a(u).add(l);
    }), o || t.modified(i.fields) ? t.visit(t.MOD, (l) => {
      const u = le(l), c = s.get(u), f = i(l);
      c === f ? a(f).mod(l) : (s.set(u, f), a(c).rem(l), a(f).add(l));
    }) : t.changed(t.MOD) && t.visit(t.MOD, (l) => {
      a(s.get(le(l))).mod(l);
    }), o && t.visit(t.REFLOW, (l) => {
      const u = le(l), c = s.get(u), f = i(l);
      c !== f && (s.set(u, f), a(c).rem(l), a(f).add(l));
    }), t.clean() ? n.runAfter(() => {
      this.clean(), s.clean();
    }) : s.empty > n.cleanThreshold && n.runAfter(s.clean), t;
  }
});
function GT(e) {
  Xe.call(this, null, SB, e);
}
Y(GT, Xe);
function SB(e) {
  return this.value && !e.modified() ? this.value : U(e.name) ? ee(e.name).map((t) => _i(t)) : _i(e.name, e.as);
}
function Gx(e) {
  I.call(this, Lu(), e);
}
Gx.Definition = {
  type: "Filter",
  metadata: {
    changes: !0
  },
  params: [{
    name: "expr",
    type: "expr",
    required: !0
  }]
};
Y(Gx, I, {
  transform(e, t) {
    const n = t.dataflow, i = this.value, r = t.fork(), s = r.add, o = r.rem, a = r.mod, l = e.expr;
    let u = !0;
    t.visit(t.REM, (f) => {
      const d = le(f);
      i.has(d) ? i.delete(d) : o.push(f);
    }), t.visit(t.ADD, (f) => {
      l(f, e) ? s.push(f) : i.set(le(f), 1);
    });
    function c(f) {
      const d = le(f), h = l(f, e), g = i.get(d);
      h && g ? (i.delete(d), s.push(f)) : !h && !g ? (i.set(d, 1), o.push(f)) : u && h && !g && a.push(f);
    }
    return t.visit(t.MOD, c), e.modified() && (u = !1, t.visit(t.REFLOW, c)), i.empty > n.cleanThreshold && n.runAfter(i.clean), r;
  }
});
function Vx(e) {
  I.call(this, [], e);
}
Vx.Definition = {
  type: "Flatten",
  metadata: {
    generates: !0
  },
  params: [{
    name: "fields",
    type: "field",
    array: !0,
    required: !0
  }, {
    name: "index",
    type: "string"
  }, {
    name: "as",
    type: "string",
    array: !0
  }]
};
Y(Vx, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE), i = e.fields, r = qT(i, e.as || []), s = e.index || null, o = r.length;
    return n.rem = this.value, t.visit(t.SOURCE, (a) => {
      const l = i.map((g) => g(a)), u = l.reduce((g, p) => Math.max(g, p.length), 0);
      let c = 0, f, d, h;
      for (; c < u; ++c) {
        for (d = mx(a), f = 0; f < o; ++f)
          d[r[f]] = (h = l[f][c]) == null ? null : h;
        s && (d[s] = c), n.add.push(d);
      }
    }), this.value = n.source = n.add, s && n.modifies(s), n.modifies(r);
  }
});
function Yx(e) {
  I.call(this, [], e);
}
Yx.Definition = {
  type: "Fold",
  metadata: {
    generates: !0
  },
  params: [{
    name: "fields",
    type: "field",
    array: !0,
    required: !0
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["key", "value"]
  }]
};
Y(Yx, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE), i = e.fields, r = i.map(ut), s = e.as || ["key", "value"], o = s[0], a = s[1], l = i.length;
    return n.rem = this.value, t.visit(t.SOURCE, (u) => {
      for (let c = 0, f; c < l; ++c)
        f = mx(u), f[o] = r[c], f[a] = i[c](u), n.add.push(f);
    }), this.value = n.source = n.add, n.modifies(s);
  }
});
function Xx(e) {
  I.call(this, null, e);
}
Xx.Definition = {
  type: "Formula",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "expr",
    type: "expr",
    required: !0
  }, {
    name: "as",
    type: "string",
    required: !0
  }, {
    name: "initonly",
    type: "boolean"
  }]
};
Y(Xx, I, {
  transform(e, t) {
    const n = e.expr, i = e.as, r = e.modified(), s = e.initonly ? t.ADD : r ? t.SOURCE : t.modified(n.fields) || t.modified(i) ? t.ADD_MOD : t.ADD;
    return r && (t = t.materialize().reflow(!0)), e.initonly || t.modifies(i), t.visit(s, (o) => o[i] = n(o, e));
  }
});
function VT(e) {
  I.call(this, [], e);
}
Y(VT, I, {
  transform(e, t) {
    const n = t.fork(t.ALL), i = e.generator;
    let r = this.value, s = e.size - r.length, o, a, l;
    if (s > 0) {
      for (o = []; --s >= 0; )
        o.push(l = je(i(e))), r.push(l);
      n.add = n.add.length ? n.materialize(n.ADD).add.concat(o) : o;
    } else
      a = r.slice(0, -s), n.rem = n.rem.length ? n.materialize(n.REM).rem.concat(a) : a, r = r.slice(-s);
    return n.source = this.value = r, n;
  }
});
const Yd = {
  value: "value",
  median: vF,
  mean: o9,
  min: Fy,
  max: va
}, kB = [];
function Kx(e) {
  I.call(this, [], e);
}
Kx.Definition = {
  type: "Impute",
  metadata: {
    changes: !0
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "key",
    type: "field",
    required: !0
  }, {
    name: "keyvals",
    array: !0
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "method",
    type: "enum",
    default: "value",
    values: ["value", "mean", "median", "max", "min"]
  }, {
    name: "value",
    default: 0
  }]
};
function AB(e) {
  var t = e.method || Yd.value, n;
  if (Yd[t] == null)
    j("Unrecognized imputation method: " + t);
  else
    return t === Yd.value ? (n = e.value !== void 0 ? e.value : 0, () => n) : Yd[t];
}
function CB(e) {
  const t = e.field;
  return (n) => n ? t(n) : NaN;
}
Y(Kx, I, {
  transform(e, t) {
    var n = t.fork(t.ALL), i = AB(e), r = CB(e), s = ut(e.field), o = ut(e.key), a = (e.groupby || []).map(ut), l = $B(t.source, e.groupby, e.key, e.keyvals), u = [], c = this.value, f = l.domain.length, d, h, g, p, m, y, b, v, _, x;
    for (m = 0, v = l.length; m < v; ++m)
      for (d = l[m], g = d.values, h = NaN, b = 0; b < f; ++b)
        if (d[b] == null) {
          for (p = l.domain[b], x = {
            _impute: !0
          }, y = 0, _ = g.length; y < _; ++y)
            x[a[y]] = g[y];
          x[o] = p, x[s] = Number.isNaN(h) ? h = i(d, r) : h, u.push(je(x));
        }
    return u.length && (n.add = n.materialize(n.ADD).add.concat(u)), c.length && (n.rem = n.materialize(n.REM).rem.concat(c)), this.value = u, n;
  }
});
function $B(e, t, n, i) {
  var r = (y) => y(m), s = [], o = i ? i.slice() : [], a = {}, l = {}, u, c, f, d, h, g, p, m;
  for (o.forEach((y, b) => a[y] = b + 1), d = 0, p = e.length; d < p; ++d)
    m = e[d], g = n(m), h = a[g] || (a[g] = o.push(g)), c = (u = t ? t.map(r) : kB) + "", (f = l[c]) || (f = l[c] = [], s.push(f), f.values = u), f[h - 1] = m;
  return s.domain = o, s;
}
function Jx(e) {
  go.call(this, e);
}
Jx.Definition = {
  type: "JoinAggregate",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "fields",
    type: "field",
    null: !0,
    array: !0
  }, {
    name: "ops",
    type: "enum",
    array: !0,
    values: rd
  }, {
    name: "as",
    type: "string",
    null: !0,
    array: !0
  }, {
    name: "key",
    type: "field"
  }]
};
Y(Jx, go, {
  transform(e, t) {
    const n = this, i = e.modified();
    let r;
    return n.value && (i || t.modified(n._inputs, !0)) ? (r = n.value = i ? n.init(e) : {}, t.visit(t.SOURCE, (s) => n.add(s))) : (r = n.value = n.value || this.init(e), t.visit(t.REM, (s) => n.rem(s)), t.visit(t.ADD, (s) => n.add(s))), n.changes(), t.visit(t.SOURCE, (s) => {
      we(s, r[n.cellkey(s)].tuple);
    }), t.reflow(i).modifies(this._outputs);
  },
  changes() {
    const e = this._adds, t = this._mods;
    let n, i;
    for (n = 0, i = this._alen; n < i; ++n)
      this.celltuple(e[n]), e[n] = null;
    for (n = 0, i = this._mlen; n < i; ++n)
      this.celltuple(t[n]), t[n] = null;
    this._alen = this._mlen = 0;
  }
});
function Qx(e) {
  I.call(this, null, e);
}
Qx.Definition = {
  type: "KDE",
  metadata: {
    generates: !0
  },
  params: [{
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "cumulative",
    type: "boolean",
    default: !1
  }, {
    name: "counts",
    type: "boolean",
    default: !1
  }, {
    name: "bandwidth",
    type: "number",
    default: 0
  }, {
    name: "extent",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "resolve",
    type: "enum",
    values: ["shared", "independent"],
    default: "independent"
  }, {
    name: "steps",
    type: "number"
  }, {
    name: "minsteps",
    type: "number",
    default: 25
  }, {
    name: "maxsteps",
    type: "number",
    default: 200
  }, {
    name: "as",
    type: "string",
    array: !0,
    default: ["value", "density"]
  }]
};
Y(Qx, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE | t.NO_FIELDS);
    if (!this.value || t.changed() || e.modified()) {
      const i = t.materialize(t.SOURCE).source, r = Ux(i, e.groupby, e.field), s = (e.groupby || []).map(ut), o = e.bandwidth, a = e.cumulative ? "cdf" : "pdf", l = e.as || ["value", "density"], u = [];
      let c = e.extent, f = e.steps || e.minsteps || 25, d = e.steps || e.maxsteps || 200;
      a !== "pdf" && a !== "cdf" && j("Invalid density method: " + a), e.resolve === "shared" && (c || (c = $r(i, e.field)), f = d = e.steps || d), r.forEach((h) => {
        const g = Sx(h, o)[a], p = e.counts ? h.length : 1, m = c || $r(h);
        sm(g, m, f, d).forEach((y) => {
          const b = {};
          for (let v = 0; v < s.length; ++v)
            b[s[v]] = h.dims[v];
          b[l[0]] = y[0], b[l[1]] = y[1] * p, u.push(je(b));
        });
      }), this.value && (n.rem = this.value), this.value = n.add = n.source = u;
    }
    return n;
  }
});
function YT(e) {
  Xe.call(this, null, MB, e);
}
Y(YT, Xe);
function MB(e) {
  return this.value && !e.modified() ? this.value : ex(e.fields, e.flat);
}
function XT(e) {
  I.call(this, [], e), this._pending = null;
}
Y(XT, I, {
  transform(e, t) {
    const n = t.dataflow;
    return this._pending ? s1(this, t, this._pending) : FB(e) ? t.StopPropagation : e.values ? s1(this, t, n.parse(e.values, e.format)) : e.async ? {
      async: n.request(e.url, e.format).then((r) => (this._pending = ee(r.data), (s) => s.touch(this)))
    } : n.request(e.url, e.format).then((i) => s1(this, t, ee(i.data)));
  }
});
function FB(e) {
  return e.modified("async") && !(e.modified("values") || e.modified("url") || e.modified("format"));
}
function s1(e, t, n) {
  n.forEach(je);
  const i = t.fork(t.NO_FIELDS & t.NO_SOURCE);
  return i.rem = e.value, e.value = i.source = i.add = n, e._pending = null, i.rem.length && i.clean(!0), i;
}
function Zx(e) {
  I.call(this, {}, e);
}
Zx.Definition = {
  type: "Lookup",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "index",
    type: "index",
    params: [{
      name: "from",
      type: "data",
      required: !0
    }, {
      name: "key",
      type: "field",
      required: !0
    }]
  }, {
    name: "values",
    type: "field",
    array: !0
  }, {
    name: "fields",
    type: "field",
    array: !0,
    required: !0
  }, {
    name: "as",
    type: "string",
    array: !0
  }, {
    name: "default",
    default: null
  }]
};
Y(Zx, I, {
  transform(e, t) {
    const n = e.fields, i = e.index, r = e.values, s = e.default == null ? null : e.default, o = e.modified(), a = n.length;
    let l = o ? t.SOURCE : t.ADD, u = t, c = e.as, f, d, h;
    return r ? (d = r.length, a > 1 && !c && j('Multi-field lookup requires explicit "as" parameter.'), c && c.length !== a * d && j('The "as" parameter has too few output field names.'), c = c || r.map(ut), f = function(g) {
      for (var p = 0, m = 0, y, b; p < a; ++p)
        if (b = i.get(n[p](g)), b == null)
          for (y = 0; y < d; ++y, ++m)
            g[c[m]] = s;
        else
          for (y = 0; y < d; ++y, ++m)
            g[c[m]] = r[y](b);
    }) : (c || j("Missing output field names."), f = function(g) {
      for (var p = 0, m; p < a; ++p)
        m = i.get(n[p](g)), g[c[p]] = m ?? s;
    }), o ? u = t.reflow(!0) : (h = n.some((g) => t.modified(g.fields)), l |= h ? t.MOD : 0), t.visit(l, f), u.modifies(c);
  }
});
function KT(e) {
  Xe.call(this, null, TB, e);
}
Y(KT, Xe);
function TB(e) {
  if (this.value && !e.modified())
    return this.value;
  const t = e.extents, n = t.length;
  let i = 1 / 0, r = -1 / 0, s, o;
  for (s = 0; s < n; ++s)
    o = t[s], o[0] < i && (i = o[0]), o[1] > r && (r = o[1]);
  return [i, r];
}
function JT(e) {
  Xe.call(this, null, OB, e);
}
Y(JT, Xe);
function OB(e) {
  return this.value && !e.modified() ? this.value : e.values.reduce((t, n) => t.concat(n), []);
}
function QT(e) {
  I.call(this, null, e);
}
Y(QT, I, {
  transform(e, t) {
    return this.modified(e.modified()), this.value = e, t.fork(t.NO_SOURCE | t.NO_FIELDS);
  }
});
function e2(e) {
  go.call(this, e);
}
e2.Definition = {
  type: "Pivot",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "value",
    type: "field",
    required: !0
  }, {
    name: "op",
    type: "enum",
    values: rd,
    default: "sum"
  }, {
    name: "limit",
    type: "number",
    default: 0
  }, {
    name: "key",
    type: "field"
  }]
};
Y(e2, go, {
  _transform: go.prototype.transform,
  transform(e, t) {
    return this._transform(NB(e, t), t);
  }
});
function NB(e, t) {
  const n = e.field, i = e.value, r = (e.op === "count" ? "__count__" : e.op) || "sum", s = nn(n).concat(nn(i)), o = RB(n, e.limit || 0, t);
  return t.changed() && e.set("__pivot__", null, null, !0), {
    key: e.key,
    groupby: e.groupby,
    ops: o.map(() => r),
    fields: o.map((a) => DB(a, n, i, s)),
    as: o.map((a) => a + ""),
    modified: e.modified.bind(e)
  };
}
function DB(e, t, n, i) {
  return Wn((r) => t(r) === e ? n(r) : NaN, i, e + "");
}
function RB(e, t, n) {
  const i = {}, r = [];
  return n.visit(n.SOURCE, (s) => {
    const o = e(s);
    i[o] || (i[o] = 1, r.push(o));
  }), r.sort(Up), t ? r.slice(0, t) : r;
}
function ZT(e) {
  om.call(this, e);
}
Y(ZT, om, {
  transform(e, t) {
    const n = e.subflow, i = e.field, r = (s) => this.subflow(le(s), n, t, s);
    return (e.modified("field") || i && t.modified(nn(i))) && j("PreFacet does not support field modification."), this.initTargets(), i ? (t.visit(t.MOD, (s) => {
      const o = r(s);
      i(s).forEach((a) => o.mod(a));
    }), t.visit(t.ADD, (s) => {
      const o = r(s);
      i(s).forEach((a) => o.add(je(a)));
    }), t.visit(t.REM, (s) => {
      const o = r(s);
      i(s).forEach((a) => o.rem(a));
    })) : (t.visit(t.MOD, (s) => r(s).mod(s)), t.visit(t.ADD, (s) => r(s).add(s)), t.visit(t.REM, (s) => r(s).rem(s))), t.clean() && t.runAfter(() => this.clean()), t;
  }
});
function t2(e) {
  I.call(this, null, e);
}
t2.Definition = {
  type: "Project",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "fields",
    type: "field",
    array: !0
  }, {
    name: "as",
    type: "string",
    null: !0,
    array: !0
  }]
};
Y(t2, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE), i = e.fields, r = qT(e.fields, e.as || []), s = i ? (a, l) => LB(a, l, i, r) : Qp;
    let o;
    return this.value ? o = this.value : (t = t.addAll(), o = this.value = {}), t.visit(t.REM, (a) => {
      const l = le(a);
      n.rem.push(o[l]), o[l] = null;
    }), t.visit(t.ADD, (a) => {
      const l = s(a, je({}));
      o[le(a)] = l, n.add.push(l);
    }), t.visit(t.MOD, (a) => {
      n.mod.push(s(a, o[le(a)]));
    }), n;
  }
});
function LB(e, t, n, i) {
  for (let r = 0, s = n.length; r < s; ++r)
    t[i[r]] = n[r](e);
  return t;
}
function e5(e) {
  I.call(this, null, e);
}
Y(e5, I, {
  transform(e, t) {
    return this.value = e.value, e.modified("value") ? t.fork(t.NO_SOURCE | t.NO_FIELDS) : t.StopPropagation;
  }
});
function n2(e) {
  I.call(this, null, e);
}
n2.Definition = {
  type: "Quantile",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "probs",
    type: "number",
    array: !0
  }, {
    name: "step",
    type: "number",
    default: 0.01
  }, {
    name: "as",
    type: "string",
    array: !0,
    default: ["prob", "value"]
  }]
};
const PB = 1e-14;
Y(n2, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = e.as || ["prob", "value"];
    if (this.value && !e.modified() && !t.changed())
      return n.source = this.value, n;
    const r = t.materialize(t.SOURCE).source, s = Ux(r, e.groupby, e.field), o = (e.groupby || []).map(ut), a = [], l = e.step || 0.01, u = e.probs || Jn(l / 2, 1 - PB, l), c = u.length;
    return s.forEach((f) => {
      const d = vx(f, u);
      for (let h = 0; h < c; ++h) {
        const g = {};
        for (let p = 0; p < o.length; ++p)
          g[o[p]] = f.dims[p];
        g[i[0]] = u[h], g[i[1]] = d[h], a.push(je(g));
      }
    }), this.value && (n.rem = this.value), this.value = n.add = n.source = a, n;
  }
});
function t5(e) {
  I.call(this, null, e);
}
Y(t5, I, {
  transform(e, t) {
    let n, i;
    return this.value ? i = this.value : (n = t = t.addAll(), i = this.value = {}), e.derive && (n = t.fork(t.NO_SOURCE), t.visit(t.REM, (r) => {
      const s = le(r);
      n.rem.push(i[s]), i[s] = null;
    }), t.visit(t.ADD, (r) => {
      const s = mx(r);
      i[le(r)] = s, n.add.push(s);
    }), t.visit(t.MOD, (r) => {
      const s = i[le(r)];
      for (const o in r)
        s[o] = r[o], n.modifies(o);
      n.mod.push(s);
    })), n;
  }
});
function i2(e) {
  I.call(this, [], e), this.count = 0;
}
i2.Definition = {
  type: "Sample",
  metadata: {},
  params: [{
    name: "size",
    type: "number",
    default: 1e3
  }]
};
Y(i2, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE), i = e.modified("size"), r = e.size, s = this.value.reduce((c, f) => (c[le(f)] = 1, c), {});
    let o = this.value, a = this.count, l = 0;
    function u(c) {
      let f, d;
      o.length < r ? o.push(c) : (d = ~~((a + 1) * ki()), d < o.length && d >= l && (f = o[d], s[le(f)] && n.rem.push(f), o[d] = c)), ++a;
    }
    if (t.rem.length && (t.visit(t.REM, (c) => {
      const f = le(c);
      s[f] && (s[f] = -1, n.rem.push(c)), --a;
    }), o = o.filter((c) => s[le(c)] !== -1)), (t.rem.length || i) && o.length < r && t.source && (l = a = o.length, t.visit(t.SOURCE, (c) => {
      s[le(c)] || u(c);
    }), l = -1), i && o.length > r) {
      const c = o.length - r;
      for (let f = 0; f < c; ++f)
        s[le(o[f])] = -1, n.rem.push(o[f]);
      o = o.slice(c);
    }
    return t.mod.length && t.visit(t.MOD, (c) => {
      s[le(c)] && n.mod.push(c);
    }), t.add.length && t.visit(t.ADD, u), (t.add.length || l < 0) && (n.add = o.filter((c) => !s[le(c)])), this.count = a, this.value = n.source = o, n;
  }
});
function r2(e) {
  I.call(this, null, e);
}
r2.Definition = {
  type: "Sequence",
  metadata: {
    generates: !0,
    changes: !0
  },
  params: [{
    name: "start",
    type: "number",
    required: !0
  }, {
    name: "stop",
    type: "number",
    required: !0
  }, {
    name: "step",
    type: "number",
    default: 1
  }, {
    name: "as",
    type: "string",
    default: "data"
  }]
};
Y(r2, I, {
  transform(e, t) {
    if (this.value && !e.modified())
      return;
    const n = t.materialize().fork(t.MOD), i = e.as || "data";
    return n.rem = this.value ? t.rem.concat(this.value) : t.rem, this.value = Jn(e.start, e.stop, e.step || 1).map((r) => {
      const s = {};
      return s[i] = r, je(s);
    }), n.add = t.add.concat(this.value), n;
  }
});
function n5(e) {
  I.call(this, null, e), this.modified(!0);
}
Y(n5, I, {
  transform(e, t) {
    return this.value = t.source, t.changed() ? t.fork(t.NO_SOURCE | t.NO_FIELDS) : t.StopPropagation;
  }
});
function s2(e) {
  I.call(this, null, e);
}
const i5 = ["unit0", "unit1"];
s2.Definition = {
  type: "TimeUnit",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field",
    required: !0
  }, {
    name: "interval",
    type: "boolean",
    default: !0
  }, {
    name: "units",
    type: "enum",
    values: ax,
    array: !0
  }, {
    name: "step",
    type: "number",
    default: 1
  }, {
    name: "maxbins",
    type: "number",
    default: 40
  }, {
    name: "extent",
    type: "date",
    array: !0
  }, {
    name: "timezone",
    type: "enum",
    default: "local",
    values: ["local", "utc"]
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: i5
  }]
};
Y(s2, I, {
  transform(e, t) {
    const n = e.field, i = e.interval !== !1, r = e.timezone === "utc", s = this._floor(e, t), o = (r ? ju : Bu)(s.unit).offset, a = e.as || i5, l = a[0], u = a[1], c = s.step;
    let f = s.start || 1 / 0, d = s.stop || -1 / 0, h = t.ADD;
    return (e.modified() || t.changed(t.REM) || t.modified(nn(n))) && (t = t.reflow(!0), h = t.SOURCE, f = 1 / 0, d = -1 / 0), t.visit(h, (g) => {
      const p = n(g);
      let m, y;
      p == null ? (g[l] = null, i && (g[u] = null)) : (g[l] = m = y = s(p), i && (g[u] = y = o(m, c)), m < f && (f = m), y > d && (d = y));
    }), s.start = f, s.stop = d, t.modifies(i ? a : l);
  },
  _floor(e, t) {
    const n = e.timezone === "utc", {
      units: i,
      step: r
    } = e.units ? {
      units: e.units,
      step: e.step || 1
    } : VF({
      extent: e.extent || $r(t.materialize(t.SOURCE).source, e.field),
      maxbins: e.maxbins
    }), s = lx(i), o = this.value || {}, a = (n ? IF : PF)(s, r);
    return a.unit = Te(s), a.units = s, a.step = r, a.start = o.start, a.stop = o.stop, this.value = a;
  }
});
function r5(e) {
  I.call(this, Lu(), e);
}
Y(r5, I, {
  transform(e, t) {
    const n = t.dataflow, i = e.field, r = this.value, s = (a) => r.set(i(a), a);
    let o = !0;
    return e.modified("field") || t.modified(i.fields) ? (r.clear(), t.visit(t.SOURCE, s)) : t.changed() ? (t.visit(t.REM, (a) => r.delete(i(a))), t.visit(t.ADD, s)) : o = !1, this.modified(o), r.empty > n.cleanThreshold && n.runAfter(r.clean), t.fork();
  }
});
function s5(e) {
  I.call(this, null, e);
}
Y(s5, I, {
  transform(e, t) {
    (!this.value || e.modified("field") || e.modified("sort") || t.changed() || e.sort && t.modified(e.sort.fields)) && (this.value = (e.sort ? t.source.slice().sort(el(e.sort)) : t.source).map(e.field));
  }
});
function IB(e, t, n, i) {
  const r = Sf[e](t, n);
  return {
    init: r.init || Xs,
    update: function(s, o) {
      o[i] = r.next(s);
    }
  };
}
const Sf = {
  row_number: function() {
    return {
      next: (e) => e.index + 1
    };
  },
  rank: function() {
    let e;
    return {
      init: () => e = 1,
      next: (t) => {
        const n = t.index, i = t.data;
        return n && t.compare(i[n - 1], i[n]) ? e = n + 1 : e;
      }
    };
  },
  dense_rank: function() {
    let e;
    return {
      init: () => e = 1,
      next: (t) => {
        const n = t.index, i = t.data;
        return n && t.compare(i[n - 1], i[n]) ? ++e : e;
      }
    };
  },
  percent_rank: function() {
    const e = Sf.rank(), t = e.next;
    return {
      init: e.init,
      next: (n) => (t(n) - 1) / (n.data.length - 1)
    };
  },
  cume_dist: function() {
    let e;
    return {
      init: () => e = 0,
      next: (t) => {
        const n = t.data, i = t.compare;
        let r = t.index;
        if (e < r) {
          for (; r + 1 < n.length && !i(n[r], n[r + 1]); )
            ++r;
          e = r;
        }
        return (1 + e) / n.length;
      }
    };
  },
  ntile: function(e, t) {
    t = +t, t > 0 || j("ntile num must be greater than zero.");
    const n = Sf.cume_dist(), i = n.next;
    return {
      init: n.init,
      next: (r) => Math.ceil(t * i(r))
    };
  },
  lag: function(e, t) {
    return t = +t || 1, {
      next: (n) => {
        const i = n.index - t;
        return i >= 0 ? e(n.data[i]) : null;
      }
    };
  },
  lead: function(e, t) {
    return t = +t || 1, {
      next: (n) => {
        const i = n.index + t, r = n.data;
        return i < r.length ? e(r[i]) : null;
      }
    };
  },
  first_value: function(e) {
    return {
      next: (t) => e(t.data[t.i0])
    };
  },
  last_value: function(e) {
    return {
      next: (t) => e(t.data[t.i1 - 1])
    };
  },
  nth_value: function(e, t) {
    return t = +t, t > 0 || j("nth_value nth must be greater than zero."), {
      next: (n) => {
        const i = n.i0 + (t - 1);
        return i < n.i1 ? e(n.data[i]) : null;
      }
    };
  },
  prev_value: function(e) {
    let t;
    return {
      init: () => t = null,
      next: (n) => {
        const i = e(n.data[n.index]);
        return i != null ? t = i : t;
      }
    };
  },
  next_value: function(e) {
    let t, n;
    return {
      init: () => (t = null, n = -1),
      next: (i) => {
        const r = i.data;
        return i.index <= n ? t : (n = zB(e, r, i.index)) < 0 ? (n = r.length, t = null) : t = e(r[n]);
      }
    };
  }
};
function zB(e, t, n) {
  for (let i = t.length; n < i; ++n)
    if (e(t[n]) != null)
      return n;
  return -1;
}
const BB = Object.keys(Sf);
function o5(e) {
  const t = ee(e.ops), n = ee(e.fields), i = ee(e.params), r = ee(e.aggregate_params), s = ee(e.as), o = this.outputs = [], a = this.windows = [], l = {}, u = {}, c = [], f = [];
  let d = !0;
  function h(g) {
    ee(nn(g)).forEach((p) => l[p] = 1);
  }
  h(e.sort), t.forEach((g, p) => {
    const m = n[p], y = i[p], b = r[p] || null, v = ut(m), _ = RT(g, v, s[p]);
    if (h(m), o.push(_), ce(Sf, g))
      a.push(IB(g, m, y, _));
    else {
      if (m == null && g !== "count" && j("Null aggregate field specified."), g === "count") {
        c.push(_);
        return;
      }
      d = !1;
      let x = u[v];
      x || (x = u[v] = [], x.field = m, f.push(x)), x.push(LT(g, b, _));
    }
  }), (c.length || f.length) && (this.cell = jB(f, c, d)), this.inputs = Object.keys(l);
}
const a5 = o5.prototype;
a5.init = function() {
  this.windows.forEach((e) => e.init()), this.cell && this.cell.init();
};
a5.update = function(e, t) {
  const n = this.cell, i = this.windows, r = e.data, s = i && i.length;
  let o;
  if (n) {
    for (o = e.p0; o < e.i0; ++o)
      n.rem(r[o]);
    for (o = e.p1; o < e.i1; ++o)
      n.add(r[o]);
    n.set(t);
  }
  for (o = 0; o < s; ++o)
    i[o].update(e, t);
};
function jB(e, t, n) {
  e = e.map((l) => IT(l, l.field));
  const i = {
    num: 0,
    agg: null,
    store: !1,
    count: t
  };
  if (!n)
    for (var r = e.length, s = i.agg = Array(r), o = 0; o < r; ++o)
      s[o] = new e[o](i);
  if (i.store)
    var a = i.data = new Lx();
  return i.add = function(l) {
    if (i.num += 1, !n) {
      a && a.add(l);
      for (let u = 0; u < r; ++u)
        s[u].add(s[u].get(l), l);
    }
  }, i.rem = function(l) {
    if (i.num -= 1, !n) {
      a && a.rem(l);
      for (let u = 0; u < r; ++u)
        s[u].rem(s[u].get(l), l);
    }
  }, i.set = function(l) {
    let u, c;
    for (a && a.values(), u = 0, c = t.length; u < c; ++u)
      l[t[u]] = i.num;
    if (!n)
      for (u = 0, c = s.length; u < c; ++u)
        s[u].set(l);
  }, i.init = function() {
    i.num = 0, a && a.reset();
    for (let l = 0; l < r; ++l)
      s[l].init();
  }, i;
}
function o2(e) {
  I.call(this, {}, e), this._mlen = 0, this._mods = [];
}
o2.Definition = {
  type: "Window",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "sort",
    type: "compare"
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "ops",
    type: "enum",
    array: !0,
    values: BB.concat(rd)
  }, {
    name: "params",
    type: "number",
    null: !0,
    array: !0
  }, {
    name: "aggregate_params",
    type: "number",
    null: !0,
    array: !0
  }, {
    name: "fields",
    type: "field",
    null: !0,
    array: !0
  }, {
    name: "as",
    type: "string",
    null: !0,
    array: !0
  }, {
    name: "frame",
    type: "number",
    null: !0,
    array: !0,
    length: 2,
    default: [null, 0]
  }, {
    name: "ignorePeers",
    type: "boolean",
    default: !1
  }]
};
Y(o2, I, {
  transform(e, t) {
    this.stamp = t.stamp;
    const n = e.modified(), i = el(e.sort), r = jy(e.groupby), s = (a) => this.group(r(a));
    let o = this.state;
    (!o || n) && (o = this.state = new o5(e)), n || t.modified(o.inputs) ? (this.value = {}, t.visit(t.SOURCE, (a) => s(a).add(a))) : (t.visit(t.REM, (a) => s(a).remove(a)), t.visit(t.ADD, (a) => s(a).add(a)));
    for (let a = 0, l = this._mlen; a < l; ++a)
      UB(this._mods[a], o, i, e);
    return this._mlen = 0, this._mods = [], t.reflow(n).modifies(o.outputs);
  },
  group(e) {
    let t = this.value[e];
    return t || (t = this.value[e] = zT(le), t.stamp = -1), t.stamp < this.stamp && (t.stamp = this.stamp, this._mods[this._mlen++] = t), t;
  }
});
function UB(e, t, n, i) {
  const r = i.sort, s = r && !i.ignorePeers, o = i.frame || [null, 0], a = e.data(n), l = a.length, u = s ? Pu(r) : null, c = {
    i0: 0,
    i1: 0,
    p0: 0,
    p1: 0,
    index: 0,
    data: a,
    compare: r || ln(-1)
  };
  t.init();
  for (let f = 0; f < l; ++f)
    qB(c, o, f, l), s && WB(c, u), t.update(c, a[f]);
}
function qB(e, t, n, i) {
  e.p0 = e.i0, e.p1 = e.i1, e.i0 = t[0] == null ? 0 : Math.max(0, n - Math.abs(t[0])), e.i1 = t[1] == null ? i : Math.min(i, n + Math.abs(t[1]) + 1), e.index = n;
}
function WB(e, t) {
  const n = e.i0, i = e.i1 - 1, r = e.compare, s = e.data, o = s.length - 1;
  n > 0 && !r(s[n], s[n - 1]) && (e.i0 = t.left(s, s[n])), i < o && !r(s[i], s[i + 1]) && (e.i1 = t.right(s, s[i]));
}
const HB = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  aggregate: go,
  bin: Px,
  collect: Ix,
  compare: BT,
  countpattern: zx,
  cross: Bx,
  density: jx,
  dotbin: qx,
  expression: HT,
  extent: Wx,
  facet: om,
  field: GT,
  filter: Gx,
  flatten: Vx,
  fold: Yx,
  formula: Xx,
  generate: VT,
  impute: Kx,
  joinaggregate: Jx,
  kde: Qx,
  key: YT,
  load: XT,
  lookup: Zx,
  multiextent: KT,
  multivalues: JT,
  params: QT,
  pivot: e2,
  prefacet: ZT,
  project: t2,
  proxy: e5,
  quantile: n2,
  relay: t5,
  sample: i2,
  sequence: r2,
  sieve: n5,
  subflow: Hx,
  timeunit: s2,
  tupleindex: r5,
  values: s5,
  window: o2
}, Symbol.toStringTag, { value: "Module" }));
function Ue(e) {
  return function() {
    return e;
  };
}
const Sk = Math.abs, Vt = Math.atan2, Go = Math.cos, GB = Math.max, o1 = Math.min, cr = Math.sin, ha = Math.sqrt, Xt = 1e-12, su = Math.PI, gg = su / 2, l5 = 2 * su;
function VB(e) {
  return e > 1 ? 0 : e < -1 ? su : Math.acos(e);
}
function kk(e) {
  return e >= 1 ? gg : e <= -1 ? -gg : Math.asin(e);
}
const Uy = Math.PI, qy = 2 * Uy, ra = 1e-6, YB = qy - ra;
function u5(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function XB(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return u5;
  const n = 10 ** t;
  return function(i) {
    this._ += i[0];
    for (let r = 1, s = i.length; r < s; ++r)
      this._ += Math.round(arguments[r] * n) / n + i[r];
  };
}
let a2 = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? u5 : XB(t);
  }
  moveTo(t, n) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
  }
  lineTo(t, n) {
    this._append`L${this._x1 = +t},${this._y1 = +n}`;
  }
  quadraticCurveTo(t, n, i, r) {
    this._append`Q${+t},${+n},${this._x1 = +i},${this._y1 = +r}`;
  }
  bezierCurveTo(t, n, i, r, s, o) {
    this._append`C${+t},${+n},${+i},${+r},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, i, r, s) {
    if (t = +t, n = +n, i = +i, r = +r, s = +s, s < 0)
      throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, l = i - t, u = r - n, c = o - t, f = a - n, d = c * c + f * f;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (d > ra)
      if (!(Math.abs(f * l - u * c) > ra) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let h = i - o, g = r - a, p = l * l + u * u, m = h * h + g * g, y = Math.sqrt(p), b = Math.sqrt(d), v = s * Math.tan((Uy - Math.acos((p + d - m) / (2 * y * b))) / 2), _ = v / b, x = v / y;
        Math.abs(_ - 1) > ra && this._append`L${t + _ * c},${n + _ * f}`, this._append`A${s},${s},0,0,${+(f * h > c * g)},${this._x1 = t + x * l},${this._y1 = n + x * u}`;
      }
  }
  arc(t, n, i, r, s, o) {
    if (t = +t, n = +n, i = +i, o = !!o, i < 0)
      throw new Error(`negative radius: ${i}`);
    let a = i * Math.cos(r), l = i * Math.sin(r), u = t + a, c = n + l, f = 1 ^ o, d = o ? r - s : s - r;
    this._x1 === null ? this._append`M${u},${c}` : (Math.abs(this._x1 - u) > ra || Math.abs(this._y1 - c) > ra) && this._append`L${u},${c}`, i && (d < 0 && (d = d % qy + qy), d > YB ? this._append`A${i},${i},0,1,${f},${t - a},${n - l}A${i},${i},0,1,${f},${this._x1 = u},${this._y1 = c}` : d > ra && this._append`A${i},${i},0,${+(d >= Uy)},${f},${this._x1 = t + i * Math.cos(s)},${this._y1 = n + i * Math.sin(s)}`);
  }
  rect(t, n, i, r) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${i = +i}v${+r}h${-i}Z`;
  }
  toString() {
    return this._;
  }
};
function am() {
  return new a2();
}
am.prototype = a2.prototype;
function lm(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length)
      return t;
    if (n == null)
      t = null;
    else {
      const i = Math.floor(n);
      if (!(i >= 0))
        throw new RangeError(`invalid digits: ${n}`);
      t = i;
    }
    return e;
  }, () => new a2(t);
}
function KB(e) {
  return e.innerRadius;
}
function JB(e) {
  return e.outerRadius;
}
function QB(e) {
  return e.startAngle;
}
function ZB(e) {
  return e.endAngle;
}
function ej(e) {
  return e && e.padAngle;
}
function tj(e, t, n, i, r, s, o, a) {
  var l = n - e, u = i - t, c = o - r, f = a - s, d = f * l - c * u;
  if (!(d * d < Xt))
    return d = (c * (t - s) - f * (e - r)) / d, [e + d * l, t + d * u];
}
function Xd(e, t, n, i, r, s, o) {
  var a = e - n, l = t - i, u = (o ? s : -s) / ha(a * a + l * l), c = u * l, f = -u * a, d = e + c, h = t + f, g = n + c, p = i + f, m = (d + g) / 2, y = (h + p) / 2, b = g - d, v = p - h, _ = b * b + v * v, x = r - s, S = d * p - g * h, E = (v < 0 ? -1 : 1) * ha(GB(0, x * x * _ - S * S)), C = (S * v - b * E) / _, $ = (-S * b - v * E) / _, N = (S * v + b * E) / _, O = (-S * b + v * E) / _, P = C - m, T = $ - y, D = N - m, M = O - y;
  return P * P + T * T > D * D + M * M && (C = N, $ = O), {
    cx: C,
    cy: $,
    x01: -c,
    y01: -f,
    x11: C * (r / x - 1),
    y11: $ * (r / x - 1)
  };
}
function nj() {
  var e = KB, t = JB, n = Ue(0), i = null, r = QB, s = ZB, o = ej, a = null, l = lm(u);
  function u() {
    var c, f, d = +e.apply(this, arguments), h = +t.apply(this, arguments), g = r.apply(this, arguments) - gg, p = s.apply(this, arguments) - gg, m = Sk(p - g), y = p > g;
    if (a || (a = c = l()), h < d && (f = h, h = d, d = f), !(h > Xt))
      a.moveTo(0, 0);
    else if (m > l5 - Xt)
      a.moveTo(h * Go(g), h * cr(g)), a.arc(0, 0, h, g, p, !y), d > Xt && (a.moveTo(d * Go(p), d * cr(p)), a.arc(0, 0, d, p, g, y));
    else {
      var b = g, v = p, _ = g, x = p, S = m, E = m, C = o.apply(this, arguments) / 2, $ = C > Xt && (i ? +i.apply(this, arguments) : ha(d * d + h * h)), N = o1(Sk(h - d) / 2, +n.apply(this, arguments)), O = N, P = N, T, D;
      if ($ > Xt) {
        var M = kk($ / d * cr(C)), w = kk($ / h * cr(C));
        (S -= M * 2) > Xt ? (M *= y ? 1 : -1, _ += M, x -= M) : (S = 0, _ = x = (g + p) / 2), (E -= w * 2) > Xt ? (w *= y ? 1 : -1, b += w, v -= w) : (E = 0, b = v = (g + p) / 2);
      }
      var k = h * Go(b), A = h * cr(b), F = d * Go(x), R = d * cr(x);
      if (N > Xt) {
        var L = h * Go(v), V = h * cr(v), K = d * Go(_), Q = d * cr(_), ie;
        if (m < su)
          if (ie = tj(k, A, K, Q, L, V, F, R)) {
            var Le = k - ie[0], Oe = A - ie[1], mt = L - ie[0], Z = V - ie[1], ye = 1 / cr(VB((Le * mt + Oe * Z) / (ha(Le * Le + Oe * Oe) * ha(mt * mt + Z * Z))) / 2), xe = ha(ie[0] * ie[0] + ie[1] * ie[1]);
            O = o1(N, (d - xe) / (ye - 1)), P = o1(N, (h - xe) / (ye + 1));
          } else
            O = P = 0;
      }
      E > Xt ? P > Xt ? (T = Xd(K, Q, k, A, h, P, y), D = Xd(L, V, F, R, h, P, y), a.moveTo(T.cx + T.x01, T.cy + T.y01), P < N ? a.arc(T.cx, T.cy, P, Vt(T.y01, T.x01), Vt(D.y01, D.x01), !y) : (a.arc(T.cx, T.cy, P, Vt(T.y01, T.x01), Vt(T.y11, T.x11), !y), a.arc(0, 0, h, Vt(T.cy + T.y11, T.cx + T.x11), Vt(D.cy + D.y11, D.cx + D.x11), !y), a.arc(D.cx, D.cy, P, Vt(D.y11, D.x11), Vt(D.y01, D.x01), !y))) : (a.moveTo(k, A), a.arc(0, 0, h, b, v, !y)) : a.moveTo(k, A), !(d > Xt) || !(S > Xt) ? a.lineTo(F, R) : O > Xt ? (T = Xd(F, R, L, V, d, -O, y), D = Xd(k, A, K, Q, d, -O, y), a.lineTo(T.cx + T.x01, T.cy + T.y01), O < N ? a.arc(T.cx, T.cy, O, Vt(T.y01, T.x01), Vt(D.y01, D.x01), !y) : (a.arc(T.cx, T.cy, O, Vt(T.y01, T.x01), Vt(T.y11, T.x11), !y), a.arc(0, 0, d, Vt(T.cy + T.y11, T.cx + T.x11), Vt(D.cy + D.y11, D.cx + D.x11), y), a.arc(D.cx, D.cy, O, Vt(D.y11, D.x11), Vt(D.y01, D.x01), !y))) : a.arc(0, 0, d, x, _, y);
    }
    if (a.closePath(), c)
      return a = null, c + "" || null;
  }
  return u.centroid = function() {
    var c = (+e.apply(this, arguments) + +t.apply(this, arguments)) / 2, f = (+r.apply(this, arguments) + +s.apply(this, arguments)) / 2 - su / 2;
    return [Go(f) * c, cr(f) * c];
  }, u.innerRadius = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : Ue(+c), u) : e;
  }, u.outerRadius = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : Ue(+c), u) : t;
  }, u.cornerRadius = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : Ue(+c), u) : n;
  }, u.padRadius = function(c) {
    return arguments.length ? (i = c == null ? null : typeof c == "function" ? c : Ue(+c), u) : i;
  }, u.startAngle = function(c) {
    return arguments.length ? (r = typeof c == "function" ? c : Ue(+c), u) : r;
  }, u.endAngle = function(c) {
    return arguments.length ? (s = typeof c == "function" ? c : Ue(+c), u) : s;
  }, u.padAngle = function(c) {
    return arguments.length ? (o = typeof c == "function" ? c : Ue(+c), u) : o;
  }, u.context = function(c) {
    return arguments.length ? (a = c ?? null, u) : a;
  }, u;
}
function c5(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function f5(e) {
  this._context = e;
}
f5.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
      default:
        this._context.lineTo(e, t);
        break;
    }
  }
};
function l2(e) {
  return new f5(e);
}
function d5(e) {
  return e[0];
}
function h5(e) {
  return e[1];
}
function g5(e, t) {
  var n = Ue(!0), i = null, r = l2, s = null, o = lm(a);
  e = typeof e == "function" ? e : e === void 0 ? d5 : Ue(e), t = typeof t == "function" ? t : t === void 0 ? h5 : Ue(t);
  function a(l) {
    var u, c = (l = c5(l)).length, f, d = !1, h;
    for (i == null && (s = r(h = o())), u = 0; u <= c; ++u)
      !(u < c && n(f = l[u], u, l)) === d && ((d = !d) ? s.lineStart() : s.lineEnd()), d && s.point(+e(f, u, l), +t(f, u, l));
    if (h)
      return s = null, h + "" || null;
  }
  return a.x = function(l) {
    return arguments.length ? (e = typeof l == "function" ? l : Ue(+l), a) : e;
  }, a.y = function(l) {
    return arguments.length ? (t = typeof l == "function" ? l : Ue(+l), a) : t;
  }, a.defined = function(l) {
    return arguments.length ? (n = typeof l == "function" ? l : Ue(!!l), a) : n;
  }, a.curve = function(l) {
    return arguments.length ? (r = l, i != null && (s = r(i)), a) : r;
  }, a.context = function(l) {
    return arguments.length ? (l == null ? i = s = null : s = r(i = l), a) : i;
  }, a;
}
function p5(e, t, n) {
  var i = null, r = Ue(!0), s = null, o = l2, a = null, l = lm(u);
  e = typeof e == "function" ? e : e === void 0 ? d5 : Ue(+e), t = typeof t == "function" ? t : Ue(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? h5 : Ue(+n);
  function u(f) {
    var d, h, g, p = (f = c5(f)).length, m, y = !1, b, v = new Array(p), _ = new Array(p);
    for (s == null && (a = o(b = l())), d = 0; d <= p; ++d) {
      if (!(d < p && r(m = f[d], d, f)) === y)
        if (y = !y)
          h = d, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), g = d - 1; g >= h; --g)
            a.point(v[g], _[g]);
          a.lineEnd(), a.areaEnd();
        }
      y && (v[d] = +e(m, d, f), _[d] = +t(m, d, f), a.point(i ? +i(m, d, f) : v[d], n ? +n(m, d, f) : _[d]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function c() {
    return g5().defined(r).curve(o).context(s);
  }
  return u.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ue(+f), i = null, u) : e;
  }, u.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ue(+f), u) : e;
  }, u.x1 = function(f) {
    return arguments.length ? (i = f == null ? null : typeof f == "function" ? f : Ue(+f), u) : i;
  }, u.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ue(+f), n = null, u) : t;
  }, u.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ue(+f), u) : t;
  }, u.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : Ue(+f), u) : n;
  }, u.lineX0 = u.lineY0 = function() {
    return c().x(e).y(t);
  }, u.lineY1 = function() {
    return c().x(e).y(n);
  }, u.lineX1 = function() {
    return c().x(i).y(t);
  }, u.defined = function(f) {
    return arguments.length ? (r = typeof f == "function" ? f : Ue(!!f), u) : r;
  }, u.curve = function(f) {
    return arguments.length ? (o = f, s != null && (a = o(s)), u) : o;
  }, u.context = function(f) {
    return arguments.length ? (f == null ? s = a = null : a = o(s = f), u) : s;
  }, u;
}
const ij = {
  draw(e, t) {
    const n = ha(t / su);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, l5);
  }
};
function rj(e, t) {
  let n = null, i = lm(r);
  e = typeof e == "function" ? e : Ue(e || ij), t = typeof t == "function" ? t : Ue(t === void 0 ? 64 : +t);
  function r() {
    let s;
    if (n || (n = s = i()), e.apply(this, arguments).draw(n, +t.apply(this, arguments)), s)
      return n = null, s + "" || null;
  }
  return r.type = function(s) {
    return arguments.length ? (e = typeof s == "function" ? s : Ue(s), r) : e;
  }, r.size = function(s) {
    return arguments.length ? (t = typeof s == "function" ? s : Ue(+s), r) : t;
  }, r.context = function(s) {
    return arguments.length ? (n = s ?? null, r) : n;
  }, r;
}
function po() {
}
function pg(e, t, n) {
  e._context.bezierCurveTo(
    (2 * e._x0 + e._x1) / 3,
    (2 * e._y0 + e._y1) / 3,
    (e._x0 + 2 * e._x1) / 3,
    (e._y0 + 2 * e._y1) / 3,
    (e._x0 + 4 * e._x1 + t) / 6,
    (e._y0 + 4 * e._y1 + n) / 6
  );
}
function um(e) {
  this._context = e;
}
um.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 3:
        pg(this, this._x1, this._y1);
      case 2:
        this._context.lineTo(this._x1, this._y1);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
      default:
        pg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function sj(e) {
  return new um(e);
}
function m5(e) {
  this._context = e;
}
m5.prototype = {
  areaStart: po,
  areaEnd: po,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x2, this._y2), this._context.closePath();
        break;
      }
      case 2: {
        this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3), this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x2, this._y2), this.point(this._x3, this._y3), this.point(this._x4, this._y4);
        break;
      }
    }
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._x2 = e, this._y2 = t;
        break;
      case 1:
        this._point = 2, this._x3 = e, this._y3 = t;
        break;
      case 2:
        this._point = 3, this._x4 = e, this._y4 = t, this._context.moveTo((this._x0 + 4 * this._x1 + e) / 6, (this._y0 + 4 * this._y1 + t) / 6);
        break;
      default:
        pg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function oj(e) {
  return new m5(e);
}
function y5(e) {
  this._context = e;
}
y5.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
        var n = (this._x0 + 4 * this._x1 + e) / 6, i = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, i) : this._context.moveTo(n, i);
        break;
      case 3:
        this._point = 4;
      default:
        pg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function aj(e) {
  return new y5(e);
}
function b5(e, t) {
  this._basis = new um(e), this._beta = t;
}
b5.prototype = {
  lineStart: function() {
    this._x = [], this._y = [], this._basis.lineStart();
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length - 1;
    if (n > 0)
      for (var i = e[0], r = t[0], s = e[n] - i, o = t[n] - r, a = -1, l; ++a <= n; )
        l = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (i + l * s),
          this._beta * t[a] + (1 - this._beta) * (r + l * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const lj = function e(t) {
  function n(i) {
    return t === 1 ? new um(i) : new b5(i, t);
  }
  return n.beta = function(i) {
    return e(+i);
  }, n;
}(0.85);
function mg(e, t, n) {
  e._context.bezierCurveTo(
    e._x1 + e._k * (e._x2 - e._x0),
    e._y1 + e._k * (e._y2 - e._y0),
    e._x2 + e._k * (e._x1 - t),
    e._y2 + e._k * (e._y1 - n),
    e._x2,
    e._y2
  );
}
function u2(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
u2.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        mg(this, this._x1, this._y1);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2, this._x1 = e, this._y1 = t;
        break;
      case 2:
        this._point = 3;
      default:
        mg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const uj = function e(t) {
  function n(i) {
    return new u2(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function c2(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
c2.prototype = {
  areaStart: po,
  areaEnd: po,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        mg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const cj = function e(t) {
  function n(i) {
    return new c2(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function f2(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
f2.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        mg(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const fj = function e(t) {
  function n(i) {
    return new f2(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function d2(e, t, n) {
  var i = e._x1, r = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > Xt) {
    var a = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, l = 3 * e._l01_a * (e._l01_a + e._l12_a);
    i = (i * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / l, r = (r * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / l;
  }
  if (e._l23_a > Xt) {
    var u = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, c = 3 * e._l23_a * (e._l23_a + e._l12_a);
    s = (s * u + e._x1 * e._l23_2a - t * e._l12_2a) / c, o = (o * u + e._y1 * e._l23_2a - n * e._l12_2a) / c;
  }
  e._context.bezierCurveTo(i, r, s, o, e._x2, e._y2);
}
function v5(e, t) {
  this._context = e, this._alpha = t;
}
v5.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        this.point(this._x2, this._y2);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
      default:
        d2(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const dj = function e(t) {
  function n(i) {
    return t ? new v5(i, t) : new u2(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function x5(e, t) {
  this._context = e, this._alpha = t;
}
x5.prototype = {
  areaStart: po,
  areaEnd: po,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        d2(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const hj = function e(t) {
  function n(i) {
    return t ? new x5(i, t) : new c2(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function w5(e, t) {
  this._context = e, this._alpha = t;
}
w5.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        d2(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const gj = function e(t) {
  function n(i) {
    return t ? new w5(i, t) : new f2(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function _5(e) {
  this._context = e;
}
_5.prototype = {
  areaStart: po,
  areaEnd: po,
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    this._point && this._context.closePath();
  },
  point: function(e, t) {
    e = +e, t = +t, this._point ? this._context.lineTo(e, t) : (this._point = 1, this._context.moveTo(e, t));
  }
};
function pj(e) {
  return new _5(e);
}
function Ak(e) {
  return e < 0 ? -1 : 1;
}
function Ck(e, t, n) {
  var i = e._x1 - e._x0, r = t - e._x1, s = (e._y1 - e._y0) / (i || r < 0 && -0), o = (n - e._y1) / (r || i < 0 && -0), a = (s * r + o * i) / (i + r);
  return (Ak(s) + Ak(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function $k(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function a1(e, t, n) {
  var i = e._x0, r = e._y0, s = e._x1, o = e._y1, a = (s - i) / 3;
  e._context.bezierCurveTo(i + a, r + a * t, s - a, o - a * n, s, o);
}
function yg(e) {
  this._context = e;
}
yg.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x1, this._y1);
        break;
      case 3:
        a1(this, this._t0, $k(this, this._t0));
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    var n = NaN;
    if (e = +e, t = +t, !(e === this._x1 && t === this._y1)) {
      switch (this._point) {
        case 0:
          this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
          break;
        case 1:
          this._point = 2;
          break;
        case 2:
          this._point = 3, a1(this, $k(this, n = Ck(this, e, t)), n);
          break;
        default:
          a1(this, this._t0, n = Ck(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function E5(e) {
  this._context = new S5(e);
}
(E5.prototype = Object.create(yg.prototype)).point = function(e, t) {
  yg.prototype.point.call(this, t, e);
};
function S5(e) {
  this._context = e;
}
S5.prototype = {
  moveTo: function(e, t) {
    this._context.moveTo(t, e);
  },
  closePath: function() {
    this._context.closePath();
  },
  lineTo: function(e, t) {
    this._context.lineTo(t, e);
  },
  bezierCurveTo: function(e, t, n, i, r, s) {
    this._context.bezierCurveTo(t, e, i, n, s, r);
  }
};
function mj(e) {
  return new yg(e);
}
function yj(e) {
  return new E5(e);
}
function k5(e) {
  this._context = e;
}
k5.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = [], this._y = [];
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length;
    if (n)
      if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), n === 2)
        this._context.lineTo(e[1], t[1]);
      else
        for (var i = Mk(e), r = Mk(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(i[0][s], r[0][s], i[1][s], r[1][s], e[o], t[o]);
    (this._line || this._line !== 0 && n === 1) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null;
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
function Mk(e) {
  var t, n = e.length - 1, i, r = new Array(n), s = new Array(n), o = new Array(n);
  for (r[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t)
    r[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (r[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t)
    i = r[t] / s[t - 1], s[t] -= i, o[t] -= i * o[t - 1];
  for (r[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t)
    r[t] = (o[t] - r[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + r[n - 1]) / 2, t = 0; t < n - 1; ++t)
    s[t] = 2 * e[t + 1] - r[t + 1];
  return [r, s];
}
function bj(e) {
  return new k5(e);
}
function cm(e, t) {
  this._context = e, this._t = t;
}
cm.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = this._y = NaN, this._point = 0;
  },
  lineEnd: function() {
    0 < this._t && this._t < 1 && this._point === 2 && this._context.lineTo(this._x, this._y), (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
      default: {
        if (this._t <= 0)
          this._context.lineTo(this._x, t), this._context.lineTo(e, t);
        else {
          var n = this._x * (1 - this._t) + e * this._t;
          this._context.lineTo(n, this._y), this._context.lineTo(n, t);
        }
        break;
      }
    }
    this._x = e, this._y = t;
  }
};
function vj(e) {
  return new cm(e, 0.5);
}
function xj(e) {
  return new cm(e, 0);
}
function wj(e) {
  return new cm(e, 1);
}
function lo(e, t) {
  if (typeof document < "u" && document.createElement) {
    const n = document.createElement("canvas");
    if (n && n.getContext)
      return n.width = e, n.height = t, n;
  }
  return null;
}
const _j = () => typeof Image < "u" ? Image : null;
function Ir(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function Oo(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1: {
      typeof e == "function" ? this.interpolator(e) : this.range(e);
      break;
    }
    default: {
      this.domain(e), typeof t == "function" ? this.interpolator(t) : this.range(t);
      break;
    }
  }
  return this;
}
const Wy = Symbol("implicit");
function h2() {
  var e = new GS(), t = [], n = [], i = Wy;
  function r(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (i !== Wy)
        return i;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return r.domain = function(s) {
    if (!arguments.length)
      return t.slice();
    t = [], e = new GS();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return r;
  }, r.range = function(s) {
    return arguments.length ? (n = Array.from(s), r) : n.slice();
  }, r.unknown = function(s) {
    return arguments.length ? (i = s, r) : i;
  }, r.copy = function() {
    return h2(t, n).unknown(i);
  }, Ir.apply(r, arguments), r;
}
function qu(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function sd(e, t) {
  var n = Object.create(e.prototype);
  for (var i in t)
    n[i] = t[i];
  return n;
}
function No() {
}
var Ma = 0.7, ou = 1 / Ma, Ul = "\\s*([+-]?\\d+)\\s*", kf = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", wr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Ej = /^#([0-9a-f]{3,8})$/, Sj = new RegExp(`^rgb\\(${Ul},${Ul},${Ul}\\)$`), kj = new RegExp(`^rgb\\(${wr},${wr},${wr}\\)$`), Aj = new RegExp(`^rgba\\(${Ul},${Ul},${Ul},${kf}\\)$`), Cj = new RegExp(`^rgba\\(${wr},${wr},${wr},${kf}\\)$`), $j = new RegExp(`^hsl\\(${kf},${wr},${wr}\\)$`), Mj = new RegExp(`^hsla\\(${kf},${wr},${wr},${kf}\\)$`), Fk = {
  aliceblue: 15792383,
  antiquewhite: 16444375,
  aqua: 65535,
  aquamarine: 8388564,
  azure: 15794175,
  beige: 16119260,
  bisque: 16770244,
  black: 0,
  blanchedalmond: 16772045,
  blue: 255,
  blueviolet: 9055202,
  brown: 10824234,
  burlywood: 14596231,
  cadetblue: 6266528,
  chartreuse: 8388352,
  chocolate: 13789470,
  coral: 16744272,
  cornflowerblue: 6591981,
  cornsilk: 16775388,
  crimson: 14423100,
  cyan: 65535,
  darkblue: 139,
  darkcyan: 35723,
  darkgoldenrod: 12092939,
  darkgray: 11119017,
  darkgreen: 25600,
  darkgrey: 11119017,
  darkkhaki: 12433259,
  darkmagenta: 9109643,
  darkolivegreen: 5597999,
  darkorange: 16747520,
  darkorchid: 10040012,
  darkred: 9109504,
  darksalmon: 15308410,
  darkseagreen: 9419919,
  darkslateblue: 4734347,
  darkslategray: 3100495,
  darkslategrey: 3100495,
  darkturquoise: 52945,
  darkviolet: 9699539,
  deeppink: 16716947,
  deepskyblue: 49151,
  dimgray: 6908265,
  dimgrey: 6908265,
  dodgerblue: 2003199,
  firebrick: 11674146,
  floralwhite: 16775920,
  forestgreen: 2263842,
  fuchsia: 16711935,
  gainsboro: 14474460,
  ghostwhite: 16316671,
  gold: 16766720,
  goldenrod: 14329120,
  gray: 8421504,
  green: 32768,
  greenyellow: 11403055,
  grey: 8421504,
  honeydew: 15794160,
  hotpink: 16738740,
  indianred: 13458524,
  indigo: 4915330,
  ivory: 16777200,
  khaki: 15787660,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  lightgoldenrodyellow: 16448210,
  lightgray: 13882323,
  lightgreen: 9498256,
  lightgrey: 13882323,
  lightpink: 16758465,
  lightsalmon: 16752762,
  lightseagreen: 2142890,
  lightskyblue: 8900346,
  lightslategray: 7833753,
  lightslategrey: 7833753,
  lightsteelblue: 11584734,
  lightyellow: 16777184,
  lime: 65280,
  limegreen: 3329330,
  linen: 16445670,
  magenta: 16711935,
  maroon: 8388608,
  mediumaquamarine: 6737322,
  mediumblue: 205,
  mediumorchid: 12211667,
  mediumpurple: 9662683,
  mediumseagreen: 3978097,
  mediumslateblue: 8087790,
  mediumspringgreen: 64154,
  mediumturquoise: 4772300,
  mediumvioletred: 13047173,
  midnightblue: 1644912,
  mintcream: 16121850,
  mistyrose: 16770273,
  moccasin: 16770229,
  navajowhite: 16768685,
  navy: 128,
  oldlace: 16643558,
  olive: 8421376,
  olivedrab: 7048739,
  orange: 16753920,
  orangered: 16729344,
  orchid: 14315734,
  palegoldenrod: 15657130,
  palegreen: 10025880,
  paleturquoise: 11529966,
  palevioletred: 14381203,
  papayawhip: 16773077,
  peachpuff: 16767673,
  peru: 13468991,
  pink: 16761035,
  plum: 14524637,
  powderblue: 11591910,
  purple: 8388736,
  rebeccapurple: 6697881,
  red: 16711680,
  rosybrown: 12357519,
  royalblue: 4286945,
  saddlebrown: 9127187,
  salmon: 16416882,
  sandybrown: 16032864,
  seagreen: 3050327,
  seashell: 16774638,
  sienna: 10506797,
  silver: 12632256,
  skyblue: 8900331,
  slateblue: 6970061,
  slategray: 7372944,
  slategrey: 7372944,
  snow: 16775930,
  springgreen: 65407,
  steelblue: 4620980,
  tan: 13808780,
  teal: 32896,
  thistle: 14204888,
  tomato: 16737095,
  turquoise: 4251856,
  violet: 15631086,
  wheat: 16113331,
  white: 16777215,
  whitesmoke: 16119285,
  yellow: 16776960,
  yellowgreen: 10145074
};
qu(No, Af, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: Tk,
  // Deprecated! Use color.formatHex.
  formatHex: Tk,
  formatHex8: Fj,
  formatHsl: Tj,
  formatRgb: Ok,
  toString: Ok
});
function Tk() {
  return this.rgb().formatHex();
}
function Fj() {
  return this.rgb().formatHex8();
}
function Tj() {
  return A5(this).formatHsl();
}
function Ok() {
  return this.rgb().formatRgb();
}
function Af(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = Ej.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? Nk(t) : n === 3 ? new Mt(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? Kd(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? Kd(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = Sj.exec(e)) ? new Mt(t[1], t[2], t[3], 1) : (t = kj.exec(e)) ? new Mt(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = Aj.exec(e)) ? Kd(t[1], t[2], t[3], t[4]) : (t = Cj.exec(e)) ? Kd(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = $j.exec(e)) ? Lk(t[1], t[2] / 100, t[3] / 100, 1) : (t = Mj.exec(e)) ? Lk(t[1], t[2] / 100, t[3] / 100, t[4]) : Fk.hasOwnProperty(e) ? Nk(Fk[e]) : e === "transparent" ? new Mt(NaN, NaN, NaN, 0) : null;
}
function Nk(e) {
  return new Mt(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function Kd(e, t, n, i) {
  return i <= 0 && (e = t = n = NaN), new Mt(e, t, n, i);
}
function g2(e) {
  return e instanceof No || (e = Af(e)), e ? (e = e.rgb(), new Mt(e.r, e.g, e.b, e.opacity)) : new Mt();
}
function mo(e, t, n, i) {
  return arguments.length === 1 ? g2(e) : new Mt(e, t, n, i ?? 1);
}
function Mt(e, t, n, i) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +i;
}
qu(Mt, mo, sd(No, {
  brighter(e) {
    return e = e == null ? ou : Math.pow(ou, e), new Mt(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ma : Math.pow(Ma, e), new Mt(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new Mt(xa(this.r), xa(this.g), xa(this.b), bg(this.opacity));
  },
  displayable() {
    return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
  },
  hex: Dk,
  // Deprecated! Use color.formatHex.
  formatHex: Dk,
  formatHex8: Oj,
  formatRgb: Rk,
  toString: Rk
}));
function Dk() {
  return `#${ga(this.r)}${ga(this.g)}${ga(this.b)}`;
}
function Oj() {
  return `#${ga(this.r)}${ga(this.g)}${ga(this.b)}${ga((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function Rk() {
  const e = bg(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${xa(this.r)}, ${xa(this.g)}, ${xa(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function bg(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function xa(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function ga(e) {
  return e = xa(e), (e < 16 ? "0" : "") + e.toString(16);
}
function Lk(e, t, n, i) {
  return i <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new ji(e, t, n, i);
}
function A5(e) {
  if (e instanceof ji)
    return new ji(e.h, e.s, e.l, e.opacity);
  if (e instanceof No || (e = Af(e)), !e)
    return new ji();
  if (e instanceof ji)
    return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = Math.min(t, n, i), s = Math.max(t, n, i), o = NaN, a = s - r, l = (s + r) / 2;
  return a ? (t === s ? o = (n - i) / a + (n < i) * 6 : n === s ? o = (i - t) / a + 2 : o = (t - n) / a + 4, a /= l < 0.5 ? s + r : 2 - s - r, o *= 60) : a = l > 0 && l < 1 ? 0 : o, new ji(o, a, l, e.opacity);
}
function vg(e, t, n, i) {
  return arguments.length === 1 ? A5(e) : new ji(e, t, n, i ?? 1);
}
function ji(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
qu(ji, vg, sd(No, {
  brighter(e) {
    return e = e == null ? ou : Math.pow(ou, e), new ji(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ma : Math.pow(Ma, e), new ji(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, i = n + (n < 0.5 ? n : 1 - n) * t, r = 2 * n - i;
    return new Mt(
      l1(e >= 240 ? e - 240 : e + 120, r, i),
      l1(e, r, i),
      l1(e < 120 ? e + 240 : e - 120, r, i),
      this.opacity
    );
  },
  clamp() {
    return new ji(Pk(this.h), Jd(this.s), Jd(this.l), bg(this.opacity));
  },
  displayable() {
    return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
  },
  formatHsl() {
    const e = bg(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${Pk(this.h)}, ${Jd(this.s) * 100}%, ${Jd(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function Pk(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function Jd(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function l1(e, t, n) {
  return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
}
const C5 = Math.PI / 180, $5 = 180 / Math.PI, xg = 18, M5 = 0.96422, F5 = 1, T5 = 0.82521, O5 = 4 / 29, ql = 6 / 29, N5 = 3 * ql * ql, Nj = ql * ql * ql;
function D5(e) {
  if (e instanceof _r)
    return new _r(e.l, e.a, e.b, e.opacity);
  if (e instanceof cs)
    return R5(e);
  e instanceof Mt || (e = g2(e));
  var t = d1(e.r), n = d1(e.g), i = d1(e.b), r = u1((0.2225045 * t + 0.7168786 * n + 0.0606169 * i) / F5), s, o;
  return t === n && n === i ? s = o = r : (s = u1((0.4360747 * t + 0.3850649 * n + 0.1430804 * i) / M5), o = u1((0.0139322 * t + 0.0971045 * n + 0.7141733 * i) / T5)), new _r(116 * r - 16, 500 * (s - r), 200 * (r - o), e.opacity);
}
function wg(e, t, n, i) {
  return arguments.length === 1 ? D5(e) : new _r(e, t, n, i ?? 1);
}
function _r(e, t, n, i) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +i;
}
qu(_r, wg, sd(No, {
  brighter(e) {
    return new _r(this.l + xg * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new _r(this.l - xg * (e ?? 1), this.a, this.b, this.opacity);
  },
  rgb() {
    var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200;
    return t = M5 * c1(t), e = F5 * c1(e), n = T5 * c1(n), new Mt(
      f1(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      f1(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      f1(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function u1(e) {
  return e > Nj ? Math.pow(e, 1 / 3) : e / N5 + O5;
}
function c1(e) {
  return e > ql ? e * e * e : N5 * (e - O5);
}
function f1(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function d1(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function Dj(e) {
  if (e instanceof cs)
    return new cs(e.h, e.c, e.l, e.opacity);
  if (e instanceof _r || (e = D5(e)), e.a === 0 && e.b === 0)
    return new cs(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * $5;
  return new cs(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function _g(e, t, n, i) {
  return arguments.length === 1 ? Dj(e) : new cs(e, t, n, i ?? 1);
}
function cs(e, t, n, i) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +i;
}
function R5(e) {
  if (isNaN(e.h))
    return new _r(e.l, 0, 0, e.opacity);
  var t = e.h * C5;
  return new _r(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
qu(cs, _g, sd(No, {
  brighter(e) {
    return new cs(this.h, this.c, this.l + xg * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new cs(this.h, this.c, this.l - xg * (e ?? 1), this.opacity);
  },
  rgb() {
    return R5(this).rgb();
  }
}));
var L5 = -0.14861, p2 = 1.78277, m2 = -0.29227, fm = -0.90649, Cf = 1.97294, Ik = Cf * fm, zk = Cf * p2, Bk = p2 * m2 - fm * L5;
function Rj(e) {
  if (e instanceof wa)
    return new wa(e.h, e.s, e.l, e.opacity);
  e instanceof Mt || (e = g2(e));
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = (Bk * i + Ik * t - zk * n) / (Bk + Ik - zk), s = i - r, o = (Cf * (n - r) - m2 * s) / fm, a = Math.sqrt(o * o + s * s) / (Cf * r * (1 - r)), l = a ? Math.atan2(o, s) * $5 - 120 : NaN;
  return new wa(l < 0 ? l + 360 : l, a, r, e.opacity);
}
function Hy(e, t, n, i) {
  return arguments.length === 1 ? Rj(e) : new wa(e, t, n, i ?? 1);
}
function wa(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
qu(wa, Hy, sd(No, {
  brighter(e) {
    return e = e == null ? ou : Math.pow(ou, e), new wa(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ma : Math.pow(Ma, e), new wa(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * C5, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), i = Math.cos(e), r = Math.sin(e);
    return new Mt(
      255 * (t + n * (L5 * i + p2 * r)),
      255 * (t + n * (m2 * i + fm * r)),
      255 * (t + n * (Cf * i)),
      this.opacity
    );
  }
}));
function P5(e, t, n, i, r) {
  var s = e * e, o = s * e;
  return ((1 - 3 * e + 3 * s - o) * t + (4 - 6 * s + 3 * o) * n + (1 + 3 * e + 3 * s - 3 * o) * i + o * r) / 6;
}
function I5(e) {
  var t = e.length - 1;
  return function(n) {
    var i = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), r = e[i], s = e[i + 1], o = i > 0 ? e[i - 1] : 2 * r - s, a = i < t - 1 ? e[i + 2] : 2 * s - r;
    return P5((n - i / t) * t, o, r, s, a);
  };
}
function z5(e) {
  var t = e.length;
  return function(n) {
    var i = Math.floor(((n %= 1) < 0 ? ++n : n) * t), r = e[(i + t - 1) % t], s = e[i % t], o = e[(i + 1) % t], a = e[(i + 2) % t];
    return P5((n - i / t) * t, r, s, o, a);
  };
}
const dm = (e) => () => e;
function B5(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function Lj(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(i) {
    return Math.pow(e + i * t, n);
  };
}
function hm(e, t) {
  var n = t - e;
  return n ? B5(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : dm(isNaN(e) ? t : e);
}
function Pj(e) {
  return (e = +e) == 1 ? Ft : function(t, n) {
    return n - t ? Lj(t, n, e) : dm(isNaN(t) ? n : t);
  };
}
function Ft(e, t) {
  var n = t - e;
  return n ? B5(e, n) : dm(isNaN(e) ? t : e);
}
const Gy = function e(t) {
  var n = Pj(t);
  function i(r, s) {
    var o = n((r = mo(r)).r, (s = mo(s)).r), a = n(r.g, s.g), l = n(r.b, s.b), u = Ft(r.opacity, s.opacity);
    return function(c) {
      return r.r = o(c), r.g = a(c), r.b = l(c), r.opacity = u(c), r + "";
    };
  }
  return i.gamma = e, i;
}(1);
function j5(e) {
  return function(t) {
    var n = t.length, i = new Array(n), r = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = mo(t[o]), i[o] = a.r || 0, r[o] = a.g || 0, s[o] = a.b || 0;
    return i = e(i), r = e(r), s = e(s), a.opacity = 1, function(l) {
      return a.r = i(l), a.g = r(l), a.b = s(l), a + "";
    };
  };
}
var Ij = j5(I5), zj = j5(z5);
function y2(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, i = t.slice(), r;
  return function(s) {
    for (r = 0; r < n; ++r)
      i[r] = e[r] * (1 - s) + t[r] * s;
    return i;
  };
}
function U5(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function Bj(e, t) {
  return (U5(t) ? y2 : q5)(e, t);
}
function q5(e, t) {
  var n = t ? t.length : 0, i = e ? Math.min(n, e.length) : 0, r = new Array(i), s = new Array(n), o;
  for (o = 0; o < i; ++o)
    r[o] = Do(e[o], t[o]);
  for (; o < n; ++o)
    s[o] = t[o];
  return function(a) {
    for (o = 0; o < i; ++o)
      s[o] = r[o](a);
    return s;
  };
}
function W5(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(i) {
    return n.setTime(e * (1 - i) + t * i), n;
  };
}
function zi(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function H5(e, t) {
  var n = {}, i = {}, r;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (r in t)
    r in e ? n[r] = Do(e[r], t[r]) : i[r] = t[r];
  return function(s) {
    for (r in n)
      i[r] = n[r](s);
    return i;
  };
}
var Vy = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, h1 = new RegExp(Vy.source, "g");
function jj(e) {
  return function() {
    return e;
  };
}
function Uj(e) {
  return function(t) {
    return e(t) + "";
  };
}
function G5(e, t) {
  var n = Vy.lastIndex = h1.lastIndex = 0, i, r, s, o = -1, a = [], l = [];
  for (e = e + "", t = t + ""; (i = Vy.exec(e)) && (r = h1.exec(t)); )
    (s = r.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (i = i[0]) === (r = r[0]) ? a[o] ? a[o] += r : a[++o] = r : (a[++o] = null, l.push({ i: o, x: zi(i, r) })), n = h1.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? l[0] ? Uj(l[0].x) : jj(t) : (t = l.length, function(u) {
    for (var c = 0, f; c < t; ++c)
      a[(f = l[c]).i] = f.x(u);
    return a.join("");
  });
}
function Do(e, t) {
  var n = typeof t, i;
  return t == null || n === "boolean" ? dm(t) : (n === "number" ? zi : n === "string" ? (i = Af(t)) ? (t = i, Gy) : G5 : t instanceof Af ? Gy : t instanceof Date ? W5 : U5(t) ? y2 : Array.isArray(t) ? q5 : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? H5 : zi)(e, t);
}
function qj(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
function Wj(e, t) {
  var n = hm(+e, +t);
  return function(i) {
    var r = n(i);
    return r - 360 * Math.floor(r / 360);
  };
}
function od(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var jk = 180 / Math.PI, Yy = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function V5(e, t, n, i, r, s) {
  var o, a, l;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (l = e * n + t * i) && (n -= e * l, i -= t * l), (a = Math.sqrt(n * n + i * i)) && (n /= a, i /= a, l /= a), e * i < t * n && (e = -e, t = -t, l = -l, o = -o), {
    translateX: r,
    translateY: s,
    rotate: Math.atan2(t, e) * jk,
    skewX: Math.atan(l) * jk,
    scaleX: o,
    scaleY: a
  };
}
var Qd;
function Hj(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? Yy : V5(t.a, t.b, t.c, t.d, t.e, t.f);
}
function Gj(e) {
  return e == null || (Qd || (Qd = document.createElementNS("http://www.w3.org/2000/svg", "g")), Qd.setAttribute("transform", e), !(e = Qd.transform.baseVal.consolidate())) ? Yy : (e = e.matrix, V5(e.a, e.b, e.c, e.d, e.e, e.f));
}
function Y5(e, t, n, i) {
  function r(u) {
    return u.length ? u.pop() + " " : "";
  }
  function s(u, c, f, d, h, g) {
    if (u !== f || c !== d) {
      var p = h.push("translate(", null, t, null, n);
      g.push({ i: p - 4, x: zi(u, f) }, { i: p - 2, x: zi(c, d) });
    } else
      (f || d) && h.push("translate(" + f + t + d + n);
  }
  function o(u, c, f, d) {
    u !== c ? (u - c > 180 ? c += 360 : c - u > 180 && (u += 360), d.push({ i: f.push(r(f) + "rotate(", null, i) - 2, x: zi(u, c) })) : c && f.push(r(f) + "rotate(" + c + i);
  }
  function a(u, c, f, d) {
    u !== c ? d.push({ i: f.push(r(f) + "skewX(", null, i) - 2, x: zi(u, c) }) : c && f.push(r(f) + "skewX(" + c + i);
  }
  function l(u, c, f, d, h, g) {
    if (u !== f || c !== d) {
      var p = h.push(r(h) + "scale(", null, ",", null, ")");
      g.push({ i: p - 4, x: zi(u, f) }, { i: p - 2, x: zi(c, d) });
    } else
      (f !== 1 || d !== 1) && h.push(r(h) + "scale(" + f + "," + d + ")");
  }
  return function(u, c) {
    var f = [], d = [];
    return u = e(u), c = e(c), s(u.translateX, u.translateY, c.translateX, c.translateY, f, d), o(u.rotate, c.rotate, f, d), a(u.skewX, c.skewX, f, d), l(u.scaleX, u.scaleY, c.scaleX, c.scaleY, f, d), u = c = null, function(h) {
      for (var g = -1, p = d.length, m; ++g < p; )
        f[(m = d[g]).i] = m.x(h);
      return f.join("");
    };
  };
}
var Vj = Y5(Hj, "px, ", "px)", "deg)"), Yj = Y5(Gj, ", ", ")", ")"), Xj = 1e-12;
function Uk(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function Kj(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function Jj(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const Qj = function e(t, n, i) {
  function r(s, o) {
    var a = s[0], l = s[1], u = s[2], c = o[0], f = o[1], d = o[2], h = c - a, g = f - l, p = h * h + g * g, m, y;
    if (p < Xj)
      y = Math.log(d / u) / t, m = function(E) {
        return [
          a + E * h,
          l + E * g,
          u * Math.exp(t * E * y)
        ];
      };
    else {
      var b = Math.sqrt(p), v = (d * d - u * u + i * p) / (2 * u * n * b), _ = (d * d - u * u - i * p) / (2 * d * n * b), x = Math.log(Math.sqrt(v * v + 1) - v), S = Math.log(Math.sqrt(_ * _ + 1) - _);
      y = (S - x) / t, m = function(E) {
        var C = E * y, $ = Uk(x), N = u / (n * b) * ($ * Jj(t * C + x) - Kj(x));
        return [
          a + N * h,
          l + N * g,
          u * $ / Uk(t * C + x)
        ];
      };
    }
    return m.duration = y * 1e3 * t / Math.SQRT2, m;
  }
  return r.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, l = a * a;
    return e(o, a, l);
  }, r;
}(Math.SQRT2, 2, 4);
function X5(e) {
  return function(t, n) {
    var i = e((t = vg(t)).h, (n = vg(n)).h), r = Ft(t.s, n.s), s = Ft(t.l, n.l), o = Ft(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.s = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const Zj = X5(hm);
var eU = X5(Ft);
function tU(e, t) {
  var n = Ft((e = wg(e)).l, (t = wg(t)).l), i = Ft(e.a, t.a), r = Ft(e.b, t.b), s = Ft(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = i(o), e.b = r(o), e.opacity = s(o), e + "";
  };
}
function K5(e) {
  return function(t, n) {
    var i = e((t = _g(t)).h, (n = _g(n)).h), r = Ft(t.c, n.c), s = Ft(t.l, n.l), o = Ft(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.c = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const nU = K5(hm);
var iU = K5(Ft);
function J5(e) {
  return function t(n) {
    n = +n;
    function i(r, s) {
      var o = e((r = Hy(r)).h, (s = Hy(s)).h), a = Ft(r.s, s.s), l = Ft(r.l, s.l), u = Ft(r.opacity, s.opacity);
      return function(c) {
        return r.h = o(c), r.s = a(c), r.l = l(Math.pow(c, n)), r.opacity = u(c), r + "";
      };
    }
    return i.gamma = t, i;
  }(1);
}
const rU = J5(hm);
var sU = J5(Ft);
function b2(e, t) {
  t === void 0 && (t = e, e = Do);
  for (var n = 0, i = t.length - 1, r = t[0], s = new Array(i < 0 ? 0 : i); n < i; )
    s[n] = e(r, r = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(i - 1, Math.floor(o *= i)));
    return s[a](o - a);
  };
}
function oU(e, t) {
  for (var n = new Array(t), i = 0; i < t; ++i)
    n[i] = e(i / (t - 1));
  return n;
}
const aU = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  interpolate: Do,
  interpolateArray: Bj,
  interpolateBasis: I5,
  interpolateBasisClosed: z5,
  interpolateCubehelix: rU,
  interpolateCubehelixLong: sU,
  interpolateDate: W5,
  interpolateDiscrete: qj,
  interpolateHcl: nU,
  interpolateHclLong: iU,
  interpolateHsl: Zj,
  interpolateHslLong: eU,
  interpolateHue: Wj,
  interpolateLab: tU,
  interpolateNumber: zi,
  interpolateNumberArray: y2,
  interpolateObject: H5,
  interpolateRgb: Gy,
  interpolateRgbBasis: Ij,
  interpolateRgbBasisClosed: zj,
  interpolateRound: od,
  interpolateString: G5,
  interpolateTransformCss: Vj,
  interpolateTransformSvg: Yj,
  interpolateZoom: Qj,
  piecewise: b2,
  quantize: oU
}, Symbol.toStringTag, { value: "Module" }));
function lU(e) {
  return function() {
    return e;
  };
}
function Xy(e) {
  return +e;
}
var qk = [0, 1];
function On(e) {
  return e;
}
function Ky(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : lU(isNaN(t) ? NaN : 0.5);
}
function uU(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(i) {
    return Math.max(e, Math.min(t, i));
  };
}
function cU(e, t, n) {
  var i = e[0], r = e[1], s = t[0], o = t[1];
  return r < i ? (i = Ky(r, i), s = n(o, s)) : (i = Ky(i, r), s = n(s, o)), function(a) {
    return s(i(a));
  };
}
function fU(e, t, n) {
  var i = Math.min(e.length, t.length) - 1, r = new Array(i), s = new Array(i), o = -1;
  for (e[i] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < i; )
    r[o] = Ky(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var l = fo(e, a, 1, i) - 1;
    return s[l](r[l](a));
  };
}
function ad(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function gm() {
  var e = qk, t = qk, n = Do, i, r, s, o = On, a, l, u;
  function c() {
    var d = Math.min(e.length, t.length);
    return o !== On && (o = uU(e[0], e[d - 1])), a = d > 2 ? fU : cU, l = u = null, f;
  }
  function f(d) {
    return d == null || isNaN(d = +d) ? s : (l || (l = a(e.map(i), t, n)))(i(o(d)));
  }
  return f.invert = function(d) {
    return o(r((u || (u = a(t, e.map(i), zi)))(d)));
  }, f.domain = function(d) {
    return arguments.length ? (e = Array.from(d, Xy), c()) : e.slice();
  }, f.range = function(d) {
    return arguments.length ? (t = Array.from(d), c()) : t.slice();
  }, f.rangeRound = function(d) {
    return t = Array.from(d), n = od, c();
  }, f.clamp = function(d) {
    return arguments.length ? (o = d ? !0 : On, c()) : o !== On;
  }, f.interpolate = function(d) {
    return arguments.length ? (n = d, c()) : n;
  }, f.unknown = function(d) {
    return arguments.length ? (s = d, f) : s;
  }, function(d, h) {
    return i = d, r = h, c();
  };
}
function Q5() {
  return gm()(On, On);
}
function Z5(e, t, n, i) {
  var r = ho(e, t, n), s;
  switch (i = $a(i ?? ",f"), i.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return i.precision == null && !isNaN(s = kF(r, o)) && (i.precision = s), sx(i, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      i.precision == null && !isNaN(s = AF(r, Math.max(Math.abs(e), Math.abs(t)))) && (i.precision = s - (i.type === "e"));
      break;
    }
    case "f":
    case "%": {
      i.precision == null && !isNaN(s = SF(r)) && (i.precision = s - (i.type === "%") * 2);
      break;
    }
  }
  return qp(i);
}
function nl(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var i = t();
    return $y(i[0], i[i.length - 1], n ?? 10);
  }, e.tickFormat = function(n, i) {
    var r = t();
    return Z5(r[0], r[r.length - 1], n ?? 10, i);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var i = t(), r = 0, s = i.length - 1, o = i[r], a = i[s], l, u, c = 10;
    for (a < o && (u = o, o = a, a = u, u = r, r = s, s = u); c-- > 0; ) {
      if (u = My(o, a, n), u === l)
        return i[r] = o, i[s] = a, t(i);
      if (u > 0)
        o = Math.floor(o / u) * u, a = Math.ceil(a / u) * u;
      else if (u < 0)
        o = Math.ceil(o * u) / u, a = Math.floor(a * u) / u;
      else
        break;
      l = u;
    }
    return e;
  }, e;
}
function eO() {
  var e = Q5();
  return e.copy = function() {
    return ad(e, eO());
  }, Ir.apply(e, arguments), nl(e);
}
function tO(e) {
  var t;
  function n(i) {
    return i == null || isNaN(i = +i) ? t : i;
  }
  return n.invert = n, n.domain = n.range = function(i) {
    return arguments.length ? (e = Array.from(i, Xy), n) : e.slice();
  }, n.unknown = function(i) {
    return arguments.length ? (t = i, n) : t;
  }, n.copy = function() {
    return tO(e).unknown(t);
  }, e = arguments.length ? Array.from(e, Xy) : [0, 1], nl(n);
}
function nO(e, t) {
  e = e.slice();
  var n = 0, i = e.length - 1, r = e[n], s = e[i], o;
  return s < r && (o = n, n = i, i = o, o = r, r = s, s = o), e[n] = t.floor(r), e[i] = t.ceil(s), e;
}
function Wk(e) {
  return Math.log(e);
}
function Hk(e) {
  return Math.exp(e);
}
function dU(e) {
  return -Math.log(-e);
}
function hU(e) {
  return -Math.exp(-e);
}
function gU(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function pU(e) {
  return e === 10 ? gU : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function mU(e) {
  return e === Math.E ? Math.log : e === 10 && Math.log10 || e === 2 && Math.log2 || (e = Math.log(e), (t) => Math.log(t) / e);
}
function Gk(e) {
  return (t, n) => -e(-t, n);
}
function v2(e) {
  const t = e(Wk, Hk), n = t.domain;
  let i = 10, r, s;
  function o() {
    return r = mU(i), s = pU(i), n()[0] < 0 ? (r = Gk(r), s = Gk(s), e(dU, hU)) : e(Wk, Hk), t;
  }
  return t.base = function(a) {
    return arguments.length ? (i = +a, o()) : i;
  }, t.domain = function(a) {
    return arguments.length ? (n(a), o()) : n();
  }, t.ticks = (a) => {
    const l = n();
    let u = l[0], c = l[l.length - 1];
    const f = c < u;
    f && ([u, c] = [c, u]);
    let d = r(u), h = r(c), g, p;
    const m = a == null ? 10 : +a;
    let y = [];
    if (!(i % 1) && h - d < m) {
      if (d = Math.floor(d), h = Math.ceil(h), u > 0) {
        for (; d <= h; ++d)
          for (g = 1; g < i; ++g)
            if (p = d < 0 ? g / s(-d) : g * s(d), !(p < u)) {
              if (p > c)
                break;
              y.push(p);
            }
      } else
        for (; d <= h; ++d)
          for (g = i - 1; g >= 1; --g)
            if (p = d > 0 ? g / s(-d) : g * s(d), !(p < u)) {
              if (p > c)
                break;
              y.push(p);
            }
      y.length * 2 < m && (y = $y(u, c, m));
    } else
      y = $y(d, h, Math.min(h - d, m)).map(s);
    return f ? y.reverse() : y;
  }, t.tickFormat = (a, l) => {
    if (a == null && (a = 10), l == null && (l = i === 10 ? "s" : ","), typeof l != "function" && (!(i % 1) && (l = $a(l)).precision == null && (l.trim = !0), l = qp(l)), a === 1 / 0)
      return l;
    const u = Math.max(1, i * a / t.ticks().length);
    return (c) => {
      let f = c / s(Math.round(r(c)));
      return f * i < i - 0.5 && (f *= i), f <= u ? l(c) : "";
    };
  }, t.nice = () => n(nO(n(), {
    floor: (a) => s(Math.floor(r(a))),
    ceil: (a) => s(Math.ceil(r(a)))
  })), t;
}
function iO() {
  const e = v2(gm()).domain([1, 10]);
  return e.copy = () => ad(e, iO()).base(e.base()), Ir.apply(e, arguments), e;
}
function Vk(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function Yk(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function x2(e) {
  var t = 1, n = e(Vk(t), Yk(t));
  return n.constant = function(i) {
    return arguments.length ? e(Vk(t = +i), Yk(t)) : t;
  }, nl(n);
}
function rO() {
  var e = x2(gm());
  return e.copy = function() {
    return ad(e, rO()).constant(e.constant());
  }, Ir.apply(e, arguments);
}
function Xk(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function yU(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function bU(e) {
  return e < 0 ? -e * e : e * e;
}
function w2(e) {
  var t = e(On, On), n = 1;
  function i() {
    return n === 1 ? e(On, On) : n === 0.5 ? e(yU, bU) : e(Xk(n), Xk(1 / n));
  }
  return t.exponent = function(r) {
    return arguments.length ? (n = +r, i()) : n;
  }, nl(t);
}
function _2() {
  var e = w2(gm());
  return e.copy = function() {
    return ad(e, _2()).exponent(e.exponent());
  }, Ir.apply(e, arguments), e;
}
function vU() {
  return _2.apply(null, arguments).exponent(0.5);
}
function sO() {
  var e = [], t = [], n = [], i;
  function r() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; )
      n[o - 1] = bF(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? i : t[fo(n, o)];
  }
  return s.invertExtent = function(o) {
    var a = t.indexOf(o);
    return a < 0 ? [NaN, NaN] : [
      a > 0 ? n[a - 1] : e[0],
      a < n.length ? n[a] : e[e.length - 1]
    ];
  }, s.domain = function(o) {
    if (!arguments.length)
      return e.slice();
    e = [];
    for (let a of o)
      a != null && !isNaN(a = +a) && e.push(a);
    return e.sort(hs), r();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), r()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (i = o, s) : i;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return sO().domain(e).range(t).unknown(i);
  }, Ir.apply(s, arguments);
}
function oO() {
  var e = 0, t = 1, n = 1, i = [0.5], r = [0, 1], s;
  function o(l) {
    return l != null && l <= l ? r[fo(i, l, 0, n)] : s;
  }
  function a() {
    var l = -1;
    for (i = new Array(n); ++l < n; )
      i[l] = ((l + 1) * t - (l - n) * e) / (n + 1);
    return o;
  }
  return o.domain = function(l) {
    return arguments.length ? ([e, t] = l, e = +e, t = +t, a()) : [e, t];
  }, o.range = function(l) {
    return arguments.length ? (n = (r = Array.from(l)).length - 1, a()) : r.slice();
  }, o.invertExtent = function(l) {
    var u = r.indexOf(l);
    return u < 0 ? [NaN, NaN] : u < 1 ? [e, i[0]] : u >= n ? [i[n - 1], t] : [i[u - 1], i[u]];
  }, o.unknown = function(l) {
    return arguments.length && (s = l), o;
  }, o.thresholds = function() {
    return i.slice();
  }, o.copy = function() {
    return oO().domain([e, t]).range(r).unknown(s);
  }, Ir.apply(nl(o), arguments);
}
function aO() {
  var e = [0.5], t = [0, 1], n, i = 1;
  function r(s) {
    return s != null && s <= s ? t[fo(e, s, 0, i)] : n;
  }
  return r.domain = function(s) {
    return arguments.length ? (e = Array.from(s), i = Math.min(e.length, t.length - 1), r) : e.slice();
  }, r.range = function(s) {
    return arguments.length ? (t = Array.from(s), i = Math.min(e.length, t.length - 1), r) : t.slice();
  }, r.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, r.unknown = function(s) {
    return arguments.length ? (n = s, r) : n;
  }, r.copy = function() {
    return aO().domain(e).range(t).unknown(n);
  }, Ir.apply(r, arguments);
}
function xU(e) {
  return new Date(e);
}
function wU(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function E2(e, t, n, i, r, s, o, a, l, u) {
  var c = Q5(), f = c.invert, d = c.domain, h = u(".%L"), g = u(":%S"), p = u("%I:%M"), m = u("%I %p"), y = u("%a %d"), b = u("%b %d"), v = u("%B"), _ = u("%Y");
  function x(S) {
    return (l(S) < S ? h : a(S) < S ? g : o(S) < S ? p : s(S) < S ? m : i(S) < S ? r(S) < S ? y : b : n(S) < S ? v : _)(S);
  }
  return c.invert = function(S) {
    return new Date(f(S));
  }, c.domain = function(S) {
    return arguments.length ? d(Array.from(S, wU)) : d().map(xU);
  }, c.ticks = function(S) {
    var E = d();
    return e(E[0], E[E.length - 1], S ?? 10);
  }, c.tickFormat = function(S, E) {
    return E == null ? x : u(E);
  }, c.nice = function(S) {
    var E = d();
    return (!S || typeof S.range != "function") && (S = t(E[0], E[E.length - 1], S ?? 10)), S ? d(nO(E, S)) : c;
  }, c.copy = function() {
    return ad(c, E2(e, t, n, i, r, s, o, a, l, u));
  }, c;
}
function _U() {
  return Ir.apply(E2($9, M9, Mr, xf, Iu, gs, Gp, Wp, us, cx).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function EU() {
  return Ir.apply(E2(A9, C9, Fr, wf, zu, oo, Vp, Hp, us, fx).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function pm() {
  var e = 0, t = 1, n, i, r, s, o = On, a = !1, l;
  function u(f) {
    return f == null || isNaN(f = +f) ? l : o(r === 0 ? 0.5 : (f = (s(f) - n) * r, a ? Math.max(0, Math.min(1, f)) : f));
  }
  u.domain = function(f) {
    return arguments.length ? ([e, t] = f, n = s(e = +e), i = s(t = +t), r = n === i ? 0 : 1 / (i - n), u) : [e, t];
  }, u.clamp = function(f) {
    return arguments.length ? (a = !!f, u) : a;
  }, u.interpolator = function(f) {
    return arguments.length ? (o = f, u) : o;
  };
  function c(f) {
    return function(d) {
      var h, g;
      return arguments.length ? ([h, g] = d, o = f(h, g), u) : [o(0), o(1)];
    };
  }
  return u.range = c(Do), u.rangeRound = c(od), u.unknown = function(f) {
    return arguments.length ? (l = f, u) : l;
  }, function(f) {
    return s = f, n = f(e), i = f(t), r = n === i ? 0 : 1 / (i - n), u;
  };
}
function Ro(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function S2() {
  var e = nl(pm()(On));
  return e.copy = function() {
    return Ro(e, S2());
  }, Oo.apply(e, arguments);
}
function lO() {
  var e = v2(pm()).domain([1, 10]);
  return e.copy = function() {
    return Ro(e, lO()).base(e.base());
  }, Oo.apply(e, arguments);
}
function uO() {
  var e = x2(pm());
  return e.copy = function() {
    return Ro(e, uO()).constant(e.constant());
  }, Oo.apply(e, arguments);
}
function k2() {
  var e = w2(pm());
  return e.copy = function() {
    return Ro(e, k2()).exponent(e.exponent());
  }, Oo.apply(e, arguments);
}
function SU() {
  return k2.apply(null, arguments).exponent(0.5);
}
function mm() {
  var e = 0, t = 0.5, n = 1, i = 1, r, s, o, a, l, u = On, c, f = !1, d;
  function h(p) {
    return isNaN(p = +p) ? d : (p = 0.5 + ((p = +c(p)) - s) * (i * p < i * s ? a : l), u(f ? Math.max(0, Math.min(1, p)) : p));
  }
  h.domain = function(p) {
    return arguments.length ? ([e, t, n] = p, r = c(e = +e), s = c(t = +t), o = c(n = +n), a = r === s ? 0 : 0.5 / (s - r), l = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, h) : [e, t, n];
  }, h.clamp = function(p) {
    return arguments.length ? (f = !!p, h) : f;
  }, h.interpolator = function(p) {
    return arguments.length ? (u = p, h) : u;
  };
  function g(p) {
    return function(m) {
      var y, b, v;
      return arguments.length ? ([y, b, v] = m, u = b2(p, [y, b, v]), h) : [u(0), u(0.5), u(1)];
    };
  }
  return h.range = g(Do), h.rangeRound = g(od), h.unknown = function(p) {
    return arguments.length ? (d = p, h) : d;
  }, function(p) {
    return c = p, r = p(e), s = p(t), o = p(n), a = r === s ? 0 : 0.5 / (s - r), l = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, h;
  };
}
function cO() {
  var e = nl(mm()(On));
  return e.copy = function() {
    return Ro(e, cO());
  }, Oo.apply(e, arguments);
}
function fO() {
  var e = v2(mm()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return Ro(e, fO()).base(e.base());
  }, Oo.apply(e, arguments);
}
function dO() {
  var e = x2(mm());
  return e.copy = function() {
    return Ro(e, dO()).constant(e.constant());
  }, Oo.apply(e, arguments);
}
function A2() {
  var e = w2(mm());
  return e.copy = function() {
    return Ro(e, A2()).exponent(e.exponent());
  }, Oo.apply(e, arguments);
}
function kU() {
  return A2.apply(null, arguments).exponent(0.5);
}
function C2(e, t, n) {
  const i = e - t + n * 2;
  return e ? i > 0 ? i : 1 : 0;
}
const AU = "identity", au = "linear", _s = "log", ld = "pow", ud = "sqrt", ym = "symlog", Fa = "time", Ta = "utc", Er = "sequential", Wu = "diverging", lu = "quantile", bm = "quantize", vm = "threshold", $2 = "ordinal", Jy = "point", hO = "band", M2 = "bin-ordinal", St = "continuous", cd = "discrete", fd = "discretizing", Mi = "interpolating", F2 = "temporal";
function CU(e) {
  return function(t) {
    let n = t[0], i = t[1], r;
    return i < n && (r = n, n = i, i = r), [e.invert(n), e.invert(i)];
  };
}
function $U(e) {
  return function(t) {
    const n = e.range();
    let i = t[0], r = t[1], s = -1, o, a, l, u;
    for (r < i && (a = i, i = r, r = a), l = 0, u = n.length; l < u; ++l)
      n[l] >= i && n[l] <= r && (s < 0 && (s = l), o = l);
    if (!(s < 0))
      return i = e.invertExtent(n[s]), r = e.invertExtent(n[o]), [i[0] === void 0 ? i[1] : i[0], r[1] === void 0 ? r[0] : r[1]];
  };
}
function T2() {
  const e = h2().unknown(void 0), t = e.domain, n = e.range;
  let i = [0, 1], r, s, o = !1, a = 0, l = 0, u = 0.5;
  delete e.unknown;
  function c() {
    const f = t().length, d = i[1] < i[0], h = i[1 - d], g = C2(f, a, l);
    let p = i[d - 0];
    r = (h - p) / (g || 1), o && (r = Math.floor(r)), p += (h - p - r * (f - a)) * u, s = r * (1 - a), o && (p = Math.round(p), s = Math.round(s));
    const m = Jn(f).map((y) => p + r * y);
    return n(d ? m.reverse() : m);
  }
  return e.domain = function(f) {
    return arguments.length ? (t(f), c()) : t();
  }, e.range = function(f) {
    return arguments.length ? (i = [+f[0], +f[1]], c()) : i.slice();
  }, e.rangeRound = function(f) {
    return i = [+f[0], +f[1]], o = !0, c();
  }, e.bandwidth = function() {
    return s;
  }, e.step = function() {
    return r;
  }, e.round = function(f) {
    return arguments.length ? (o = !!f, c()) : o;
  }, e.padding = function(f) {
    return arguments.length ? (l = Math.max(0, Math.min(1, f)), a = l, c()) : a;
  }, e.paddingInner = function(f) {
    return arguments.length ? (a = Math.max(0, Math.min(1, f)), c()) : a;
  }, e.paddingOuter = function(f) {
    return arguments.length ? (l = Math.max(0, Math.min(1, f)), c()) : l;
  }, e.align = function(f) {
    return arguments.length ? (u = Math.max(0, Math.min(1, f)), c()) : u;
  }, e.invertRange = function(f) {
    if (f[0] == null || f[1] == null)
      return;
    const d = i[1] < i[0], h = d ? n().reverse() : n(), g = h.length - 1;
    let p = +f[0], m = +f[1], y, b, v;
    if (!(p !== p || m !== m) && (m < p && (v = p, p = m, m = v), !(m < h[0] || p > i[1 - d])))
      return y = Math.max(0, fo(h, p) - 1), b = p === m ? y : fo(h, m) - 1, p - h[y] > s + 1e-10 && ++y, d && (v = y, y = g - b, b = g - v), y > b ? void 0 : t().slice(y, b + 1);
  }, e.invert = function(f) {
    const d = e.invertRange([f, f]);
    return d && d[0];
  }, e.copy = function() {
    return T2().domain(t()).range(i).round(o).paddingInner(a).paddingOuter(l).align(u);
  }, c();
}
function gO(e) {
  const t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, e.copy = function() {
    return gO(t());
  }, e;
}
function MU() {
  return gO(T2().paddingInner(1));
}
var FU = Array.prototype.map;
function TU(e) {
  return FU.call(e, Zt);
}
const OU = Array.prototype.slice;
function pO() {
  let e = [], t = [];
  function n(i) {
    return i == null || i !== i ? void 0 : t[(fo(e, i) - 1) % t.length];
  }
  return n.domain = function(i) {
    return arguments.length ? (e = TU(i), n) : e.slice();
  }, n.range = function(i) {
    return arguments.length ? (t = OU.call(i), n) : t.slice();
  }, n.tickFormat = function(i, r) {
    return Z5(e[0], Te(e), i ?? 10, r);
  }, n.copy = function() {
    return pO().domain(n.domain()).range(n.range());
  }, n;
}
const Eg = /* @__PURE__ */ new Map(), mO = Symbol("vega_scale");
function yO(e) {
  return e[mO] = !0, e;
}
function NU(e) {
  return e && e[mO] === !0;
}
function DU(e, t, n) {
  const i = function() {
    const s = t();
    return s.invertRange || (s.invertRange = s.invert ? CU(s) : s.invertExtent ? $U(s) : void 0), s.type = e, yO(s);
  };
  return i.metadata = Ji(ee(n)), i;
}
function ze(e, t, n) {
  return arguments.length > 1 ? (Eg.set(e, DU(e, t, n)), this) : bO(e) ? Eg.get(e) : void 0;
}
ze(AU, tO);
ze(au, eO, St);
ze(_s, iO, [St, _s]);
ze(ld, _2, St);
ze(ud, vU, St);
ze(ym, rO, St);
ze(Fa, _U, [St, F2]);
ze(Ta, EU, [St, F2]);
ze(Er, S2, [St, Mi]);
ze(`${Er}-${au}`, S2, [St, Mi]);
ze(`${Er}-${_s}`, lO, [St, Mi, _s]);
ze(`${Er}-${ld}`, k2, [St, Mi]);
ze(`${Er}-${ud}`, SU, [St, Mi]);
ze(`${Er}-${ym}`, uO, [St, Mi]);
ze(`${Wu}-${au}`, cO, [St, Mi]);
ze(`${Wu}-${_s}`, fO, [St, Mi, _s]);
ze(`${Wu}-${ld}`, A2, [St, Mi]);
ze(`${Wu}-${ud}`, kU, [St, Mi]);
ze(`${Wu}-${ym}`, dO, [St, Mi]);
ze(lu, sO, [fd, lu]);
ze(bm, oO, fd);
ze(vm, aO, fd);
ze(M2, pO, [cd, fd]);
ze($2, h2, cd);
ze(hO, T2, cd);
ze(Jy, MU, cd);
function bO(e) {
  return Eg.has(e);
}
function il(e, t) {
  const n = Eg.get(e);
  return n && n.metadata[t];
}
function O2(e) {
  return il(e, St);
}
function uu(e) {
  return il(e, cd);
}
function Qy(e) {
  return il(e, fd);
}
function vO(e) {
  return il(e, _s);
}
function RU(e) {
  return il(e, F2);
}
function xO(e) {
  return il(e, Mi);
}
function wO(e) {
  return il(e, lu);
}
const LU = ["clamp", "base", "constant", "exponent"];
function _O(e, t) {
  const n = t[0], i = Te(t) - n;
  return function(r) {
    return e(n + r * i);
  };
}
function xm(e, t, n) {
  return b2(N2(t || "rgb", n), e);
}
function EO(e, t) {
  const n = new Array(t), i = t + 1;
  for (let r = 0; r < t; )
    n[r] = e(++r / i);
  return n;
}
function SO(e, t, n) {
  const i = n - t;
  let r, s, o;
  return !i || !Number.isFinite(i) ? ln(0.5) : (r = (s = e.type).indexOf("-"), s = r < 0 ? s : s.slice(r + 1), o = ze(s)().domain([t, n]).range([0, 1]), LU.forEach((a) => e[a] ? o[a](e[a]()) : 0), o);
}
function N2(e, t) {
  const n = aU[PU(e)];
  return t != null && n && n.gamma ? n.gamma(t) : n;
}
function PU(e) {
  return "interpolate" + e.toLowerCase().split("-").map((t) => t[0].toUpperCase() + t.slice(1)).join("");
}
const IU = {
  blues: "cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",
  greens: "d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",
  greys: "e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",
  oranges: "fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",
  purples: "e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",
  reds: "fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",
  blueGreen: "d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",
  bluePurple: "ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",
  greenBlue: "d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",
  orangeRed: "fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",
  purpleBlue: "dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",
  purpleBlueGreen: "dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",
  purpleRed: "dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",
  redPurple: "fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",
  yellowGreen: "e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",
  yellowOrangeBrown: "feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",
  yellowOrangeRed: "fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",
  blueOrange: "134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",
  brownBlueGreen: "704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",
  purpleGreen: "5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",
  purpleOrange: "4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",
  redBlue: "8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",
  redGrey: "8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",
  yellowGreenBlue: "eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",
  redYellowBlue: "a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",
  redYellowGreen: "a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",
  pinkYellowGreen: "8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",
  spectral: "9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",
  viridis: "440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",
  magma: "0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",
  inferno: "0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",
  plasma: "0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",
  cividis: "00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",
  rainbow: "6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",
  sinebow: "ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",
  turbo: "23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",
  browns: "eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",
  tealBlues: "bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",
  teals: "bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",
  warmGreys: "dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",
  goldGreen: "f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",
  goldOrange: "f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",
  goldRed: "f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",
  lightGreyRed: "efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",
  lightGreyTeal: "e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",
  lightMulti: "e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",
  lightOrange: "f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",
  lightTealBlue: "e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",
  darkBlue: "3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",
  darkGold: "3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",
  darkGreen: "3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",
  darkMulti: "3737371f5287197d8c29a86995ce3fffe800ffffff",
  darkRed: "3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"
}, zU = {
  category10: "1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",
  category20: "1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",
  category20b: "393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",
  category20c: "3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",
  tableau10: "4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",
  tableau20: "4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",
  accent: "7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",
  dark2: "1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",
  paired: "a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",
  pastel1: "fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",
  pastel2: "b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",
  set1: "e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",
  set2: "66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",
  set3: "8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"
};
function kO(e) {
  const t = e.length / 6 | 0, n = new Array(t);
  for (let i = 0; i < t; )
    n[i] = "#" + e.slice(i * 6, ++i * 6);
  return n;
}
function AO(e, t) {
  for (const n in e)
    D2(n, t(e[n]));
}
const Kk = {};
AO(zU, kO);
AO(IU, (e) => xm(kO(e)));
function D2(e, t) {
  return e = e && e.toLowerCase(), arguments.length > 1 ? (Kk[e] = t, this) : Kk[e];
}
const Rh = "symbol", BU = "discrete", jU = "gradient", UU = (e) => U(e) ? e.map((t) => String(t)) : String(e), qU = (e, t) => e[1] - t[1], WU = (e, t) => t[1] - e[1];
function R2(e, t, n) {
  let i;
  return Re(t) && (e.bins && (t = Math.max(t, e.bins.length)), n != null && (t = Math.min(t, Math.floor(td(e.domain()) / n || 1) + 1))), ne(t) && (i = t.step, t = t.interval), te(t) && (t = e.type === Fa ? Bu(t) : e.type == Ta ? ju(t) : j("Only time and utc scales accept interval strings."), i && (t = t.every(i))), t;
}
function CO(e, t, n) {
  let i = e.range(), r = i[0], s = Te(i), o = qU;
  if (r > s && (i = s, s = r, r = i, o = WU), r = Math.floor(r), s = Math.ceil(s), t = t.map((a) => [a, e(a)]).filter((a) => r <= a[1] && a[1] <= s).sort(o).map((a) => a[0]), n > 0 && t.length > 1) {
    const a = [t[0], Te(t)];
    for (; t.length > n && t.length >= 3; )
      t = t.filter((l, u) => !(u % 2));
    t.length < 3 && (t = a);
  }
  return t;
}
function L2(e, t) {
  return e.bins ? CO(e, e.bins) : e.ticks ? e.ticks(t) : e.domain();
}
function $O(e, t, n, i, r, s) {
  const o = t.type;
  let a = UU;
  if (o === Fa || r === Fa)
    a = e.timeFormat(i);
  else if (o === Ta || r === Ta)
    a = e.utcFormat(i);
  else if (vO(o)) {
    const l = e.formatFloat(i);
    if (s || t.bins)
      a = l;
    else {
      const u = MO(t, n, !1);
      a = (c) => u(c) ? l(c) : "";
    }
  } else if (t.tickFormat) {
    const l = t.domain();
    a = e.formatSpan(l[0], l[l.length - 1], n, i);
  } else
    i && (a = e.format(i));
  return a;
}
function MO(e, t, n) {
  const i = L2(e, t), r = e.base(), s = Math.log(r), o = Math.max(1, r * t / i.length), a = (l) => {
    let u = l / Math.pow(r, Math.round(Math.log(l) / s));
    return u * r < r - 0.5 && (u *= r), u <= o;
  };
  return n ? i.filter(a) : a;
}
const Zy = {
  [lu]: "quantiles",
  [bm]: "thresholds",
  [vm]: "domain"
}, FO = {
  [lu]: "quantiles",
  [bm]: "domain"
};
function TO(e, t) {
  return e.bins ? VU(e.bins) : e.type === _s ? MO(e, t, !0) : Zy[e.type] ? GU(e[Zy[e.type]]()) : L2(e, t);
}
function HU(e, t, n) {
  const i = t[FO[t.type]](), r = i.length;
  let s = r > 1 ? i[1] - i[0] : i[0], o;
  for (o = 1; o < r; ++o)
    s = Math.min(s, i[o] - i[o - 1]);
  return e.formatSpan(0, s, 3 * 10, n);
}
function GU(e) {
  const t = [-1 / 0].concat(e);
  return t.max = 1 / 0, t;
}
function VU(e) {
  const t = e.slice(0, -1);
  return t.max = Te(e), t;
}
const YU = (e) => Zy[e.type] || e.bins;
function OO(e, t, n, i, r, s, o) {
  const a = FO[t.type] && s !== Fa && s !== Ta ? HU(e, t, r) : $O(e, t, n, r, s, o);
  return i === Rh && YU(t) ? XU(a) : i === BU ? KU(a) : JU(a);
}
const XU = (e) => (t, n, i) => {
  const r = Jk(i[n + 1], Jk(i.max, 1 / 0)), s = Qk(t, e), o = Qk(r, e);
  return s && o ? s + " – " + o : o ? "< " + o : "≥ " + s;
}, Jk = (e, t) => e ?? t, KU = (e) => (t, n) => n ? e(t) : null, JU = (e) => (t) => e(t), Qk = (e, t) => Number.isFinite(e) ? t(e) : null;
function QU(e) {
  const t = e.domain(), n = t.length - 1;
  let i = +t[0], r = +Te(t), s = r - i;
  if (e.type === vm) {
    const o = n ? s / n : 0.1;
    i -= o, r += o, s = r - i;
  }
  return (o) => (o - i) / s;
}
function ZU(e, t, n, i) {
  const r = i || t.type;
  return te(n) && RU(r) && (n = n.replace(/%a/g, "%A").replace(/%b/g, "%B")), !n && r === Fa ? e.timeFormat("%A, %d %B %Y, %X") : !n && r === Ta ? e.utcFormat("%A, %d %B %Y, %X UTC") : OO(e, t, 5, null, n, i, !0);
}
function NO(e, t, n) {
  n = n || {};
  const i = Math.max(3, n.maxlen || 7), r = ZU(e, t, n.format, n.formatType);
  if (Qy(t.type)) {
    const s = TO(t).slice(1).map(r), o = s.length;
    return `${o} boundar${o === 1 ? "y" : "ies"}: ${s.join(", ")}`;
  } else if (uu(t.type)) {
    const s = t.domain(), o = s.length, a = o > i ? s.slice(0, i - 2).map(r).join(", ") + ", ending with " + s.slice(-1).map(r) : s.map(r).join(", ");
    return `${o} value${o === 1 ? "" : "s"}: ${a}`;
  } else {
    const s = t.domain();
    return `values from ${r(s[0])} to ${r(Te(s))}`;
  }
}
let DO = 0;
function eq() {
  DO = 0;
}
const Sg = "p_";
function P2(e) {
  return e && e.gradient;
}
function RO(e, t, n) {
  const i = e.gradient;
  let r = e.id, s = i === "radial" ? Sg : "";
  return r || (r = e.id = "gradient_" + DO++, i === "radial" ? (e.x1 = fr(e.x1, 0.5), e.y1 = fr(e.y1, 0.5), e.r1 = fr(e.r1, 0), e.x2 = fr(e.x2, 0.5), e.y2 = fr(e.y2, 0.5), e.r2 = fr(e.r2, 0.5), s = Sg) : (e.x1 = fr(e.x1, 0), e.y1 = fr(e.y1, 0), e.x2 = fr(e.x2, 1), e.y2 = fr(e.y2, 0))), t[r] = e, "url(" + (n || "") + "#" + s + r + ")";
}
function fr(e, t) {
  return e ?? t;
}
function LO(e, t) {
  var n = [], i;
  return i = {
    gradient: "linear",
    x1: e ? e[0] : 0,
    y1: e ? e[1] : 0,
    x2: t ? t[0] : 1,
    y2: t ? t[1] : 0,
    stops: n,
    stop: function(r, s) {
      return n.push({
        offset: r,
        color: s
      }), i;
    }
  };
}
const Zk = {
  basis: {
    curve: sj
  },
  "basis-closed": {
    curve: oj
  },
  "basis-open": {
    curve: aj
  },
  bundle: {
    curve: lj,
    tension: "beta",
    value: 0.85
  },
  cardinal: {
    curve: uj,
    tension: "tension",
    value: 0
  },
  "cardinal-open": {
    curve: fj,
    tension: "tension",
    value: 0
  },
  "cardinal-closed": {
    curve: cj,
    tension: "tension",
    value: 0
  },
  "catmull-rom": {
    curve: dj,
    tension: "alpha",
    value: 0.5
  },
  "catmull-rom-closed": {
    curve: hj,
    tension: "alpha",
    value: 0.5
  },
  "catmull-rom-open": {
    curve: gj,
    tension: "alpha",
    value: 0.5
  },
  linear: {
    curve: l2
  },
  "linear-closed": {
    curve: pj
  },
  monotone: {
    horizontal: yj,
    vertical: mj
  },
  natural: {
    curve: bj
  },
  step: {
    curve: vj
  },
  "step-after": {
    curve: wj
  },
  "step-before": {
    curve: xj
  }
};
function I2(e, t, n) {
  var i = ce(Zk, e) && Zk[e], r = null;
  return i && (r = i.curve || i[t || "vertical"], i.tension && n != null && (r = r[i.tension](n))), r;
}
const tq = {
  m: 2,
  l: 2,
  h: 1,
  v: 1,
  z: 0,
  c: 6,
  s: 4,
  q: 4,
  t: 2,
  a: 7
}, nq = /[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi, iq = /^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/, rq = /^((\s+,?\s*)|(,\s*))/, sq = /^[01]/;
function cu(e) {
  const t = [];
  return (e.match(nq) || []).forEach((i) => {
    let r = i[0];
    const s = r.toLowerCase(), o = tq[s], a = oq(s, o, i.slice(1).trim()), l = a.length;
    if (l < o || l && l % o !== 0)
      throw Error("Invalid SVG path, incorrect parameter count");
    if (t.push([r, ...a.slice(0, o)]), l !== o) {
      s === "m" && (r = r === "M" ? "L" : "l");
      for (let u = o; u < l; u += o)
        t.push([r, ...a.slice(u, u + o)]);
    }
  }), t;
}
function oq(e, t, n) {
  const i = [];
  for (let r = 0; t && r < n.length; )
    for (let s = 0; s < t; ++s) {
      const o = e === "a" && (s === 3 || s === 4) ? sq : iq, a = n.slice(r).match(o);
      if (a === null)
        throw Error("Invalid SVG path, incorrect parameter type");
      r += a[0].length, i.push(+a[0]);
      const l = n.slice(r).match(rq);
      l !== null && (r += l[0].length);
    }
  return i;
}
const yo = Math.PI / 180, aq = 1e-14, aa = Math.PI / 2, yr = Math.PI * 2, bl = Math.sqrt(3) / 2;
var g1 = {}, p1 = {}, PO = [].join;
function lq(e, t, n, i, r, s, o, a, l) {
  const u = PO.call(arguments);
  if (g1[u])
    return g1[u];
  const c = o * yo, f = Math.sin(c), d = Math.cos(c);
  n = Math.abs(n), i = Math.abs(i);
  const h = d * (a - e) * 0.5 + f * (l - t) * 0.5, g = d * (l - t) * 0.5 - f * (a - e) * 0.5;
  let p = h * h / (n * n) + g * g / (i * i);
  p > 1 && (p = Math.sqrt(p), n *= p, i *= p);
  const m = d / n, y = f / n, b = -f / i, v = d / i, _ = m * a + y * l, x = b * a + v * l, S = m * e + y * t, E = b * e + v * t;
  let $ = 1 / ((S - _) * (S - _) + (E - x) * (E - x)) - 0.25;
  $ < 0 && ($ = 0);
  let N = Math.sqrt($);
  s == r && (N = -N);
  const O = 0.5 * (_ + S) - N * (E - x), P = 0.5 * (x + E) + N * (S - _), T = Math.atan2(x - P, _ - O);
  let M = Math.atan2(E - P, S - O) - T;
  M < 0 && s === 1 ? M += yr : M > 0 && s === 0 && (M -= yr);
  const w = Math.ceil(Math.abs(M / (aa + 1e-3))), k = [];
  for (let A = 0; A < w; ++A) {
    const F = T + A * M / w, R = T + (A + 1) * M / w;
    k[A] = [O, P, F, R, n, i, f, d];
  }
  return g1[u] = k;
}
function uq(e) {
  const t = PO.call(e);
  if (p1[t])
    return p1[t];
  var n = e[0], i = e[1], r = e[2], s = e[3], o = e[4], a = e[5], l = e[6], u = e[7];
  const c = u * o, f = -l * a, d = l * o, h = u * a, g = Math.cos(r), p = Math.sin(r), m = Math.cos(s), y = Math.sin(s), b = 0.5 * (s - r), v = Math.sin(b * 0.5), _ = 8 / 3 * v * v / Math.sin(b), x = n + g - _ * p, S = i + p + _ * g, E = n + m, C = i + y, $ = E + _ * y, N = C - _ * m;
  return p1[t] = [c * x + f * S, d * x + h * S, c * $ + f * N, d * $ + h * N, c * E + f * C, d * E + h * C];
}
const ci = ["l", 0, 0, 0, 0, 0, 0, 0];
function cq(e, t, n) {
  const i = ci[0] = e[0];
  if (i === "a" || i === "A")
    ci[1] = t * e[1], ci[2] = n * e[2], ci[3] = e[3], ci[4] = e[4], ci[5] = e[5], ci[6] = t * e[6], ci[7] = n * e[7];
  else if (i === "h" || i === "H")
    ci[1] = t * e[1];
  else if (i === "v" || i === "V")
    ci[1] = n * e[1];
  else
    for (var r = 1, s = e.length; r < s; ++r)
      ci[r] = (r % 2 == 1 ? t : n) * e[r];
  return ci;
}
function $f(e, t, n, i, r, s) {
  var o, a = null, l = 0, u = 0, c = 0, f = 0, d, h, g, p, m = 0, y = 0;
  n == null && (n = 0), i == null && (i = 0), r == null && (r = 1), s == null && (s = r), e.beginPath && e.beginPath();
  for (var b = 0, v = t.length; b < v; ++b) {
    switch (o = t[b], (r !== 1 || s !== 1) && (o = cq(o, r, s)), o[0]) {
      case "l":
        l += o[1], u += o[2], e.lineTo(l + n, u + i);
        break;
      case "L":
        l = o[1], u = o[2], e.lineTo(l + n, u + i);
        break;
      case "h":
        l += o[1], e.lineTo(l + n, u + i);
        break;
      case "H":
        l = o[1], e.lineTo(l + n, u + i);
        break;
      case "v":
        u += o[1], e.lineTo(l + n, u + i);
        break;
      case "V":
        u = o[1], e.lineTo(l + n, u + i);
        break;
      case "m":
        l += o[1], u += o[2], m = l, y = u, e.moveTo(l + n, u + i);
        break;
      case "M":
        l = o[1], u = o[2], m = l, y = u, e.moveTo(l + n, u + i);
        break;
      case "c":
        d = l + o[5], h = u + o[6], c = l + o[3], f = u + o[4], e.bezierCurveTo(
          l + o[1] + n,
          // x1
          u + o[2] + i,
          // y1
          c + n,
          // x2
          f + i,
          // y2
          d + n,
          h + i
        ), l = d, u = h;
        break;
      case "C":
        l = o[5], u = o[6], c = o[3], f = o[4], e.bezierCurveTo(o[1] + n, o[2] + i, c + n, f + i, l + n, u + i);
        break;
      case "s":
        d = l + o[3], h = u + o[4], c = 2 * l - c, f = 2 * u - f, e.bezierCurveTo(c + n, f + i, l + o[1] + n, u + o[2] + i, d + n, h + i), c = l + o[1], f = u + o[2], l = d, u = h;
        break;
      case "S":
        d = o[3], h = o[4], c = 2 * l - c, f = 2 * u - f, e.bezierCurveTo(c + n, f + i, o[1] + n, o[2] + i, d + n, h + i), l = d, u = h, c = o[1], f = o[2];
        break;
      case "q":
        d = l + o[3], h = u + o[4], c = l + o[1], f = u + o[2], e.quadraticCurveTo(c + n, f + i, d + n, h + i), l = d, u = h;
        break;
      case "Q":
        d = o[3], h = o[4], e.quadraticCurveTo(o[1] + n, o[2] + i, d + n, h + i), l = d, u = h, c = o[1], f = o[2];
        break;
      case "t":
        d = l + o[1], h = u + o[2], a[0].match(/[QqTt]/) === null ? (c = l, f = u) : a[0] === "t" ? (c = 2 * l - g, f = 2 * u - p) : a[0] === "q" && (c = 2 * l - c, f = 2 * u - f), g = c, p = f, e.quadraticCurveTo(c + n, f + i, d + n, h + i), l = d, u = h, c = l + o[1], f = u + o[2];
        break;
      case "T":
        d = o[1], h = o[2], c = 2 * l - c, f = 2 * u - f, e.quadraticCurveTo(c + n, f + i, d + n, h + i), l = d, u = h;
        break;
      case "a":
        eA(e, l + n, u + i, [o[1], o[2], o[3], o[4], o[5], o[6] + l + n, o[7] + u + i]), l += o[6], u += o[7];
        break;
      case "A":
        eA(e, l + n, u + i, [o[1], o[2], o[3], o[4], o[5], o[6] + n, o[7] + i]), l = o[6], u = o[7];
        break;
      case "z":
      case "Z":
        l = m, u = y, e.closePath();
        break;
    }
    a = o;
  }
}
function eA(e, t, n, i) {
  const r = lq(
    i[5],
    // end x
    i[6],
    // end y
    i[0],
    // radius x
    i[1],
    // radius y
    i[3],
    // large flag
    i[4],
    // sweep flag
    i[2],
    // rotation
    t,
    n
  );
  for (let s = 0; s < r.length; ++s) {
    const o = uq(r[s]);
    e.bezierCurveTo(o[0], o[1], o[2], o[3], o[4], o[5]);
  }
}
const tA = 0.5773502691896257, nA = {
  circle: {
    draw: function(e, t) {
      const n = Math.sqrt(t) / 2;
      e.moveTo(n, 0), e.arc(0, 0, n, 0, yr);
    }
  },
  cross: {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = n / 2.5;
      e.moveTo(-n, -i), e.lineTo(-n, i), e.lineTo(-i, i), e.lineTo(-i, n), e.lineTo(i, n), e.lineTo(i, i), e.lineTo(n, i), e.lineTo(n, -i), e.lineTo(i, -i), e.lineTo(i, -n), e.lineTo(-i, -n), e.lineTo(-i, -i), e.closePath();
    }
  },
  diamond: {
    draw: function(e, t) {
      const n = Math.sqrt(t) / 2;
      e.moveTo(-n, 0), e.lineTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.closePath();
    }
  },
  square: {
    draw: function(e, t) {
      var n = Math.sqrt(t), i = -n / 2;
      e.rect(i, i, n, n);
    }
  },
  arrow: {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = n / 7, r = n / 2.5, s = n / 8;
      e.moveTo(-i, n), e.lineTo(i, n), e.lineTo(i, -s), e.lineTo(r, -s), e.lineTo(0, -n), e.lineTo(-r, -s), e.lineTo(-i, -s), e.closePath();
    }
  },
  wedge: {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n, r = i - n * tA, s = n / 4;
      e.moveTo(0, -i - r), e.lineTo(-s, i - r), e.lineTo(s, i - r), e.closePath();
    }
  },
  triangle: {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n, r = i - n * tA;
      e.moveTo(0, -i - r), e.lineTo(-n, i - r), e.lineTo(n, i - r), e.closePath();
    }
  },
  "triangle-up": {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n;
      e.moveTo(0, -i), e.lineTo(-n, i), e.lineTo(n, i), e.closePath();
    }
  },
  "triangle-down": {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n;
      e.moveTo(0, i), e.lineTo(-n, -i), e.lineTo(n, -i), e.closePath();
    }
  },
  "triangle-right": {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n;
      e.moveTo(i, 0), e.lineTo(-i, -n), e.lineTo(-i, n), e.closePath();
    }
  },
  "triangle-left": {
    draw: function(e, t) {
      var n = Math.sqrt(t) / 2, i = bl * n;
      e.moveTo(-i, 0), e.lineTo(i, -n), e.lineTo(i, n), e.closePath();
    }
  },
  stroke: {
    draw: function(e, t) {
      const n = Math.sqrt(t) / 2;
      e.moveTo(-n, 0), e.lineTo(n, 0);
    }
  }
};
function IO(e) {
  return ce(nA, e) ? nA[e] : fq(e);
}
var m1 = {};
function fq(e) {
  if (!ce(m1, e)) {
    const t = cu(e);
    m1[e] = {
      draw: function(n, i) {
        $f(n, t, 0, 0, Math.sqrt(i) / 2);
      }
    };
  }
  return m1[e];
}
const Bs = 0.448084975506;
function dq(e) {
  return e.x;
}
function hq(e) {
  return e.y;
}
function gq(e) {
  return e.width;
}
function pq(e) {
  return e.height;
}
function Kr(e) {
  return typeof e == "function" ? e : () => +e;
}
function Zd(e, t, n) {
  return Math.max(t, Math.min(e, n));
}
function zO() {
  var e = dq, t = hq, n = gq, i = pq, r = Kr(0), s = r, o = r, a = r, l = null;
  function u(c, f, d) {
    var h, g = f ?? +e.call(this, c), p = d ?? +t.call(this, c), m = +n.call(this, c), y = +i.call(this, c), b = Math.min(m, y) / 2, v = Zd(+r.call(this, c), 0, b), _ = Zd(+s.call(this, c), 0, b), x = Zd(+o.call(this, c), 0, b), S = Zd(+a.call(this, c), 0, b);
    if (l || (l = h = am()), v <= 0 && _ <= 0 && x <= 0 && S <= 0)
      l.rect(g, p, m, y);
    else {
      var E = g + m, C = p + y;
      l.moveTo(g + v, p), l.lineTo(E - _, p), l.bezierCurveTo(E - Bs * _, p, E, p + Bs * _, E, p + _), l.lineTo(E, C - S), l.bezierCurveTo(E, C - Bs * S, E - Bs * S, C, E - S, C), l.lineTo(g + x, C), l.bezierCurveTo(g + Bs * x, C, g, C - Bs * x, g, C - x), l.lineTo(g, p + v), l.bezierCurveTo(g, p + Bs * v, g + Bs * v, p, g + v, p), l.closePath();
    }
    if (h)
      return l = null, h + "" || null;
  }
  return u.x = function(c) {
    return arguments.length ? (e = Kr(c), u) : e;
  }, u.y = function(c) {
    return arguments.length ? (t = Kr(c), u) : t;
  }, u.width = function(c) {
    return arguments.length ? (n = Kr(c), u) : n;
  }, u.height = function(c) {
    return arguments.length ? (i = Kr(c), u) : i;
  }, u.cornerRadius = function(c, f, d, h) {
    return arguments.length ? (r = Kr(c), s = f != null ? Kr(f) : r, a = d != null ? Kr(d) : r, o = h != null ? Kr(h) : s, u) : r;
  }, u.context = function(c) {
    return arguments.length ? (l = c ?? null, u) : l;
  }, u;
}
function BO() {
  var e, t, n, i, r = null, s, o, a, l;
  function u(f, d, h) {
    const g = h / 2;
    if (s) {
      var p = a - d, m = f - o;
      if (p || m) {
        var y = Math.hypot(p, m), b = (p /= y) * l, v = (m /= y) * l, _ = Math.atan2(m, p);
        r.moveTo(o - b, a - v), r.lineTo(f - p * g, d - m * g), r.arc(f, d, g, _ - Math.PI, _), r.lineTo(o + b, a + v), r.arc(o, a, l, _, _ + Math.PI);
      } else
        r.arc(f, d, g, 0, yr);
      r.closePath();
    } else
      s = 1;
    o = f, a = d, l = g;
  }
  function c(f) {
    var d, h = f.length, g, p = !1, m;
    for (r == null && (r = m = am()), d = 0; d <= h; ++d)
      !(d < h && i(g = f[d], d, f)) === p && (p = !p) && (s = 0), p && u(+e(g, d, f), +t(g, d, f), +n(g, d, f));
    if (m)
      return r = null, m + "" || null;
  }
  return c.x = function(f) {
    return arguments.length ? (e = f, c) : e;
  }, c.y = function(f) {
    return arguments.length ? (t = f, c) : t;
  }, c.size = function(f) {
    return arguments.length ? (n = f, c) : n;
  }, c.defined = function(f) {
    return arguments.length ? (i = f, c) : i;
  }, c.context = function(f) {
    return arguments.length ? (f == null ? r = null : r = f, c) : r;
  }, c;
}
function dd(e, t) {
  return e ?? t;
}
const hd = (e) => e.x || 0, gd = (e) => e.y || 0, mq = (e) => e.width || 0, yq = (e) => e.height || 0, bq = (e) => (e.x || 0) + (e.width || 0), vq = (e) => (e.y || 0) + (e.height || 0), xq = (e) => e.startAngle || 0, wq = (e) => e.endAngle || 0, _q = (e) => e.padAngle || 0, Eq = (e) => e.innerRadius || 0, Sq = (e) => e.outerRadius || 0, kq = (e) => e.cornerRadius || 0, Aq = (e) => dd(e.cornerRadiusTopLeft, e.cornerRadius) || 0, Cq = (e) => dd(e.cornerRadiusTopRight, e.cornerRadius) || 0, $q = (e) => dd(e.cornerRadiusBottomRight, e.cornerRadius) || 0, Mq = (e) => dd(e.cornerRadiusBottomLeft, e.cornerRadius) || 0, Fq = (e) => dd(e.size, 64), Tq = (e) => e.size || 1, wm = (e) => e.defined !== !1, Oq = (e) => IO(e.shape || "circle"), Nq = nj().startAngle(xq).endAngle(wq).padAngle(_q).innerRadius(Eq).outerRadius(Sq).cornerRadius(kq), Dq = p5().x(hd).y1(gd).y0(vq).defined(wm), Rq = p5().y(gd).x1(hd).x0(bq).defined(wm), Lq = g5().x(hd).y(gd).defined(wm), Pq = zO().x(hd).y(gd).width(mq).height(yq).cornerRadius(Aq, Cq, $q, Mq), Iq = rj().type(Oq).size(Fq), zq = BO().x(hd).y(gd).defined(wm).size(Tq);
function z2(e) {
  return e.cornerRadius || e.cornerRadiusTopLeft || e.cornerRadiusTopRight || e.cornerRadiusBottomRight || e.cornerRadiusBottomLeft;
}
function Bq(e, t) {
  return Nq.context(e)(t);
}
function jq(e, t) {
  const n = t[0], i = n.interpolate || "linear";
  return (n.orient === "horizontal" ? Rq : Dq).curve(I2(i, n.orient, n.tension)).context(e)(t);
}
function Uq(e, t) {
  const n = t[0], i = n.interpolate || "linear";
  return Lq.curve(I2(i, n.orient, n.tension)).context(e)(t);
}
function Hu(e, t, n, i) {
  return Pq.context(e)(t, n, i);
}
function qq(e, t) {
  return (t.mark.shape || t.shape).context(e)(t);
}
function Wq(e, t) {
  return Iq.context(e)(t);
}
function Hq(e, t) {
  return zq.context(e)(t);
}
var jO = 1;
function UO() {
  jO = 1;
}
function B2(e, t, n) {
  var i = t.clip, r = e._defs, s = t.clip_id || (t.clip_id = "clip" + jO++), o = r.clipping[s] || (r.clipping[s] = {
    id: s
  });
  return Ee(i) ? o.path = i(null) : z2(n) ? o.path = Hu(null, n, 0, 0) : (o.width = n.width || 0, o.height = n.height || 0), "url(#" + s + ")";
}
function pt(e) {
  this.clear(), e && this.union(e);
}
pt.prototype = {
  clone() {
    return new pt(this);
  },
  clear() {
    return this.x1 = +Number.MAX_VALUE, this.y1 = +Number.MAX_VALUE, this.x2 = -Number.MAX_VALUE, this.y2 = -Number.MAX_VALUE, this;
  },
  empty() {
    return this.x1 === +Number.MAX_VALUE && this.y1 === +Number.MAX_VALUE && this.x2 === -Number.MAX_VALUE && this.y2 === -Number.MAX_VALUE;
  },
  equals(e) {
    return this.x1 === e.x1 && this.y1 === e.y1 && this.x2 === e.x2 && this.y2 === e.y2;
  },
  set(e, t, n, i) {
    return n < e ? (this.x2 = e, this.x1 = n) : (this.x1 = e, this.x2 = n), i < t ? (this.y2 = t, this.y1 = i) : (this.y1 = t, this.y2 = i), this;
  },
  add(e, t) {
    return e < this.x1 && (this.x1 = e), t < this.y1 && (this.y1 = t), e > this.x2 && (this.x2 = e), t > this.y2 && (this.y2 = t), this;
  },
  expand(e) {
    return this.x1 -= e, this.y1 -= e, this.x2 += e, this.y2 += e, this;
  },
  round() {
    return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this;
  },
  scale(e) {
    return this.x1 *= e, this.y1 *= e, this.x2 *= e, this.y2 *= e, this;
  },
  translate(e, t) {
    return this.x1 += e, this.x2 += e, this.y1 += t, this.y2 += t, this;
  },
  rotate(e, t, n) {
    const i = this.rotatedPoints(e, t, n);
    return this.clear().add(i[0], i[1]).add(i[2], i[3]).add(i[4], i[5]).add(i[6], i[7]);
  },
  rotatedPoints(e, t, n) {
    var {
      x1: i,
      y1: r,
      x2: s,
      y2: o
    } = this, a = Math.cos(e), l = Math.sin(e), u = t - t * a + n * l, c = n - t * l - n * a;
    return [a * i - l * r + u, l * i + a * r + c, a * i - l * o + u, l * i + a * o + c, a * s - l * r + u, l * s + a * r + c, a * s - l * o + u, l * s + a * o + c];
  },
  union(e) {
    return e.x1 < this.x1 && (this.x1 = e.x1), e.y1 < this.y1 && (this.y1 = e.y1), e.x2 > this.x2 && (this.x2 = e.x2), e.y2 > this.y2 && (this.y2 = e.y2), this;
  },
  intersect(e) {
    return e.x1 > this.x1 && (this.x1 = e.x1), e.y1 > this.y1 && (this.y1 = e.y1), e.x2 < this.x2 && (this.x2 = e.x2), e.y2 < this.y2 && (this.y2 = e.y2), this;
  },
  encloses(e) {
    return e && this.x1 <= e.x1 && this.x2 >= e.x2 && this.y1 <= e.y1 && this.y2 >= e.y2;
  },
  alignsWith(e) {
    return e && (this.x1 == e.x1 || this.x2 == e.x2 || this.y1 == e.y1 || this.y2 == e.y2);
  },
  intersects(e) {
    return e && !(this.x2 < e.x1 || this.x1 > e.x2 || this.y2 < e.y1 || this.y1 > e.y2);
  },
  contains(e, t) {
    return !(e < this.x1 || e > this.x2 || t < this.y1 || t > this.y2);
  },
  width() {
    return this.x2 - this.x1;
  },
  height() {
    return this.y2 - this.y1;
  }
};
function _m(e) {
  this.mark = e, this.bounds = this.bounds || new pt();
}
function Em(e) {
  _m.call(this, e), this.items = this.items || [];
}
Y(Em, _m);
function j2(e) {
  this._pending = 0, this._loader = e || Xp();
}
function iA(e) {
  e._pending += 1;
}
function hc(e) {
  e._pending -= 1;
}
j2.prototype = {
  pending() {
    return this._pending;
  },
  sanitizeURL(e) {
    const t = this;
    return iA(t), t._loader.sanitize(e, {
      context: "href"
    }).then((n) => (hc(t), n)).catch(() => (hc(t), null));
  },
  loadImage(e) {
    const t = this, n = _j();
    return iA(t), t._loader.sanitize(e, {
      context: "image"
    }).then((i) => {
      const r = i.href;
      if (!r || !n)
        throw {
          url: r
        };
      const s = new n(), o = ce(i, "crossOrigin") ? i.crossOrigin : "anonymous";
      return o != null && (s.crossOrigin = o), s.onload = () => hc(t), s.onerror = () => hc(t), s.src = r, s;
    }).catch((i) => (hc(t), {
      complete: !1,
      width: 0,
      height: 0,
      src: i && i.url || ""
    }));
  },
  ready() {
    const e = this;
    return new Promise((t) => {
      function n(i) {
        e.pending() ? setTimeout(() => {
          n(!0);
        }, 10) : t(i);
      }
      n(!1);
    });
  }
};
function Fs(e, t, n) {
  if (t.stroke && t.opacity !== 0 && t.strokeOpacity !== 0) {
    const i = t.strokeWidth != null ? +t.strokeWidth : 1;
    e.expand(i + (n ? Gq(t, i) : 0));
  }
  return e;
}
function Gq(e, t) {
  return e.strokeJoin && e.strokeJoin !== "miter" ? 0 : t;
}
const Vq = yr - 1e-8;
let Sm, Lh, Ph, pa, eb, Ih, tb, nb;
const Ks = (e, t) => Sm.add(e, t), zh = (e, t) => Ks(Lh = e, Ph = t), rA = (e) => Ks(e, Sm.y1), sA = (e) => Ks(Sm.x1, e), la = (e, t) => eb * e + tb * t, ua = (e, t) => Ih * e + nb * t, y1 = (e, t) => Ks(la(e, t), ua(e, t)), b1 = (e, t) => zh(la(e, t), ua(e, t));
function pd(e, t) {
  return Sm = e, t ? (pa = t * yo, eb = nb = Math.cos(pa), Ih = Math.sin(pa), tb = -Ih) : (eb = nb = 1, pa = Ih = tb = 0), Yq;
}
const Yq = {
  beginPath() {
  },
  closePath() {
  },
  moveTo: b1,
  lineTo: b1,
  rect(e, t, n, i) {
    pa ? (y1(e + n, t), y1(e + n, t + i), y1(e, t + i), b1(e, t)) : (Ks(e + n, t + i), zh(e, t));
  },
  quadraticCurveTo(e, t, n, i) {
    const r = la(e, t), s = ua(e, t), o = la(n, i), a = ua(n, i);
    oA(Lh, r, o, rA), oA(Ph, s, a, sA), zh(o, a);
  },
  bezierCurveTo(e, t, n, i, r, s) {
    const o = la(e, t), a = ua(e, t), l = la(n, i), u = ua(n, i), c = la(r, s), f = ua(r, s);
    aA(Lh, o, l, c, rA), aA(Ph, a, u, f, sA), zh(c, f);
  },
  arc(e, t, n, i, r, s) {
    if (i += pa, r += pa, Lh = n * Math.cos(r) + e, Ph = n * Math.sin(r) + t, Math.abs(r - i) > Vq)
      Ks(e - n, t - n), Ks(e + n, t + n);
    else {
      const o = (u) => Ks(n * Math.cos(u) + e, n * Math.sin(u) + t);
      let a, l;
      if (o(i), o(r), r !== i)
        if (i = i % yr, i < 0 && (i += yr), r = r % yr, r < 0 && (r += yr), r < i && (s = !s, a = i, i = r, r = a), s)
          for (r -= yr, a = i - i % aa, l = 0; l < 4 && a > r; ++l, a -= aa)
            o(a);
        else
          for (a = i - i % aa + aa, l = 0; l < 4 && a < r; ++l, a = a + aa)
            o(a);
    }
  }
};
function oA(e, t, n, i) {
  const r = (e - t) / (e + n - 2 * t);
  0 < r && r < 1 && i(e + (t - e) * r);
}
function aA(e, t, n, i, r) {
  const s = i - e + 3 * t - 3 * n, o = e + n - 2 * t, a = e - t;
  let l = 0, u = 0, c;
  Math.abs(s) > aq ? (c = o * o + a * s, c >= 0 && (c = Math.sqrt(c), l = (-o + c) / s, u = (-o - c) / s)) : l = 0.5 * a / o, 0 < l && l < 1 && r(lA(l, e, t, n, i)), 0 < u && u < 1 && r(lA(u, e, t, n, i));
}
function lA(e, t, n, i, r) {
  const s = 1 - e, o = s * s, a = e * e;
  return o * s * t + 3 * o * e * n + 3 * s * a * i + a * e * r;
}
var uo = (uo = lo(1, 1)) ? uo.getContext("2d") : null;
const ib = new pt();
function U2(e) {
  return function(t, n) {
    if (!uo)
      return !0;
    e(uo, t), ib.clear().union(t.bounds).intersect(n).round();
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o
    } = ib;
    for (let a = r; a <= o; ++a)
      for (let l = i; l <= s; ++l)
        if (uo.isPointInPath(l, a))
          return !0;
    return !1;
  };
}
function q2(e, t) {
  return t.contains(e.x || 0, e.y || 0);
}
function qO(e, t) {
  const n = e.x || 0, i = e.y || 0, r = e.width || 0, s = e.height || 0;
  return t.intersects(ib.set(n, i, n + r, i + s));
}
function WO(e, t) {
  const n = e.x || 0, i = e.y || 0, r = e.x2 != null ? e.x2 : n, s = e.y2 != null ? e.y2 : i;
  return Rl(t, n, i, r, s);
}
function Rl(e, t, n, i, r) {
  const {
    x1: s,
    y1: o,
    x2: a,
    y2: l
  } = e, u = i - t, c = r - n;
  let f = 0, d = 1, h, g, p, m;
  for (m = 0; m < 4; ++m) {
    if (m === 0 && (h = -u, g = -(s - t)), m === 1 && (h = u, g = a - t), m === 2 && (h = -c, g = -(o - n)), m === 3 && (h = c, g = l - n), Math.abs(h) < 1e-10 && g < 0)
      return !1;
    if (p = g / h, h < 0) {
      if (p > d)
        return !1;
      p > f && (f = p);
    } else if (h > 0) {
      if (p < f)
        return !1;
      p < d && (d = p);
    }
  }
  return !0;
}
function fu(e, t) {
  e.globalCompositeOperation = t.blend || "source-over";
}
function Ni(e, t) {
  return e ?? t;
}
function uA(e, t) {
  const n = t.length;
  for (let i = 0; i < n; ++i)
    e.addColorStop(t[i].offset, t[i].color);
  return e;
}
function Xq(e, t, n) {
  const i = n.width(), r = n.height();
  let s;
  if (t.gradient === "radial")
    s = e.createRadialGradient(n.x1 + Ni(t.x1, 0.5) * i, n.y1 + Ni(t.y1, 0.5) * r, Math.max(i, r) * Ni(t.r1, 0), n.x1 + Ni(t.x2, 0.5) * i, n.y1 + Ni(t.y2, 0.5) * r, Math.max(i, r) * Ni(t.r2, 0.5));
  else {
    const o = Ni(t.x1, 0), a = Ni(t.y1, 0), l = Ni(t.x2, 1), u = Ni(t.y2, 0);
    if (o === l || a === u || i === r)
      s = e.createLinearGradient(n.x1 + o * i, n.y1 + a * r, n.x1 + l * i, n.y1 + u * r);
    else {
      const c = lo(Math.ceil(i), Math.ceil(r)), f = c.getContext("2d");
      return f.scale(i, r), f.fillStyle = uA(f.createLinearGradient(o, a, l, u), t.stops), f.fillRect(0, 0, i, r), e.createPattern(c, "no-repeat");
    }
  }
  return uA(s, t.stops);
}
function HO(e, t, n) {
  return P2(n) ? Xq(e, n, t.bounds) : n;
}
function kg(e, t, n) {
  return n *= t.fillOpacity == null ? 1 : t.fillOpacity, n > 0 ? (e.globalAlpha = n, e.fillStyle = HO(e, t, t.fill), !0) : !1;
}
var Kq = [];
function du(e, t, n) {
  var i = (i = t.strokeWidth) != null ? i : 1;
  return i <= 0 ? !1 : (n *= t.strokeOpacity == null ? 1 : t.strokeOpacity, n > 0 ? (e.globalAlpha = n, e.strokeStyle = HO(e, t, t.stroke), e.lineWidth = i, e.lineCap = t.strokeCap || "butt", e.lineJoin = t.strokeJoin || "miter", e.miterLimit = t.strokeMiterLimit || 10, e.setLineDash && (e.setLineDash(t.strokeDash || Kq), e.lineDashOffset = t.strokeDashOffset || 0), !0) : !1);
}
function Jq(e, t) {
  return e.zindex - t.zindex || e.index - t.index;
}
function W2(e) {
  if (!e.zdirty)
    return e.zitems;
  var t = e.items, n = [], i, r, s;
  for (r = 0, s = t.length; r < s; ++r)
    i = t[r], i.index = r, i.zindex && n.push(i);
  return e.zdirty = !1, e.zitems = n.sort(Jq);
}
function Zi(e, t) {
  var n = e.items, i, r;
  if (!n || !n.length)
    return;
  const s = W2(e);
  if (s && s.length) {
    for (i = 0, r = n.length; i < r; ++i)
      n[i].zindex || t(n[i]);
    n = s;
  }
  for (i = 0, r = n.length; i < r; ++i)
    t(n[i]);
}
function Ag(e, t) {
  var n = e.items, i, r;
  if (!n || !n.length)
    return null;
  const s = W2(e);
  for (s && s.length && (n = s), r = n.length; --r >= 0; )
    if (i = t(n[r]))
      return i;
  if (n === s) {
    for (n = e.items, r = n.length; --r >= 0; )
      if (!n[r].zindex && (i = t(n[r])))
        return i;
  }
  return null;
}
function H2(e) {
  return function(t, n, i) {
    Zi(n, (r) => {
      (!i || i.intersects(r.bounds)) && GO(e, t, r, r);
    });
  };
}
function Qq(e) {
  return function(t, n, i) {
    n.items.length && (!i || i.intersects(n.bounds)) && GO(e, t, n.items[0], n.items);
  };
}
function GO(e, t, n, i) {
  var r = n.opacity == null ? 1 : n.opacity;
  r !== 0 && (e(t, i) || (fu(t, n), n.fill && kg(t, n, r) && t.fill(), n.stroke && du(t, n, r) && t.stroke()));
}
function km(e) {
  return e = e || Ei, function(t, n, i, r, s, o) {
    return i *= t.pixelRatio, r *= t.pixelRatio, Ag(n, (a) => {
      const l = a.bounds;
      if (!(l && !l.contains(s, o) || !l) && e(t, a, i, r, s, o))
        return a;
    });
  };
}
function md(e, t) {
  return function(n, i, r, s) {
    var o = Array.isArray(i) ? i[0] : i, a = t ?? o.fill, l = o.stroke && n.isPointInStroke, u, c;
    return l && (u = o.strokeWidth, c = o.strokeCap, n.lineWidth = u ?? 1, n.lineCap = c ?? "butt"), e(n, i) ? !1 : a && n.isPointInPath(r, s) || l && n.isPointInStroke(r, s);
  };
}
function G2(e) {
  return km(md(e));
}
function _a(e, t) {
  return "translate(" + e + "," + t + ")";
}
function V2(e) {
  return "rotate(" + e + ")";
}
function Zq(e, t) {
  return "scale(" + e + "," + t + ")";
}
function VO(e) {
  return _a(e.x || 0, e.y || 0);
}
function eW(e) {
  return _a(e.x || 0, e.y || 0) + (e.angle ? " " + V2(e.angle) : "");
}
function tW(e) {
  return _a(e.x || 0, e.y || 0) + (e.angle ? " " + V2(e.angle) : "") + (e.scaleX || e.scaleY ? " " + Zq(e.scaleX || 1, e.scaleY || 1) : "");
}
function Y2(e, t, n) {
  function i(o, a) {
    o("transform", eW(a)), o("d", t(null, a));
  }
  function r(o, a) {
    return t(pd(o, a.angle), a), Fs(o, a).translate(a.x || 0, a.y || 0);
  }
  function s(o, a) {
    var l = a.x || 0, u = a.y || 0, c = a.angle || 0;
    o.translate(l, u), c && o.rotate(c *= yo), o.beginPath(), t(o, a), c && o.rotate(-c), o.translate(-l, -u);
  }
  return {
    type: e,
    tag: "path",
    nested: !1,
    attr: i,
    bound: r,
    draw: H2(s),
    pick: G2(s),
    isect: n || U2(s)
  };
}
var nW = Y2("arc", Bq);
function iW(e, t) {
  for (var n = e[0].orient === "horizontal" ? t[1] : t[0], i = e[0].orient === "horizontal" ? "y" : "x", r = e.length, s = 1 / 0, o, a; --r >= 0; )
    e[r].defined !== !1 && (a = Math.abs(e[r][i] - n), a < s && (s = a, o = e[r]));
  return o;
}
function rW(e, t) {
  for (var n = Math.pow(e[0].strokeWidth || 1, 2), i = e.length, r, s, o; --i >= 0; )
    if (e[i].defined !== !1 && (r = e[i].x - t[0], s = e[i].y - t[1], o = r * r + s * s, o < n))
      return e[i];
  return null;
}
function sW(e, t) {
  for (var n = e.length, i, r, s; --n >= 0; )
    if (e[n].defined !== !1 && (i = e[n].x - t[0], r = e[n].y - t[1], s = i * i + r * r, i = e[n].size || 1, s < i * i))
      return e[n];
  return null;
}
function X2(e, t, n) {
  function i(l, u) {
    var c = u.mark.items;
    c.length && l("d", t(null, c));
  }
  function r(l, u) {
    var c = u.items;
    return c.length === 0 ? l : (t(pd(l), c), Fs(l, c[0]));
  }
  function s(l, u) {
    l.beginPath(), t(l, u);
  }
  const o = md(s);
  function a(l, u, c, f, d, h) {
    var g = u.items, p = u.bounds;
    return !g || !g.length || p && !p.contains(d, h) ? null : (c *= l.pixelRatio, f *= l.pixelRatio, o(l, g, c, f) ? g[0] : null);
  }
  return {
    type: e,
    tag: "path",
    nested: !0,
    attr: i,
    bound: r,
    draw: Qq(s),
    pick: a,
    isect: q2,
    tip: n
  };
}
var oW = X2("area", jq, iW);
function aW(e, t) {
  var n = t.clip;
  e.save(), Ee(n) ? (e.beginPath(), n(e), e.clip()) : YO(e, t.group);
}
function YO(e, t) {
  e.beginPath(), z2(t) ? Hu(e, t, 0, 0) : e.rect(0, 0, t.width || 0, t.height || 0), e.clip();
}
function XO(e) {
  const t = Ni(e.strokeWidth, 1);
  return e.strokeOffset != null ? e.strokeOffset : e.stroke && t > 0.5 && t < 1.5 ? 0.5 - Math.abs(t - 1) : 0;
}
function lW(e, t) {
  e("transform", VO(t));
}
function KO(e, t) {
  const n = XO(t);
  e("d", Hu(null, t, n, n));
}
function uW(e, t) {
  e("class", "background"), e("aria-hidden", !0), KO(e, t);
}
function cW(e, t) {
  e("class", "foreground"), e("aria-hidden", !0), t.strokeForeground ? KO(e, t) : e("d", "");
}
function fW(e, t, n) {
  const i = t.clip ? B2(n, t, t) : null;
  e("clip-path", i);
}
function dW(e, t) {
  if (!t.clip && t.items) {
    const n = t.items, i = n.length;
    for (let r = 0; r < i; ++r)
      e.union(n[r].bounds);
  }
  return (t.clip || t.width || t.height) && !t.noBound && e.add(0, 0).add(t.width || 0, t.height || 0), Fs(e, t), e.translate(t.x || 0, t.y || 0);
}
function Mf(e, t, n, i) {
  const r = XO(t);
  e.beginPath(), Hu(e, t, (n || 0) + r, (i || 0) + r);
}
const hW = md(Mf), gW = md(Mf, !1), pW = md(Mf, !0);
function mW(e, t, n, i) {
  Zi(t, (r) => {
    const s = r.x || 0, o = r.y || 0, a = r.strokeForeground, l = r.opacity == null ? 1 : r.opacity;
    (r.stroke || r.fill) && l && (Mf(e, r, s, o), fu(e, r), r.fill && kg(e, r, l) && e.fill(), r.stroke && !a && du(e, r, l) && e.stroke()), e.save(), e.translate(s, o), r.clip && YO(e, r), n && n.translate(-s, -o), Zi(r, (u) => {
      (u.marktype === "group" || i == null || i.includes(u.marktype)) && this.draw(e, u, n, i);
    }), n && n.translate(s, o), e.restore(), a && r.stroke && l && (Mf(e, r, s, o), fu(e, r), du(e, r, l) && e.stroke());
  });
}
function yW(e, t, n, i, r, s) {
  if (t.bounds && !t.bounds.contains(r, s) || !t.items)
    return null;
  const o = n * e.pixelRatio, a = i * e.pixelRatio;
  return Ag(t, (l) => {
    let u, c, f;
    const d = l.bounds;
    if (d && !d.contains(r, s))
      return;
    c = l.x || 0, f = l.y || 0;
    const h = c + (l.width || 0), g = f + (l.height || 0), p = l.clip;
    if (p && (r < c || r > h || s < f || s > g))
      return;
    if (e.save(), e.translate(c, f), c = r - c, f = s - f, p && z2(l) && !pW(e, l, o, a))
      return e.restore(), null;
    const m = l.strokeForeground, y = t.interactive !== !1;
    return y && m && l.stroke && gW(e, l, o, a) ? (e.restore(), l) : (u = Ag(l, (b) => bW(b, c, f) ? this.pick(b, n, i, c, f) : null), !u && y && (l.fill || !m && l.stroke) && hW(e, l, o, a) && (u = l), e.restore(), u || null);
  });
}
function bW(e, t, n) {
  return (e.interactive !== !1 || e.marktype === "group") && e.bounds && e.bounds.contains(t, n);
}
var vW = {
  type: "group",
  tag: "g",
  nested: !1,
  attr: lW,
  bound: dW,
  draw: mW,
  pick: yW,
  isect: qO,
  content: fW,
  background: uW,
  foreground: cW
}, Ff = {
  xmlns: "http://www.w3.org/2000/svg",
  "xmlns:xlink": "http://www.w3.org/1999/xlink",
  version: "1.1"
};
function K2(e, t) {
  var n = e.image;
  return (!n || e.url && e.url !== n.url) && (n = {
    complete: !1,
    width: 0,
    height: 0
  }, t.loadImage(e.url).then((i) => {
    e.image = i, e.image.url = e.url;
  })), n;
}
function J2(e, t) {
  return e.width != null ? e.width : !t || !t.width ? 0 : e.aspect !== !1 && e.height ? e.height * t.width / t.height : t.width;
}
function Q2(e, t) {
  return e.height != null ? e.height : !t || !t.height ? 0 : e.aspect !== !1 && e.width ? e.width * t.height / t.width : t.height;
}
function Am(e, t) {
  return e === "center" ? t / 2 : e === "right" ? t : 0;
}
function Cm(e, t) {
  return e === "middle" ? t / 2 : e === "bottom" ? t : 0;
}
function xW(e, t, n) {
  const i = K2(t, n), r = J2(t, i), s = Q2(t, i), o = (t.x || 0) - Am(t.align, r), a = (t.y || 0) - Cm(t.baseline, s), l = !i.src && i.toDataURL ? i.toDataURL() : i.src || "";
  e("href", l, Ff["xmlns:xlink"], "xlink:href"), e("transform", _a(o, a)), e("width", r), e("height", s), e("preserveAspectRatio", t.aspect === !1 ? "none" : "xMidYMid");
}
function wW(e, t) {
  const n = t.image, i = J2(t, n), r = Q2(t, n), s = (t.x || 0) - Am(t.align, i), o = (t.y || 0) - Cm(t.baseline, r);
  return e.set(s, o, s + i, o + r);
}
function _W(e, t, n) {
  Zi(t, (i) => {
    if (n && !n.intersects(i.bounds))
      return;
    const r = K2(i, this);
    let s = J2(i, r), o = Q2(i, r);
    if (s === 0 || o === 0)
      return;
    let a = (i.x || 0) - Am(i.align, s), l = (i.y || 0) - Cm(i.baseline, o), u, c, f, d;
    i.aspect !== !1 && (c = r.width / r.height, f = i.width / i.height, c === c && f === f && c !== f && (f < c ? (d = s / c, l += (o - d) / 2, o = d) : (d = o * c, a += (s - d) / 2, s = d))), (r.complete || r.toDataURL) && (fu(e, i), e.globalAlpha = (u = i.opacity) != null ? u : 1, e.imageSmoothingEnabled = i.smooth !== !1, e.drawImage(r, a, l, s, o));
  });
}
var EW = {
  type: "image",
  tag: "image",
  nested: !1,
  attr: xW,
  bound: wW,
  draw: _W,
  pick: km(),
  isect: Ei,
  // bounds check is sufficient
  get: K2,
  xOffset: Am,
  yOffset: Cm
}, SW = X2("line", Uq, rW);
function kW(e, t) {
  var n = t.scaleX || 1, i = t.scaleY || 1;
  (n !== 1 || i !== 1) && e("vector-effect", "non-scaling-stroke"), e("transform", tW(t)), e("d", t.path);
}
function Bh(e, t) {
  var n = t.path;
  if (n == null)
    return !0;
  var i = t.x || 0, r = t.y || 0, s = t.scaleX || 1, o = t.scaleY || 1, a = (t.angle || 0) * yo, l = t.pathCache;
  (!l || l.path !== n) && ((t.pathCache = l = cu(n)).path = n), a && e.rotate && e.translate ? (e.translate(i, r), e.rotate(a), $f(e, l, 0, 0, s, o), e.rotate(-a), e.translate(-i, -r)) : $f(e, l, i, r, s, o);
}
function AW(e, t) {
  return Bh(pd(e, t.angle), t) ? e.set(0, 0, 0, 0) : Fs(e, t, !0);
}
var CW = {
  type: "path",
  tag: "path",
  nested: !1,
  attr: kW,
  bound: AW,
  draw: H2(Bh),
  pick: G2(Bh),
  isect: U2(Bh)
};
function $W(e, t) {
  e("d", Hu(null, t));
}
function MW(e, t) {
  var n, i;
  return Fs(e.set(n = t.x || 0, i = t.y || 0, n + t.width || 0, i + t.height || 0), t);
}
function cA(e, t) {
  e.beginPath(), Hu(e, t);
}
var FW = {
  type: "rect",
  tag: "path",
  nested: !1,
  attr: $W,
  bound: MW,
  draw: H2(cA),
  pick: G2(cA),
  isect: qO
};
function TW(e, t) {
  e("transform", VO(t)), e("x2", t.x2 != null ? t.x2 - (t.x || 0) : 0), e("y2", t.y2 != null ? t.y2 - (t.y || 0) : 0);
}
function OW(e, t) {
  var n, i;
  return Fs(e.set(n = t.x || 0, i = t.y || 0, t.x2 != null ? t.x2 : n, t.y2 != null ? t.y2 : i), t);
}
function JO(e, t, n) {
  var i, r, s, o;
  return t.stroke && du(e, t, n) ? (i = t.x || 0, r = t.y || 0, s = t.x2 != null ? t.x2 : i, o = t.y2 != null ? t.y2 : r, e.beginPath(), e.moveTo(i, r), e.lineTo(s, o), !0) : !1;
}
function NW(e, t, n) {
  Zi(t, (i) => {
    if (!(n && !n.intersects(i.bounds))) {
      var r = i.opacity == null ? 1 : i.opacity;
      r && JO(e, i, r) && (fu(e, i), e.stroke());
    }
  });
}
function DW(e, t, n, i) {
  return e.isPointInStroke ? JO(e, t, 1) && e.isPointInStroke(n, i) : !1;
}
var RW = {
  type: "rule",
  tag: "line",
  nested: !1,
  attr: TW,
  bound: OW,
  draw: NW,
  pick: km(DW),
  isect: WO
}, LW = Y2("shape", qq), PW = Y2("symbol", Wq, q2);
const fA = sF();
var ti = {
  height: zr,
  measureWidth: Z2,
  estimateWidth: Cg,
  width: Cg,
  canvas: QO
};
QO(!0);
function QO(e) {
  ti.width = e && uo ? Z2 : Cg;
}
function Cg(e, t) {
  return ZO(vo(e, t), zr(e));
}
function ZO(e, t) {
  return ~~(0.8 * e.length * t);
}
function Z2(e, t) {
  return zr(e) <= 0 || !(t = vo(e, t)) ? 0 : eN(t, $m(e));
}
function eN(e, t) {
  const n = `(${t}) ${e}`;
  let i = fA.get(n);
  return i === void 0 && (uo.font = t, i = uo.measureText(e).width, fA.set(n, i)), i;
}
function zr(e) {
  return e.fontSize != null ? +e.fontSize || 0 : 11;
}
function bo(e) {
  return e.lineHeight != null ? e.lineHeight : zr(e) + 2;
}
function IW(e) {
  return U(e) ? e.length > 1 ? e : e[0] : e;
}
function yd(e) {
  return IW(e.lineBreak && e.text && !U(e.text) ? e.text.split(e.lineBreak) : e.text);
}
function ew(e) {
  const t = yd(e);
  return (U(t) ? t.length - 1 : 0) * bo(e);
}
function vo(e, t) {
  const n = t == null ? "" : (t + "").trim();
  return e.limit > 0 && n.length ? BW(e, n) : n;
}
function zW(e) {
  if (ti.width === Z2) {
    const t = $m(e);
    return (n) => eN(n, t);
  } else if (ti.width === Cg) {
    const t = zr(e);
    return (n) => ZO(n, t);
  } else
    return (t) => ti.width(e, t);
}
function BW(e, t) {
  var n = +e.limit, i = zW(e);
  if (i(t) < n)
    return t;
  var r = e.ellipsis || "…", s = e.dir === "rtl", o = 0, a = t.length, l;
  if (n -= i(r), s) {
    for (; o < a; )
      l = o + a >>> 1, i(t.slice(l)) > n ? o = l + 1 : a = l;
    return r + t.slice(o);
  } else {
    for (; o < a; )
      l = 1 + (o + a >>> 1), i(t.slice(0, l)) < n ? o = l : a = l - 1;
    return t.slice(0, o) + r;
  }
}
function bd(e, t) {
  var n = e.font;
  return (t && n ? String(n).replace(/"/g, "'") : n) || "sans-serif";
}
function $m(e, t) {
  return (e.fontStyle ? e.fontStyle + " " : "") + (e.fontVariant ? e.fontVariant + " " : "") + (e.fontWeight ? e.fontWeight + " " : "") + zr(e) + "px " + bd(e, t);
}
function tw(e) {
  var t = e.baseline, n = zr(e);
  return Math.round(t === "top" ? 0.79 * n : t === "middle" ? 0.3 * n : t === "bottom" ? -0.21 * n : t === "line-top" ? 0.29 * n + 0.5 * bo(e) : t === "line-bottom" ? 0.29 * n - 0.5 * bo(e) : 0);
}
const jW = {
  left: "start",
  center: "middle",
  right: "end"
}, tf = new pt();
function Mm(e) {
  var t = e.x || 0, n = e.y || 0, i = e.radius || 0, r;
  return i && (r = (e.theta || 0) - aa, t += i * Math.cos(r), n += i * Math.sin(r)), tf.x1 = t, tf.y1 = n, tf;
}
function UW(e, t) {
  var n = t.dx || 0, i = (t.dy || 0) + tw(t), r = Mm(t), s = r.x1, o = r.y1, a = t.angle || 0, l;
  e("text-anchor", jW[t.align] || "start"), a ? (l = _a(s, o) + " " + V2(a), (n || i) && (l += " " + _a(n, i))) : l = _a(s + n, o + i), e("transform", l);
}
function nw(e, t, n) {
  var i = ti.height(t), r = t.align, s = Mm(t), o = s.x1, a = s.y1, l = t.dx || 0, u = (t.dy || 0) + tw(t) - Math.round(0.8 * i), c = yd(t), f;
  if (U(c) ? (i += bo(t) * (c.length - 1), f = c.reduce((d, h) => Math.max(d, ti.width(t, h)), 0)) : f = ti.width(t, c), r === "center" ? l -= f / 2 : r === "right" && (l -= f), e.set(l += o, u += a, l + f, u + i), t.angle && !n)
    e.rotate(t.angle * yo, o, a);
  else if (n === 2)
    return e.rotatedPoints(t.angle * yo, o, a);
  return e;
}
function qW(e, t, n) {
  Zi(t, (i) => {
    var r = i.opacity == null ? 1 : i.opacity, s, o, a, l, u, c, f;
    if (!(n && !n.intersects(i.bounds) || // bounds check
    r === 0 || i.fontSize <= 0 || i.text == null || i.text.length === 0)) {
      if (e.font = $m(i), e.textAlign = i.align || "left", s = Mm(i), o = s.x1, a = s.y1, i.angle && (e.save(), e.translate(o, a), e.rotate(i.angle * yo), o = a = 0), o += i.dx || 0, a += (i.dy || 0) + tw(i), c = yd(i), fu(e, i), U(c))
        for (u = bo(i), l = 0; l < c.length; ++l)
          f = vo(i, c[l]), i.fill && kg(e, i, r) && e.fillText(f, o, a), i.stroke && du(e, i, r) && e.strokeText(f, o, a), a += u;
      else
        f = vo(i, c), i.fill && kg(e, i, r) && e.fillText(f, o, a), i.stroke && du(e, i, r) && e.strokeText(f, o, a);
      i.angle && e.restore();
    }
  });
}
function WW(e, t, n, i, r, s) {
  if (t.fontSize <= 0)
    return !1;
  if (!t.angle)
    return !0;
  var o = Mm(t), a = o.x1, l = o.y1, u = nw(tf, t, 1), c = -t.angle * yo, f = Math.cos(c), d = Math.sin(c), h = f * r - d * s + (a - f * a + d * l), g = d * r + f * s + (l - d * a - f * l);
  return u.contains(h, g);
}
function HW(e, t) {
  const n = nw(tf, e, 2);
  return Rl(t, n[0], n[1], n[2], n[3]) || Rl(t, n[0], n[1], n[4], n[5]) || Rl(t, n[4], n[5], n[6], n[7]) || Rl(t, n[2], n[3], n[6], n[7]);
}
var GW = {
  type: "text",
  tag: "text",
  nested: !1,
  attr: UW,
  bound: nw,
  draw: qW,
  pick: km(WW),
  isect: HW
}, VW = X2("trail", Hq, sW), oi = {
  arc: nW,
  area: oW,
  group: vW,
  image: EW,
  line: SW,
  path: CW,
  rect: FW,
  rule: RW,
  shape: LW,
  symbol: PW,
  text: GW,
  trail: VW
};
function rb(e, t, n) {
  var i = oi[e.mark.marktype], r = t || i.bound;
  return i.nested && (e = e.mark), r(e.bounds || (e.bounds = new pt()), e, n);
}
var dA = {
  mark: null
};
function tN(e, t, n) {
  var i = oi[e.marktype], r = i.bound, s = e.items, o = s && s.length, a, l, u, c;
  if (i.nested)
    return o ? u = s[0] : (dA.mark = e, u = dA), c = rb(u, r, n), t = t && t.union(c) || c, t;
  if (t = t || e.bounds && e.bounds.clear() || new pt(), o)
    for (a = 0, l = s.length; a < l; ++a)
      t.union(rb(s[a], r, n));
  return e.bounds = t;
}
const YW = [
  "marktype",
  "name",
  "role",
  "interactive",
  "clip",
  "items",
  "zindex",
  "x",
  "y",
  "width",
  "height",
  "align",
  "baseline",
  // layout
  "fill",
  "fillOpacity",
  "opacity",
  "blend",
  // fill
  "stroke",
  "strokeOpacity",
  "strokeWidth",
  "strokeCap",
  // stroke
  "strokeDash",
  "strokeDashOffset",
  // stroke dash
  "strokeForeground",
  "strokeOffset",
  // group
  "startAngle",
  "endAngle",
  "innerRadius",
  "outerRadius",
  // arc
  "cornerRadius",
  "padAngle",
  // arc, rect
  "cornerRadiusTopLeft",
  "cornerRadiusTopRight",
  // rect, group
  "cornerRadiusBottomLeft",
  "cornerRadiusBottomRight",
  "interpolate",
  "tension",
  "orient",
  "defined",
  // area, line
  "url",
  "aspect",
  "smooth",
  // image
  "path",
  "scaleX",
  "scaleY",
  // path
  "x2",
  "y2",
  // rule
  "size",
  "shape",
  // symbol
  "text",
  "angle",
  "theta",
  "radius",
  "dir",
  "dx",
  "dy",
  // text
  "ellipsis",
  "limit",
  "lineBreak",
  "lineHeight",
  "font",
  "fontSize",
  "fontWeight",
  "fontStyle",
  "fontVariant",
  // font
  "description",
  "aria",
  "ariaRole",
  "ariaRoleDescription"
  // aria
];
function nN(e, t) {
  return JSON.stringify(e, YW, t);
}
function iN(e) {
  const t = typeof e == "string" ? JSON.parse(e) : e;
  return rN(t);
}
function rN(e) {
  var t = e.marktype, n = e.items, i, r, s;
  if (n)
    for (r = 0, s = n.length; r < s; ++r)
      i = t ? "mark" : "group", n[r][i] = e, n[r].zindex && (n[r][i].zdirty = !0), (t || i) === "group" && rN(n[r]);
  return t && tN(e), e;
}
function iw(e) {
  arguments.length ? this.root = iN(e) : (this.root = sN({
    marktype: "group",
    name: "root",
    role: "frame"
  }), this.root.items = [new Em(this.root)]);
}
iw.prototype = {
  toJSON(e) {
    return nN(this.root, e || 0);
  },
  mark(e, t, n) {
    t = t || this.root.items[0];
    const i = sN(e, t);
    return t.items[n] = i, i.zindex && (i.group.zdirty = !0), i;
  }
};
function sN(e, t) {
  const n = {
    bounds: new pt(),
    clip: !!e.clip,
    group: t,
    interactive: e.interactive !== !1,
    items: [],
    marktype: e.marktype,
    name: e.name || void 0,
    role: e.role || void 0,
    zindex: e.zindex || 0
  };
  return e.aria != null && (n.aria = e.aria), e.description && (n.description = e.description), n;
}
function Js(e, t, n) {
  return !e && typeof document < "u" && document.createElement && (e = document), e ? n ? e.createElementNS(n, t) : e.createElement(t) : null;
}
function rw(e, t) {
  t = t.toLowerCase();
  for (var n = e.childNodes, i = 0, r = n.length; i < r; ++i)
    if (n[i].tagName.toLowerCase() === t)
      return n[i];
}
function vt(e, t, n, i) {
  var r = e.childNodes[t], s;
  return (!r || r.tagName.toLowerCase() !== n.toLowerCase()) && (s = r || null, r = Js(e.ownerDocument, n, i), e.insertBefore(r, s)), r;
}
function di(e, t) {
  for (var n = e.childNodes, i = n.length; i > t; )
    e.removeChild(n[--i]);
  return e;
}
function oN(e) {
  return "mark-" + e.marktype + (e.role ? " role-" + e.role : "") + (e.name ? " " + e.name : "");
}
function Fm(e, t) {
  const n = t.getBoundingClientRect();
  return [e.clientX - n.left - (t.clientLeft || 0), e.clientY - n.top - (t.clientTop || 0)];
}
function XW(e, t, n, i) {
  var r = e && e.mark, s, o;
  if (r && (s = oi[r.marktype]).tip) {
    for (o = Fm(t, n), o[0] -= i[0], o[1] -= i[1]; e = e.mark.group; )
      o[0] -= e.x || 0, o[1] -= e.y || 0;
    e = s.tip(r.items, o);
  }
  return e;
}
function xo(e, t) {
  this._active = null, this._handlers = {}, this._loader = e || Xp(), this._tooltip = t || KW;
}
function KW(e, t, n, i) {
  e.element().setAttribute("title", i || "");
}
xo.prototype = {
  /**
   * Initialize a new Handler instance.
   * @param {DOMElement} el - The containing DOM element for the display.
   * @param {Array<number>} origin - The origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {object} [obj] - Optional context object that should serve as
   *   the "this" context for event callbacks.
   * @return {Handler} - This handler instance.
   */
  initialize(e, t, n) {
    return this._el = e, this._obj = n || null, this.origin(t);
  },
  /**
   * Returns the parent container element for a visualization.
   * @return {DOMElement} - The containing DOM element.
   */
  element() {
    return this._el;
  },
  /**
   * Returns the scene element (e.g., canvas or SVG) of the visualization
   * Subclasses must override if the first child is not the scene element.
   * @return {DOMElement} - The scene (e.g., canvas or SVG) element.
   */
  canvas() {
    return this._el && this._el.firstChild;
  },
  /**
   * Get / set the origin coordinates of the visualization.
   */
  origin(e) {
    return arguments.length ? (this._origin = e || [0, 0], this) : this._origin.slice();
  },
  /**
   * Get / set the scenegraph root.
   */
  scene(e) {
    return arguments.length ? (this._scene = e, this) : this._scene;
  },
  /**
   * Add an event handler. Subclasses should override this method.
   */
  on() {
  },
  /**
   * Remove an event handler. Subclasses should override this method.
   */
  off() {
  },
  /**
   * Utility method for finding the array index of an event handler.
   * @param {Array} h - An array of registered event handlers.
   * @param {string} type - The event type.
   * @param {function} handler - The event handler instance to find.
   * @return {number} - The handler's array index or -1 if not registered.
   */
  _handlerIndex(e, t, n) {
    for (let i = e ? e.length : 0; --i >= 0; )
      if (e[i].type === t && (!n || e[i].handler === n))
        return i;
    return -1;
  },
  /**
   * Returns an array with registered event handlers.
   * @param {string} [type] - The event type to query. Any annotations
   *   are ignored; for example, for the argument "click.foo", ".foo" will
   *   be ignored and the method returns all "click" handlers. If type is
   *   null or unspecified, this method returns handlers for all types.
   * @return {Array} - A new array containing all registered event handlers.
   */
  handlers(e) {
    const t = this._handlers, n = [];
    if (e)
      n.push(...t[this.eventName(e)]);
    else
      for (const i in t)
        n.push(...t[i]);
    return n;
  },
  /**
   * Parses an event name string to return the specific event type.
   * For example, given "click.foo" returns "click"
   * @param {string} name - The input event type string.
   * @return {string} - A string with the event type only.
   */
  eventName(e) {
    const t = e.indexOf(".");
    return t < 0 ? e : e.slice(0, t);
  },
  /**
   * Handle hyperlink navigation in response to an item.href value.
   * @param {Event} event - The event triggering hyperlink navigation.
   * @param {Item} item - The scenegraph item.
   * @param {string} href - The URL to navigate to.
   */
  handleHref(e, t, n) {
    this._loader.sanitize(n, {
      context: "href"
    }).then((i) => {
      const r = new MouseEvent(e.type, e), s = Js(null, "a");
      for (const o in i)
        s.setAttribute(o, i[o]);
      s.dispatchEvent(r);
    }).catch(() => {
    });
  },
  /**
   * Handle tooltip display in response to an item.tooltip value.
   * @param {Event} event - The event triggering tooltip display.
   * @param {Item} item - The scenegraph item.
   * @param {boolean} show - A boolean flag indicating whether
   *   to show or hide a tooltip for the given item.
   */
  handleTooltip(e, t, n) {
    if (t && t.tooltip != null) {
      t = XW(t, e, this.canvas(), this._origin);
      const i = n && t && t.tooltip || null;
      this._tooltip.call(this._obj, this, e, t, i);
    }
  },
  /**
   * Returns the size of a scenegraph item and its position relative
   * to the viewport.
   * @param {Item} item - The scenegraph item.
   * @return {object} - A bounding box object (compatible with the
   *   DOMRect type) consisting of x, y, width, heigh, top, left,
   *   right, and bottom properties.
   */
  getItemBoundingClientRect(e) {
    const t = this.canvas();
    if (!t)
      return;
    const n = t.getBoundingClientRect(), i = this._origin, r = e.bounds, s = r.width(), o = r.height();
    let a = r.x1 + i[0] + n.left, l = r.y1 + i[1] + n.top;
    for (; e.mark && (e = e.mark.group); )
      a += e.x || 0, l += e.y || 0;
    return {
      x: a,
      y: l,
      width: s,
      height: o,
      left: a,
      top: l,
      right: a + s,
      bottom: l + o
    };
  }
};
function ui(e) {
  this._el = null, this._bgcolor = null, this._loader = new j2(e);
}
ui.prototype = {
  /**
   * Initialize a new Renderer instance.
   * @param {DOMElement} el - The containing DOM element for the display.
   * @param {number} width - The coordinate width of the display, in pixels.
   * @param {number} height - The coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {Renderer} - This renderer instance.
   */
  initialize(e, t, n, i, r) {
    return this._el = e, this.resize(t, n, i, r);
  },
  /**
   * Returns the parent container element for a visualization.
   * @return {DOMElement} - The containing DOM element.
   */
  element() {
    return this._el;
  },
  /**
   * Returns the scene element (e.g., canvas or SVG) of the visualization
   * Subclasses must override if the first child is not the scene element.
   * @return {DOMElement} - The scene (e.g., canvas or SVG) element.
   */
  canvas() {
    return this._el && this._el.firstChild;
  },
  /**
   * Get / set the background color.
   */
  background(e) {
    return arguments.length === 0 ? this._bgcolor : (this._bgcolor = e, this);
  },
  /**
   * Resize the display.
   * @param {number} width - The new coordinate width of the display, in pixels.
   * @param {number} height - The new coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The new origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {Renderer} - This renderer instance;
   */
  resize(e, t, n, i) {
    return this._width = e, this._height = t, this._origin = n || [0, 0], this._scale = i || 1, this;
  },
  /**
   * Report a dirty item whose bounds should be redrawn.
   * This base class method does nothing. Subclasses that perform
   * incremental should implement this method.
   * @param {Item} item - The dirty item whose bounds should be redrawn.
   */
  dirty() {
  },
  /**
   * Render an input scenegraph, potentially with a set of dirty items.
   * This method will perform an immediate rendering with available resources.
   * The renderer may also need to perform image loading to perform a complete
   * render. This process can lead to asynchronous re-rendering of the scene
   * after this method returns. To receive notification when rendering is
   * complete, use the renderAsync method instead.
   * @param {object} scene - The root mark of a scenegraph to render.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   * @return {Renderer} - This renderer instance.
   */
  render(e, t) {
    const n = this;
    return n._call = function() {
      n._render(e, t);
    }, n._call(), n._call = null, n;
  },
  /**
   * Internal rendering method. Renderer subclasses should override this
   * method to actually perform rendering.
   * @param {object} scene - The root mark of a scenegraph to render.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   */
  _render() {
  },
  /**
   * Asynchronous rendering method. Similar to render, but returns a Promise
   * that resolves when all rendering is completed. Sometimes a renderer must
   * perform image loading to get a complete rendering. The returned
   * Promise will not resolve until this process completes.
   * @param {object} scene - The root mark of a scenegraph to render.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   * @return {Promise} - A Promise that resolves when rendering is complete.
   */
  renderAsync(e, t) {
    const n = this.render(e, t);
    return this._ready ? this._ready.then(() => n) : Promise.resolve(n);
  },
  /**
   * Internal method for asynchronous resource loading.
   * Proxies method calls to the ImageLoader, and tracks loading
   * progress to invoke a re-render once complete.
   * @param {string} method - The method name to invoke on the ImageLoader.
   * @param {string} uri - The URI for the requested resource.
   * @return {Promise} - A Promise that resolves to the requested resource.
   */
  _load(e, t) {
    var n = this, i = n._loader[e](t);
    if (!n._ready) {
      const r = n._call;
      n._ready = n._loader.ready().then((s) => {
        s && r(), n._ready = null;
      });
    }
    return i;
  },
  /**
   * Sanitize a URL to include as a hyperlink in the rendered scene.
   * This method proxies a call to ImageLoader.sanitizeURL, but also tracks
   * image loading progress and invokes a re-render once complete.
   * @param {string} uri - The URI string to sanitize.
   * @return {Promise} - A Promise that resolves to the sanitized URL.
   */
  sanitizeURL(e) {
    return this._load("sanitizeURL", e);
  },
  /**
   * Requests an image to include in the rendered scene.
   * This method proxies a call to ImageLoader.loadImage, but also tracks
   * image loading progress and invokes a re-render once complete.
   * @param {string} uri - The URI string of the image.
   * @return {Promise} - A Promise that resolves to the loaded Image.
   */
  loadImage(e) {
    return this._load("loadImage", e);
  }
};
const JW = "keydown", QW = "keypress", ZW = "keyup", aN = "dragenter", jh = "dragleave", lN = "dragover", sb = "pointerdown", eH = "pointerup", $g = "pointermove", nf = "pointerout", uN = "pointerover", ob = "mousedown", tH = "mouseup", cN = "mousemove", ab = "mouseout", fN = "mouseover", Mg = "click", nH = "dblclick", iH = "wheel", dN = "mousewheel", Fg = "touchstart", Tg = "touchmove", Og = "touchend", rH = [JW, QW, ZW, aN, jh, lN, sb, eH, $g, nf, uN, ob, tH, cN, ab, fN, Mg, nH, iH, dN, Fg, Tg, Og], lb = $g, Tf = nf, ub = Mg;
function wo(e, t) {
  xo.call(this, e, t), this._down = null, this._touch = null, this._first = !0, this._events = {};
}
const sH = (e) => e === Fg || e === Tg || e === Og ? [Fg, Tg, Og] : [e];
function hA(e, t) {
  sH(t).forEach((n) => oH(e, n));
}
function oH(e, t) {
  const n = e.canvas();
  n && !e._events[t] && (e._events[t] = 1, n.addEventListener(t, e[t] ? (i) => e[t](i) : (i) => e.fire(t, i)));
}
function Ic(e, t, n) {
  t.forEach((i) => e.fire(i, n));
}
function gA(e, t, n) {
  return function(i) {
    const r = this._active, s = this.pickEvent(i);
    s === r ? Ic(this, e, i) : ((!r || !r.exit) && Ic(this, n, i), this._active = s, Ic(this, t, i), Ic(this, e, i));
  };
}
function pA(e) {
  return function(t) {
    Ic(this, e, t), this._active = null;
  };
}
Y(wo, xo, {
  initialize(e, t, n) {
    return this._canvas = e && rw(e, "canvas"), [Mg, ob, sb, $g, nf, jh].forEach((i) => hA(this, i)), xo.prototype.initialize.call(this, e, t, n);
  },
  // return the backing canvas instance
  canvas() {
    return this._canvas;
  },
  // retrieve the current canvas context
  context() {
    return this._canvas.getContext("2d");
  },
  // supported events
  events: rH,
  // to keep old versions of firefox happy
  DOMMouseScroll(e) {
    this.fire(dN, e);
  },
  pointermove: gA([$g, cN], [uN, fN], [nf, ab]),
  dragover: gA([lN], [aN], [jh]),
  pointerout: pA([nf, ab]),
  dragleave: pA([jh]),
  pointerdown(e) {
    this._down = this._active, this.fire(sb, e);
  },
  mousedown(e) {
    this._down = this._active, this.fire(ob, e);
  },
  click(e) {
    this._down === this._active && (this.fire(Mg, e), this._down = null);
  },
  touchstart(e) {
    this._touch = this.pickEvent(e.changedTouches[0]), this._first && (this._active = this._touch, this._first = !1), this.fire(Fg, e, !0);
  },
  touchmove(e) {
    this.fire(Tg, e, !0);
  },
  touchend(e) {
    this.fire(Og, e, !0), this._touch = null;
  },
  // fire an event
  fire(e, t, n) {
    const i = n ? this._touch : this._active, r = this._handlers[e];
    if (t.vegaType = e, e === ub && i && i.href ? this.handleHref(t, i, i.href) : (e === lb || e === Tf) && this.handleTooltip(t, i, e !== Tf), r)
      for (let s = 0, o = r.length; s < o; ++s)
        r[s].handler.call(this._obj, t, i);
  },
  // add an event handler
  on(e, t) {
    const n = this.eventName(e), i = this._handlers;
    return this._handlerIndex(i[n], e, t) < 0 && (hA(this, e), (i[n] || (i[n] = [])).push({
      type: e,
      handler: t
    })), this;
  },
  // remove an event handler
  off(e, t) {
    const n = this.eventName(e), i = this._handlers[n], r = this._handlerIndex(i, e, t);
    return r >= 0 && i.splice(r, 1), this;
  },
  pickEvent(e) {
    const t = Fm(e, this._canvas), n = this._origin;
    return this.pick(this._scene, t[0], t[1], t[0] - n[0], t[1] - n[1]);
  },
  // find the scenegraph item at the current pointer position
  // x, y -- the absolute x, y pointer coordinates on the canvas element
  // gx, gy -- the relative coordinates within the current group
  pick(e, t, n, i, r) {
    const s = this.context();
    return oi[e.marktype].pick.call(this, s, e, t, n, i, r);
  }
});
function aH() {
  return typeof window < "u" && window.devicePixelRatio || 1;
}
function lH(e, t, n, i, r, s) {
  const o = typeof HTMLElement < "u" && e instanceof HTMLElement && e.parentNode != null, a = e.getContext("2d"), l = o ? aH() : r;
  e.width = t * l, e.height = n * l;
  for (const u in s)
    a[u] = s[u];
  return o && l !== 1 && (e.style.width = t + "px", e.style.height = n + "px"), a.pixelRatio = l, a.setTransform(l, 0, 0, l, l * i[0], l * i[1]), e;
}
function Of(e) {
  ui.call(this, e), this._options = {}, this._redraw = !1, this._dirty = new pt(), this._tempb = new pt();
}
const mA = ui.prototype, uH = (e, t, n) => new pt().set(0, 0, t, n).translate(-e[0], -e[1]);
function cH(e, t, n) {
  return t.expand(1).round(), e.pixelRatio % 1 && t.scale(e.pixelRatio).round().scale(1 / e.pixelRatio), t.translate(-(n[0] % 1), -(n[1] % 1)), e.beginPath(), e.rect(t.x1, t.y1, t.width(), t.height()), e.clip(), t;
}
Y(Of, ui, {
  initialize(e, t, n, i, r, s) {
    return this._options = s || {}, this._canvas = this._options.externalContext ? null : lo(1, 1, this._options.type), e && this._canvas && (di(e, 0).appendChild(this._canvas), this._canvas.setAttribute("class", "marks")), mA.initialize.call(this, e, t, n, i, r);
  },
  resize(e, t, n, i) {
    if (mA.resize.call(this, e, t, n, i), this._canvas)
      lH(this._canvas, this._width, this._height, this._origin, this._scale, this._options.context);
    else {
      const r = this._options.externalContext;
      r || j("CanvasRenderer is missing a valid canvas or context"), r.scale(this._scale, this._scale), r.translate(this._origin[0], this._origin[1]);
    }
    return this._redraw = !0, this;
  },
  canvas() {
    return this._canvas;
  },
  context() {
    return this._options.externalContext || (this._canvas ? this._canvas.getContext("2d") : null);
  },
  dirty(e) {
    const t = this._tempb.clear().union(e.bounds);
    let n = e.mark.group;
    for (; n; )
      t.translate(n.x || 0, n.y || 0), n = n.mark.group;
    this._dirty.union(t);
  },
  _render(e, t) {
    const n = this.context(), i = this._origin, r = this._width, s = this._height, o = this._dirty, a = uH(i, r, s);
    n.save();
    const l = this._redraw || o.empty() ? (this._redraw = !1, a.expand(1)) : cH(n, a.intersect(o), i);
    return this.clear(-i[0], -i[1], r, s), this.draw(n, e, l, t), n.restore(), o.clear(), this;
  },
  draw(e, t, n, i) {
    if (t.marktype !== "group" && i != null && !i.includes(t.marktype))
      return;
    const r = oi[t.marktype];
    t.clip && aW(e, t), r.draw.call(this, e, t, n, i), t.clip && e.restore();
  },
  clear(e, t, n, i) {
    const r = this._options, s = this.context();
    r.type !== "pdf" && !r.externalContext && s.clearRect(e, t, n, i), this._bgcolor != null && (s.fillStyle = this._bgcolor, s.fillRect(e, t, n, i));
  }
});
function sw(e, t) {
  xo.call(this, e, t);
  const n = this;
  n._hrefHandler = cb(n, (i, r) => {
    r && r.href && n.handleHref(i, r, r.href);
  }), n._tooltipHandler = cb(n, (i, r) => {
    n.handleTooltip(i, r, i.type !== Tf);
  });
}
const cb = (e, t) => (n) => {
  let i = n.target.__data__;
  i = Array.isArray(i) ? i[0] : i, n.vegaType = n.type, t.call(e._obj, n, i);
};
Y(sw, xo, {
  initialize(e, t, n) {
    let i = this._svg;
    return i && (i.removeEventListener(ub, this._hrefHandler), i.removeEventListener(lb, this._tooltipHandler), i.removeEventListener(Tf, this._tooltipHandler)), this._svg = i = e && rw(e, "svg"), i && (i.addEventListener(ub, this._hrefHandler), i.addEventListener(lb, this._tooltipHandler), i.addEventListener(Tf, this._tooltipHandler)), xo.prototype.initialize.call(this, e, t, n);
  },
  canvas() {
    return this._svg;
  },
  // add an event handler
  on(e, t) {
    const n = this.eventName(e), i = this._handlers;
    if (this._handlerIndex(i[n], e, t) < 0) {
      const s = {
        type: e,
        handler: t,
        listener: cb(this, t)
      };
      (i[n] || (i[n] = [])).push(s), this._svg && this._svg.addEventListener(n, s.listener);
    }
    return this;
  },
  // remove an event handler
  off(e, t) {
    const n = this.eventName(e), i = this._handlers[n], r = this._handlerIndex(i, e, t);
    return r >= 0 && (this._svg && this._svg.removeEventListener(n, i[r].listener), i.splice(r, 1)), this;
  }
});
const hN = "aria-hidden", ow = "aria-label", aw = "role", lw = "aria-roledescription", gN = "graphics-object", uw = "graphics-symbol", pN = (e, t, n) => ({
  [aw]: e,
  [lw]: t,
  [ow]: n || void 0
}), fH = Ji(["axis-domain", "axis-grid", "axis-label", "axis-tick", "axis-title", "legend-band", "legend-entry", "legend-gradient", "legend-label", "legend-title", "legend-symbol", "title"]), yA = {
  axis: {
    desc: "axis",
    caption: gH
  },
  legend: {
    desc: "legend",
    caption: pH
  },
  "title-text": {
    desc: "title",
    caption: (e) => `Title text '${vA(e)}'`
  },
  "title-subtitle": {
    desc: "subtitle",
    caption: (e) => `Subtitle text '${vA(e)}'`
  }
}, bA = {
  ariaRole: aw,
  ariaRoleDescription: lw,
  description: ow
};
function mN(e, t) {
  const n = t.aria === !1;
  if (e(hN, n || void 0), n || t.description == null)
    for (const i in bA)
      e(bA[i], void 0);
  else {
    const i = t.mark.marktype;
    e(ow, t.description), e(aw, t.ariaRole || (i === "group" ? gN : uw)), e(lw, t.ariaRoleDescription || `${i} mark`);
  }
}
function yN(e) {
  return e.aria === !1 ? {
    [hN]: !0
  } : fH[e.role] ? null : yA[e.role] ? hH(e, yA[e.role]) : dH(e);
}
function dH(e) {
  const t = e.marktype, n = t === "group" || t === "text" || e.items.some((i) => i.description != null && i.aria !== !1);
  return pN(n ? gN : uw, `${t} mark container`, e.description);
}
function hH(e, t) {
  try {
    const n = e.items[0], i = t.caption || (() => "");
    return pN(t.role || uw, t.desc, n.description || i(n));
  } catch {
    return null;
  }
}
function vA(e) {
  return ee(e.text).join(" ");
}
function gH(e) {
  const t = e.datum, n = e.orient, i = t.title ? bN(e) : null, r = e.context, s = r.scales[t.scale].value, o = r.dataflow.locale(), a = s.type;
  return `${n === "left" || n === "right" ? "Y" : "X"}-axis` + (i ? ` titled '${i}'` : "") + ` for a ${uu(a) ? "discrete" : a} scale with ${NO(o, s, e)}`;
}
function pH(e) {
  const t = e.datum, n = t.title ? bN(e) : null, i = `${t.type || ""} legend`.trim(), r = t.scales, s = Object.keys(r), o = e.context, a = o.scales[r[s[0]]].value, l = o.dataflow.locale();
  return yH(i) + (n ? ` titled '${n}'` : "") + ` for ${mH(s)} with ${NO(l, a, e)}`;
}
function bN(e) {
  try {
    return ee(Te(e.items).items[0].text).join(" ");
  } catch {
    return null;
  }
}
function mH(e) {
  return e = e.map((t) => t + (t === "fill" || t === "stroke" ? " color" : "")), e.length < 2 ? e[0] : e.slice(0, -1).join(", ") + " and " + Te(e);
}
function yH(e) {
  return e.length ? e[0].toUpperCase() + e.slice(1) : e;
}
const vN = (e) => (e + "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), bH = (e) => vN(e).replace(/"/g, "&quot;").replace(/\t/g, "&#x9;").replace(/\n/g, "&#xA;").replace(/\r/g, "&#xD;");
function cw() {
  let e = "", t = "", n = "";
  const i = [], r = () => t = n = "", s = (l) => {
    t && (e += `${t}>${n}`, r()), i.push(l);
  }, o = (l, u) => (u != null && (t += ` ${l}="${bH(u)}"`), a), a = {
    open(l) {
      s(l), t = "<" + l;
      for (var u = arguments.length, c = new Array(u > 1 ? u - 1 : 0), f = 1; f < u; f++)
        c[f - 1] = arguments[f];
      for (const d of c)
        for (const h in d)
          o(h, d[h]);
      return a;
    },
    close() {
      const l = i.pop();
      return t ? e += t + (n ? `>${n}</${l}>` : "/>") : e += `</${l}>`, r(), a;
    },
    attr: o,
    text: (l) => (n += vN(l), a),
    toString: () => e
  };
  return a;
}
const xN = (e) => wN(cw(), e) + "";
function wN(e, t) {
  if (e.open(t.tagName), t.hasAttributes()) {
    const n = t.attributes, i = n.length;
    for (let r = 0; r < i; ++r)
      e.attr(n[r].name, n[r].value);
  }
  if (t.hasChildNodes()) {
    const n = t.childNodes;
    for (const i of n)
      i.nodeType === 3 ? e.text(i.nodeValue) : wN(e, i);
  }
  return e.close();
}
const Ng = {
  fill: "fill",
  fillOpacity: "fill-opacity",
  stroke: "stroke",
  strokeOpacity: "stroke-opacity",
  strokeWidth: "stroke-width",
  strokeCap: "stroke-linecap",
  strokeJoin: "stroke-linejoin",
  strokeDash: "stroke-dasharray",
  strokeDashOffset: "stroke-dashoffset",
  strokeMiterLimit: "stroke-miterlimit",
  opacity: "opacity"
}, Dg = {
  blend: "mix-blend-mode"
}, _N = {
  fill: "none",
  "stroke-miterlimit": 10
}, gc = 0, xA = "http://www.w3.org/2000/xmlns/", bt = Ff.xmlns;
function Tm(e) {
  ui.call(this, e), this._dirtyID = 0, this._dirty = [], this._svg = null, this._root = null, this._defs = null;
}
const v1 = ui.prototype;
Y(Tm, ui, {
  /**
   * Initialize a new SVGRenderer instance.
   * @param {DOMElement} el - The containing DOM element for the display.
   * @param {number} width - The coordinate width of the display, in pixels.
   * @param {number} height - The coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {SVGRenderer} - This renderer instance.
   */
  initialize(e, t, n, i, r) {
    return this._defs = {}, this._clearDefs(), e && (this._svg = vt(e, 0, "svg", bt), this._svg.setAttributeNS(xA, "xmlns", bt), this._svg.setAttributeNS(xA, "xmlns:xlink", Ff["xmlns:xlink"]), this._svg.setAttribute("version", Ff.version), this._svg.setAttribute("class", "marks"), di(e, 1), this._root = vt(this._svg, gc, "g", bt), Qs(this._root, _N), di(this._svg, gc + 1)), this.background(this._bgcolor), v1.initialize.call(this, e, t, n, i, r);
  },
  /**
   * Get / set the background color.
   */
  background(e) {
    return arguments.length && this._svg && this._svg.style.setProperty("background-color", e), v1.background.apply(this, arguments);
  },
  /**
   * Resize the display.
   * @param {number} width - The new coordinate width of the display, in pixels.
   * @param {number} height - The new coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The new origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {SVGRenderer} - This renderer instance;
   */
  resize(e, t, n, i) {
    return v1.resize.call(this, e, t, n, i), this._svg && (Qs(this._svg, {
      width: this._width * this._scale,
      height: this._height * this._scale,
      viewBox: `0 0 ${this._width} ${this._height}`
    }), this._root.setAttribute("transform", `translate(${this._origin})`)), this._dirty = [], this;
  },
  /**
   * Returns the SVG element of the visualization.
   * @return {DOMElement} - The SVG element.
   */
  canvas() {
    return this._svg;
  },
  /**
   * Returns an SVG text string for the rendered content,
   * or null if this renderer is currently headless.
   */
  svg() {
    const e = this._svg, t = this._bgcolor;
    if (!e)
      return null;
    let n;
    t && (e.removeAttribute("style"), n = vt(e, gc, "rect", bt), Qs(n, {
      width: this._width,
      height: this._height,
      fill: t
    }));
    const i = xN(e);
    return t && (e.removeChild(n), this._svg.style.setProperty("background-color", t)), i;
  },
  /**
   * Internal rendering method.
   * @param {object} scene - The root mark of a scenegraph to render.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   */
  _render(e, t) {
    return this._dirtyCheck() && (this._dirtyAll && this._clearDefs(), this.mark(this._root, e, void 0, t), di(this._root, 1)), this.defs(), this._dirty = [], ++this._dirtyID, this;
  },
  // -- Manage rendering of items marked as dirty --
  /**
   * Flag a mark item as dirty.
   * @param {Item} item - The mark item.
   */
  dirty(e) {
    e.dirty !== this._dirtyID && (e.dirty = this._dirtyID, this._dirty.push(e));
  },
  /**
   * Check if a mark item is considered dirty.
   * @param {Item} item - The mark item.
   */
  isDirty(e) {
    return this._dirtyAll || !e._svg || !e._svg.ownerSVGElement || e.dirty === this._dirtyID;
  },
  /**
   * Internal method to check dirty status and, if possible,
   * make targetted updates without a full rendering pass.
   */
  _dirtyCheck() {
    this._dirtyAll = !0;
    const e = this._dirty;
    if (!e.length || !this._dirtyID)
      return !0;
    const t = ++this._dirtyID;
    let n, i, r, s, o, a, l;
    for (o = 0, a = e.length; o < a; ++o)
      if (n = e[o], i = n.mark, i.marktype !== r && (r = i.marktype, s = oi[r]), i.zdirty && i.dirty !== t && (this._dirtyAll = !1, wA(n, t), i.items.forEach((u) => {
        u.dirty = t;
      })), !i.zdirty) {
        if (n.exit) {
          s.nested && i.items.length ? (l = i.items[0], l._svg && this._update(s, l._svg, l)) : n._svg && (l = n._svg.parentNode, l && l.removeChild(n._svg)), n._svg = null;
          continue;
        }
        n = s.nested ? i.items[0] : n, n._update !== t && (!n._svg || !n._svg.ownerSVGElement ? (this._dirtyAll = !1, wA(n, t)) : this._update(s, n._svg, n), n._update = t);
      }
    return !this._dirtyAll;
  },
  // -- Construct & maintain scenegraph to SVG mapping ---
  /**
   * Render a set of mark items.
   * @param {SVGElement} el - The parent element in the SVG tree.
   * @param {object} scene - The mark parent to render.
   * @param {SVGElement} prev - The previous sibling in the SVG tree.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   */
  mark(e, t, n, i) {
    if (!this.isDirty(t))
      return t._svg;
    const r = this._svg, s = t.marktype, o = oi[s], a = t.interactive === !1 ? "none" : null, l = o.tag === "g", u = _A(t, e, n, "g", r);
    if (s !== "group" && i != null && !i.includes(s))
      return di(u, 0), t._svg;
    u.setAttribute("class", oN(t));
    const c = yN(t);
    for (const g in c)
      fn(u, g, c[g]);
    l || fn(u, "pointer-events", a), fn(u, "clip-path", t.clip ? B2(this, t, t.group) : null);
    let f = null, d = 0;
    const h = (g) => {
      const p = this.isDirty(g), m = _A(g, u, f, o.tag, r);
      p && (this._update(o, m, g), l && wH(this, m, g, i)), f = m, ++d;
    };
    return o.nested ? t.items.length && h(t.items[0]) : Zi(t, h), di(u, d), u;
  },
  /**
   * Update the attributes of an SVG element for a mark item.
   * @param {object} mdef - The mark definition object
   * @param {SVGElement} el - The SVG element.
   * @param {Item} item - The mark item.
   */
  _update(e, t, n) {
    fs = t, Jt = t.__values__, mN(rf, n), e.attr(rf, n, this);
    const i = EH[e.type];
    i && i.call(this, e, t, n), fs && this.style(fs, n);
  },
  /**
   * Update the presentation attributes of an SVG element for a mark item.
   * @param {SVGElement} el - The SVG element.
   * @param {Item} item - The mark item.
   */
  style(e, t) {
    if (t != null) {
      for (const n in Ng) {
        let i = n === "font" ? bd(t) : t[n];
        if (i === Jt[n])
          continue;
        const r = Ng[n];
        i == null ? e.removeAttribute(r) : (P2(i) && (i = RO(i, this._defs.gradient, EN())), e.setAttribute(r, i + "")), Jt[n] = i;
      }
      for (const n in Dg)
        Uh(e, Dg[n], t[n]);
    }
  },
  /**
   * Render SVG defs, as needed.
   * Must be called *after* marks have been processed to ensure the
   * collected state is current and accurate.
   */
  defs() {
    const e = this._svg, t = this._defs;
    let n = t.el, i = 0;
    for (const r in t.gradient)
      n || (t.el = n = vt(e, gc + 1, "defs", bt)), i = vH(n, t.gradient[r], i);
    for (const r in t.clipping)
      n || (t.el = n = vt(e, gc + 1, "defs", bt)), i = xH(n, t.clipping[r], i);
    n && (i === 0 ? (e.removeChild(n), t.el = null) : di(n, i));
  },
  /**
   * Clear defs caches.
   */
  _clearDefs() {
    const e = this._defs;
    e.gradient = {}, e.clipping = {};
  }
});
function wA(e, t) {
  for (; e && e.dirty !== t; e = e.mark.group)
    if (e.dirty = t, e.mark && e.mark.dirty !== t)
      e.mark.dirty = t;
    else
      return;
}
function vH(e, t, n) {
  let i, r, s;
  if (t.gradient === "radial") {
    let o = vt(e, n++, "pattern", bt);
    Qs(o, {
      id: Sg + t.id,
      viewBox: "0,0,1,1",
      width: "100%",
      height: "100%",
      preserveAspectRatio: "xMidYMid slice"
    }), o = vt(o, 0, "rect", bt), Qs(o, {
      width: 1,
      height: 1,
      fill: `url(${EN()}#${t.id})`
    }), e = vt(e, n++, "radialGradient", bt), Qs(e, {
      id: t.id,
      fx: t.x1,
      fy: t.y1,
      fr: t.r1,
      cx: t.x2,
      cy: t.y2,
      r: t.r2
    });
  } else
    e = vt(e, n++, "linearGradient", bt), Qs(e, {
      id: t.id,
      x1: t.x1,
      x2: t.x2,
      y1: t.y1,
      y2: t.y2
    });
  for (i = 0, r = t.stops.length; i < r; ++i)
    s = vt(e, i, "stop", bt), s.setAttribute("offset", t.stops[i].offset), s.setAttribute("stop-color", t.stops[i].color);
  return di(e, i), n;
}
function xH(e, t, n) {
  let i;
  return e = vt(e, n, "clipPath", bt), e.setAttribute("id", t.id), t.path ? (i = vt(e, 0, "path", bt), i.setAttribute("d", t.path)) : (i = vt(e, 0, "rect", bt), Qs(i, {
    x: 0,
    y: 0,
    width: t.width,
    height: t.height
  })), di(e, 1), n + 1;
}
function wH(e, t, n, i) {
  t = t.lastChild.previousSibling;
  let r, s = 0;
  Zi(n, (o) => {
    r = e.mark(t, o, r, i), ++s;
  }), di(t, 1 + s);
}
function _A(e, t, n, i, r) {
  let s = e._svg, o;
  if (!s && (o = t.ownerDocument, s = Js(o, i, bt), e._svg = s, e.mark && (s.__data__ = e, s.__values__ = {
    fill: "default"
  }, i === "g"))) {
    const a = Js(o, "path", bt);
    s.appendChild(a), a.__data__ = e;
    const l = Js(o, "g", bt);
    s.appendChild(l), l.__data__ = e;
    const u = Js(o, "path", bt);
    s.appendChild(u), u.__data__ = e, u.__values__ = {
      fill: "default"
    };
  }
  return (s.ownerSVGElement !== r || _H(s, n)) && t.insertBefore(s, n ? n.nextSibling : t.firstChild), s;
}
function _H(e, t) {
  return e.parentNode && e.parentNode.childNodes.length > 1 && e.previousSibling != t;
}
let fs = null, Jt = null;
const EH = {
  group(e, t, n) {
    const i = fs = t.childNodes[2];
    Jt = i.__values__, e.foreground(rf, n, this), Jt = t.__values__, fs = t.childNodes[1], e.content(rf, n, this);
    const r = fs = t.childNodes[0];
    e.background(rf, n, this);
    const s = n.mark.interactive === !1 ? "none" : null;
    if (s !== Jt.events && (fn(i, "pointer-events", s), fn(r, "pointer-events", s), Jt.events = s), n.strokeForeground && n.stroke) {
      const o = n.fill;
      fn(i, "display", null), this.style(r, n), fn(r, "stroke", null), o && (n.fill = null), Jt = i.__values__, this.style(i, n), o && (n.fill = o), fs = null;
    } else
      fn(i, "display", "none");
  },
  image(e, t, n) {
    n.smooth === !1 ? (Uh(t, "image-rendering", "optimizeSpeed"), Uh(t, "image-rendering", "pixelated")) : Uh(t, "image-rendering", null);
  },
  text(e, t, n) {
    const i = yd(n);
    let r, s, o, a;
    U(i) ? (s = i.map((l) => vo(n, l)), r = s.join(`
`), r !== Jt.text && (di(t, 0), o = t.ownerDocument, a = bo(n), s.forEach((l, u) => {
      const c = Js(o, "tspan", bt);
      c.__data__ = n, c.textContent = l, u && (c.setAttribute("x", 0), c.setAttribute("dy", a)), t.appendChild(c);
    }), Jt.text = r)) : (s = vo(n, i), s !== Jt.text && (t.textContent = s, Jt.text = s)), fn(t, "font-family", bd(n)), fn(t, "font-size", zr(n) + "px"), fn(t, "font-style", n.fontStyle), fn(t, "font-variant", n.fontVariant), fn(t, "font-weight", n.fontWeight);
  }
};
function rf(e, t, n) {
  t !== Jt[e] && (n ? SH(fs, e, t, n) : fn(fs, e, t), Jt[e] = t);
}
function Uh(e, t, n) {
  n !== Jt[t] && (n == null ? e.style.removeProperty(t) : e.style.setProperty(t, n + ""), Jt[t] = n);
}
function Qs(e, t) {
  for (const n in t)
    fn(e, n, t[n]);
}
function fn(e, t, n) {
  n != null ? e.setAttribute(t, n) : e.removeAttribute(t);
}
function SH(e, t, n, i) {
  n != null ? e.setAttributeNS(i, t, n) : e.removeAttributeNS(i, t);
}
function EN() {
  let e;
  return typeof window > "u" ? "" : (e = window.location).hash ? e.href.slice(0, -e.hash.length) : e.href;
}
function fw(e) {
  ui.call(this, e), this._text = null, this._defs = {
    gradient: {},
    clipping: {}
  };
}
Y(fw, ui, {
  /**
   * Returns the rendered SVG text string,
   * or null if rendering has not yet occurred.
   */
  svg() {
    return this._text;
  },
  /**
   * Internal rendering method.
   * @param {object} scene - The root mark of a scenegraph to render.
   */
  _render(e) {
    const t = cw();
    t.open("svg", we({}, Ff, {
      class: "marks",
      width: this._width * this._scale,
      height: this._height * this._scale,
      viewBox: `0 0 ${this._width} ${this._height}`
    }));
    const n = this._bgcolor;
    return n && n !== "transparent" && n !== "none" && t.open("rect", {
      width: this._width,
      height: this._height,
      fill: n
    }).close(), t.open("g", _N, {
      transform: "translate(" + this._origin + ")"
    }), this.mark(t, e), t.close(), this.defs(t), this._text = t.close() + "", this;
  },
  /**
   * Render a set of mark items.
   * @param {object} m - The markup context.
   * @param {object} scene - The mark parent to render.
   */
  mark(e, t) {
    const n = oi[t.marktype], i = n.tag, r = [mN, n.attr];
    e.open("g", {
      class: oN(t),
      "clip-path": t.clip ? B2(this, t, t.group) : null
    }, yN(t), {
      "pointer-events": i !== "g" && t.interactive === !1 ? "none" : null
    });
    const s = (o) => {
      const a = this.href(o);
      if (a && e.open("a", a), e.open(i, this.attr(t, o, r, i !== "g" ? i : null)), i === "text") {
        const l = yd(o);
        if (U(l)) {
          const u = {
            x: 0,
            dy: bo(o)
          };
          for (let c = 0; c < l.length; ++c)
            e.open("tspan", c ? u : null).text(vo(o, l[c])).close();
        } else
          e.text(vo(o, l));
      } else if (i === "g") {
        const l = o.strokeForeground, u = o.fill, c = o.stroke;
        l && c && (o.stroke = null), e.open("path", this.attr(t, o, n.background, "bgrect")).close(), e.open("g", this.attr(t, o, n.content)), Zi(o, (f) => this.mark(e, f)), e.close(), l && c ? (u && (o.fill = null), o.stroke = c, e.open("path", this.attr(t, o, n.foreground, "bgrect")).close(), u && (o.fill = u)) : e.open("path", this.attr(t, o, n.foreground, "bgfore")).close();
      }
      e.close(), a && e.close();
    };
    return n.nested ? t.items && t.items.length && s(t.items[0]) : Zi(t, s), e.close();
  },
  /**
   * Get href attributes for a hyperlinked mark item.
   * @param {Item} item - The mark item.
   */
  href(e) {
    const t = e.href;
    let n;
    if (t) {
      if (n = this._hrefs && this._hrefs[t])
        return n;
      this.sanitizeURL(t).then((i) => {
        i["xlink:href"] = i.href, i.href = null, (this._hrefs || (this._hrefs = {}))[t] = i;
      });
    }
    return null;
  },
  /**
   * Get an object of SVG attributes for a mark item.
   * @param {object} scene - The mark parent.
   * @param {Item} item - The mark item.
   * @param {array|function} attrs - One or more attribute emitters.
   * @param {string} tag - The tag being rendered.
   */
  attr(e, t, n, i) {
    const r = {}, s = (o, a, l, u) => {
      r[u || o] = a;
    };
    return Array.isArray(n) ? n.forEach((o) => o(s, t, this)) : n(s, t, this), i && kH(r, t, e, i, this._defs), r;
  },
  /**
   * Render SVG defs, as needed.
   * Must be called *after* marks have been processed to ensure the
   * collected state is current and accurate.
   * @param {object} m - The markup context.
   */
  defs(e) {
    const t = this._defs.gradient, n = this._defs.clipping;
    if (Object.keys(t).length + Object.keys(n).length !== 0) {
      e.open("defs");
      for (const r in t) {
        const s = t[r], o = s.stops;
        s.gradient === "radial" ? (e.open("pattern", {
          id: Sg + r,
          viewBox: "0,0,1,1",
          width: "100%",
          height: "100%",
          preserveAspectRatio: "xMidYMid slice"
        }), e.open("rect", {
          width: "1",
          height: "1",
          fill: "url(#" + r + ")"
        }).close(), e.close(), e.open("radialGradient", {
          id: r,
          fx: s.x1,
          fy: s.y1,
          fr: s.r1,
          cx: s.x2,
          cy: s.y2,
          r: s.r2
        })) : e.open("linearGradient", {
          id: r,
          x1: s.x1,
          x2: s.x2,
          y1: s.y1,
          y2: s.y2
        });
        for (let a = 0; a < o.length; ++a)
          e.open("stop", {
            offset: o[a].offset,
            "stop-color": o[a].color
          }).close();
        e.close();
      }
      for (const r in n) {
        const s = n[r];
        e.open("clipPath", {
          id: r
        }), s.path ? e.open("path", {
          d: s.path
        }).close() : e.open("rect", {
          x: 0,
          y: 0,
          width: s.width,
          height: s.height
        }).close(), e.close();
      }
      e.close();
    }
  }
});
function kH(e, t, n, i, r) {
  let s;
  if (t == null || (i === "bgrect" && n.interactive === !1 && (e["pointer-events"] = "none"), i === "bgfore" && (n.interactive === !1 && (e["pointer-events"] = "none"), e.display = "none", t.fill !== null)))
    return e;
  i === "image" && t.smooth === !1 && (s = ["image-rendering: optimizeSpeed;", "image-rendering: pixelated;"]), i === "text" && (e["font-family"] = bd(t), e["font-size"] = zr(t) + "px", e["font-style"] = t.fontStyle, e["font-variant"] = t.fontVariant, e["font-weight"] = t.fontWeight);
  for (const o in Ng) {
    let a = t[o];
    const l = Ng[o];
    a === "transparent" && (l === "fill" || l === "stroke") || a != null && (P2(a) && (a = RO(a, r.gradient, "")), e[l] = a);
  }
  for (const o in Dg) {
    const a = t[o];
    a != null && (s = s || [], s.push(`${Dg[o]}: ${a};`));
  }
  return s && (e.style = s.join(" ")), e;
}
const Pi = {
  svgMarkTypes: ["text"],
  svgOnTop: !0,
  debug: !1
};
function AH(e) {
  Pi.svgMarkTypes = e.svgMarkTypes ?? ["text"], Pi.svgOnTop = e.svgOnTop ?? !0, Pi.debug = e.debug ?? !1;
}
function Rg(e) {
  ui.call(this, e), this._svgRenderer = new Tm(e), this._canvasRenderer = new Of(e);
}
const EA = ui.prototype;
Y(Rg, ui, {
  /**
   * Initialize a new HybridRenderer instance.
   * @param {DOMElement} el - The containing DOM element for the display.
   * @param {number} width - The coordinate width of the display, in pixels.
   * @param {number} height - The coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {HybridRenderer} - This renderer instance.
   */
  initialize(e, t, n, i, r) {
    this._root_el = vt(e, 0, "div");
    const s = vt(this._root_el, 0, "div"), o = vt(this._root_el, 1, "div");
    return this._root_el.style.position = "relative", Pi.debug || (s.style.height = "100%", o.style.position = "absolute", o.style.top = "0", o.style.left = "0", o.style.height = "100%", o.style.width = "100%"), this._svgEl = Pi.svgOnTop ? o : s, this._canvasEl = Pi.svgOnTop ? s : o, this._svgEl.style.pointerEvents = "none", this._canvasRenderer.initialize(this._canvasEl, t, n, i, r), this._svgRenderer.initialize(this._svgEl, t, n, i, r), EA.initialize.call(this, e, t, n, i, r);
  },
  /**
   * Flag a mark item as dirty.
   * @param {Item} item - The mark item.
   */
  dirty(e) {
    return Pi.svgMarkTypes.includes(e.mark.marktype) ? this._svgRenderer.dirty(e) : this._canvasRenderer.dirty(e), this;
  },
  /**
   * Internal rendering method.
   * @param {object} scene - The root mark of a scenegraph to render.
   * @param {Array} markTypes - Array of the mark types to render.
   *                            If undefined, render all mark types
   */
  _render(e, t) {
    const i = (t ?? ["arc", "area", "image", "line", "path", "rect", "rule", "shape", "symbol", "text", "trail"]).filter((r) => !Pi.svgMarkTypes.includes(r));
    this._svgRenderer.render(e, Pi.svgMarkTypes), this._canvasRenderer.render(e, i);
  },
  /**
   * Resize the display.
   * @param {number} width - The new coordinate width of the display, in pixels.
   * @param {number} height - The new coordinate height of the display, in pixels.
   * @param {Array<number>} origin - The new origin of the display, in pixels.
   *   The coordinate system will be translated to this point.
   * @param {number} [scaleFactor=1] - Optional scaleFactor by which to multiply
   *   the width and height to determine the final pixel size.
   * @return {SVGRenderer} - This renderer instance;
   */
  resize(e, t, n, i) {
    return EA.resize.call(this, e, t, n, i), this._svgRenderer.resize(e, t, n, i), this._canvasRenderer.resize(e, t, n, i), this;
  },
  background(e) {
    return Pi.svgOnTop ? this._canvasRenderer.background(e) : this._svgRenderer.background(e), this;
  }
});
function dw(e, t) {
  wo.call(this, e, t);
}
Y(dw, wo, {
  initialize(e, t, n) {
    const i = vt(vt(e, 0, "div"), Pi.svgOnTop ? 0 : 1, "div");
    return wo.prototype.initialize.call(this, i, t, n);
  }
});
const SN = "canvas", kN = "hybrid", AN = "png", CN = "svg", $N = "none", Zs = {
  Canvas: SN,
  PNG: AN,
  SVG: CN,
  Hybrid: kN,
  None: $N
}, Oa = {};
Oa[SN] = Oa[AN] = {
  renderer: Of,
  headless: Of,
  handler: wo
};
Oa[CN] = {
  renderer: Tm,
  headless: fw,
  handler: sw
};
Oa[kN] = {
  renderer: Rg,
  headless: Rg,
  handler: dw
};
Oa[$N] = {};
function Om(e, t) {
  return e = String(e || "").toLowerCase(), arguments.length > 1 ? (Oa[e] = t, this) : Oa[e];
}
function MN(e, t, n) {
  const i = [], r = new pt().union(t), s = e.marktype;
  return s ? FN(e, r, n, i) : s === "group" ? TN(e, r, n, i) : j("Intersect scene must be mark node or group item.");
}
function FN(e, t, n, i) {
  if (CH(e, t, n)) {
    const r = e.items, s = e.marktype, o = r.length;
    let a = 0;
    if (s === "group")
      for (; a < o; ++a)
        TN(r[a], t, n, i);
    else
      for (const l = oi[s].isect; a < o; ++a) {
        const u = r[a];
        ON(u, t, l) && i.push(u);
      }
  }
  return i;
}
function CH(e, t, n) {
  return e.bounds && t.intersects(e.bounds) && (e.marktype === "group" || e.interactive !== !1 && (!n || n(e)));
}
function TN(e, t, n, i) {
  n && n(e.mark) && ON(e, t, oi.group.isect) && i.push(e);
  const r = e.items, s = r && r.length;
  if (s) {
    const o = e.x || 0, a = e.y || 0;
    t.translate(-o, -a);
    for (let l = 0; l < s; ++l)
      FN(r[l], t, n, i);
    t.translate(o, a);
  }
  return i;
}
function ON(e, t, n) {
  const i = e.bounds;
  return t.encloses(i) || t.intersects(i) && n(e, t);
}
const x1 = new pt();
function NN(e) {
  const t = e.clip;
  if (Ee(t))
    t(pd(x1.clear()));
  else if (t)
    x1.set(0, 0, e.group.width, e.group.height);
  else
    return;
  e.bounds.intersect(x1);
}
const $H = 1e-9;
function hw(e, t, n) {
  return e === t ? !0 : n === "path" ? DN(e, t) : e instanceof Date && t instanceof Date ? +e == +t : Re(e) && Re(t) ? Math.abs(e - t) <= $H : !e || !t || !ne(e) && !ne(t) ? e == t : MH(e, t);
}
function DN(e, t) {
  return hw(cu(e), cu(t));
}
function MH(e, t) {
  var n = Object.keys(e), i = Object.keys(t), r, s;
  if (n.length !== i.length)
    return !1;
  for (n.sort(), i.sort(), s = n.length - 1; s >= 0; s--)
    if (n[s] != i[s])
      return !1;
  for (s = n.length - 1; s >= 0; s--)
    if (r = n[s], !hw(e[r], t[r], r))
      return !1;
  return typeof e == typeof t;
}
function FH() {
  UO(), eq();
}
const hu = "top", Ui = "left", qi = "right", _o = "bottom", TH = "top-left", OH = "top-right", NH = "bottom-left", DH = "bottom-right", gw = "start", fb = "middle", dn = "end", RH = "x", LH = "y", Nm = "group", pw = "axis", mw = "title", PH = "frame", IH = "scope", yw = "legend", RN = "row-header", LN = "row-footer", PN = "row-title", IN = "column-header", zN = "column-footer", BN = "column-title", zH = "padding", BH = "symbol", jN = "fit", UN = "fit-x", qN = "fit-y", jH = "pad", bw = "none", eh = "all", db = "each", vw = "flush", eo = "column", to = "row";
function WN(e) {
  I.call(this, null, e);
}
Y(WN, I, {
  transform(e, t) {
    const n = t.dataflow, i = e.mark, r = i.marktype, s = oi[r], o = s.bound;
    let a = i.bounds, l;
    if (s.nested)
      i.items.length && n.dirty(i.items[0]), a = th(i, o), i.items.forEach((u) => {
        u.bounds.clear().union(a);
      });
    else if (r === Nm || e.modified())
      switch (t.visit(t.MOD, (u) => n.dirty(u)), a.clear(), i.items.forEach((u) => a.union(th(u, o))), i.role) {
        case pw:
        case yw:
        case mw:
          t.reflow();
      }
    else
      l = t.changed(t.REM), t.visit(t.ADD, (u) => {
        a.union(th(u, o));
      }), t.visit(t.MOD, (u) => {
        l = l || a.alignsWith(u.bounds), n.dirty(u), a.union(th(u, o));
      }), l && (a.clear(), i.items.forEach((u) => a.union(u.bounds)));
    return NN(i), t.modifies("bounds");
  }
});
function th(e, t, n) {
  return t(e.bounds.clear(), e, n);
}
const SA = ":vega_identifier:";
function xw(e) {
  I.call(this, 0, e);
}
xw.Definition = {
  type: "Identifier",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "as",
    type: "string",
    required: !0
  }]
};
Y(xw, I, {
  transform(e, t) {
    const n = UH(t.dataflow), i = e.as;
    let r = n.value;
    return t.visit(t.ADD, (s) => s[i] = s[i] || ++r), n.set(this.value = r), t;
  }
});
function UH(e) {
  return e._signals[SA] || (e._signals[SA] = e.add(0));
}
function HN(e) {
  I.call(this, null, e);
}
Y(HN, I, {
  transform(e, t) {
    let n = this.value;
    n || (n = t.dataflow.scenegraph().mark(e.markdef, qH(e), e.index), n.group.context = e.context, e.context.group || (e.context.group = n.group), n.source = this.source, n.clip = e.clip, n.interactive = e.interactive, this.value = n);
    const i = n.marktype === Nm ? Em : _m;
    return t.visit(t.ADD, (r) => i.call(r, n)), (e.modified("clip") || e.modified("interactive")) && (n.clip = e.clip, n.interactive = !!e.interactive, n.zdirty = !0, t.reflow()), n.items = t.source, t;
  }
});
function qH(e) {
  const t = e.groups, n = e.parent;
  return t && t.size === 1 ? t.get(Object.keys(t.object)[0]) : t && n ? t.lookup(n) : null;
}
function GN(e) {
  I.call(this, null, e);
}
const kA = {
  parity: (e) => e.filter((t, n) => n % 2 ? t.opacity = 0 : 1),
  greedy: (e, t) => {
    let n;
    return e.filter((i, r) => !r || !VN(n.bounds, i.bounds, t) ? (n = i, 1) : i.opacity = 0);
  }
}, VN = (e, t, n) => n > Math.max(t.x1 - e.x2, e.x1 - t.x2, t.y1 - e.y2, e.y1 - t.y2), AA = (e, t) => {
  for (var n = 1, i = e.length, r = e[0].bounds, s; n < i; r = s, ++n)
    if (VN(r, s = e[n].bounds, t))
      return !0;
}, WH = (e) => {
  const t = e.bounds;
  return t.width() > 1 && t.height() > 1;
}, HH = (e, t, n) => {
  var i = e.range(), r = new pt();
  return t === hu || t === _o ? r.set(i[0], -1 / 0, i[1], 1 / 0) : r.set(-1 / 0, i[0], 1 / 0, i[1]), r.expand(n || 1), (s) => r.encloses(s.bounds);
}, CA = (e) => (e.forEach((t) => t.opacity = 1), e), $A = (e, t) => e.reflow(t.modified()).modifies("opacity");
Y(GN, I, {
  transform(e, t) {
    const n = kA[e.method] || kA.parity, i = e.separation || 0;
    let r = t.materialize(t.SOURCE).source, s, o;
    if (!r || !r.length)
      return;
    if (!e.method)
      return e.modified("method") && (CA(r), t = $A(t, e)), t;
    if (r = r.filter(WH), !r.length)
      return;
    if (e.sort && (r = r.slice().sort(e.sort)), s = CA(r), t = $A(t, e), s.length >= 3 && AA(s, i)) {
      do
        s = n(s, i);
      while (s.length >= 3 && AA(s, i));
      s.length < 3 && !Te(r).opacity && (s.length > 1 && (Te(s).opacity = 0), Te(r).opacity = 1);
    }
    e.boundScale && e.boundTolerance >= 0 && (o = HH(e.boundScale, e.boundOrient, +e.boundTolerance), r.forEach((l) => {
      o(l) || (l.opacity = 0);
    }));
    const a = s[0].mark.bounds.clear();
    return r.forEach((l) => {
      l.opacity && a.union(l.bounds);
    }), t;
  }
});
function YN(e) {
  I.call(this, null, e);
}
Y(YN, I, {
  transform(e, t) {
    const n = t.dataflow;
    if (t.visit(t.ALL, (i) => n.dirty(i)), t.fields && t.fields.zindex) {
      const i = t.source && t.source[0];
      i && (i.mark.zdirty = !0);
    }
  }
});
const Kt = new pt();
function Ll(e, t, n) {
  return e[t] === n ? 0 : (e[t] = n, 1);
}
function GH(e) {
  var t = e.items[0].orient;
  return t === Ui || t === qi;
}
function VH(e) {
  let t = +e.grid;
  return [
    e.ticks ? t++ : -1,
    // ticks index
    e.labels ? t++ : -1,
    // labels index
    t + +e.domain
    // title index
  ];
}
function YH(e, t, n, i) {
  var r = t.items[0], s = r.datum, o = r.translate != null ? r.translate : 0.5, a = r.orient, l = VH(s), u = r.range, c = r.offset, f = r.position, d = r.minExtent, h = r.maxExtent, g = s.title && r.items[l[2]].items[0], p = r.titlePadding, m = r.bounds, y = g && ew(g), b = 0, v = 0, _, x;
  switch (Kt.clear().union(m), m.clear(), (_ = l[0]) > -1 && m.union(r.items[_].bounds), (_ = l[1]) > -1 && m.union(r.items[_].bounds), a) {
    case hu:
      b = f || 0, v = -c, x = Math.max(d, Math.min(h, -m.y1)), m.add(0, -x).add(u, 0), g && nh(e, g, x, p, y, 0, -1, m);
      break;
    case Ui:
      b = -c, v = f || 0, x = Math.max(d, Math.min(h, -m.x1)), m.add(-x, 0).add(0, u), g && nh(e, g, x, p, y, 1, -1, m);
      break;
    case qi:
      b = n + c, v = f || 0, x = Math.max(d, Math.min(h, m.x2)), m.add(0, 0).add(x, u), g && nh(e, g, x, p, y, 1, 1, m);
      break;
    case _o:
      b = f || 0, v = i + c, x = Math.max(d, Math.min(h, m.y2)), m.add(0, 0).add(u, x), g && nh(e, g, x, p, 0, 0, 1, m);
      break;
    default:
      b = r.x, v = r.y;
  }
  return Fs(m.translate(b, v), r), Ll(r, "x", b + o) | Ll(r, "y", v + o) && (r.bounds = Kt, e.dirty(r), r.bounds = m, e.dirty(r)), r.mark.bounds.clear().union(m);
}
function nh(e, t, n, i, r, s, o, a) {
  const l = t.bounds;
  if (t.auto) {
    const u = o * (n + r + i);
    let c = 0, f = 0;
    e.dirty(t), s ? c = (t.x || 0) - (t.x = u) : f = (t.y || 0) - (t.y = u), t.mark.bounds.clear().union(l.translate(-c, -f)), e.dirty(t);
  }
  a.union(l);
}
const MA = (e, t) => Math.floor(Math.min(e, t)), FA = (e, t) => Math.ceil(Math.max(e, t));
function XH(e) {
  var t = e.items, n = t.length, i = 0, r, s;
  const o = {
    marks: [],
    rowheaders: [],
    rowfooters: [],
    colheaders: [],
    colfooters: [],
    rowtitle: null,
    coltitle: null
  };
  for (; i < n; ++i)
    if (r = t[i], s = r.items, r.marktype === Nm)
      switch (r.role) {
        case pw:
        case yw:
        case mw:
          break;
        case RN:
          o.rowheaders.push(...s);
          break;
        case LN:
          o.rowfooters.push(...s);
          break;
        case IN:
          o.colheaders.push(...s);
          break;
        case zN:
          o.colfooters.push(...s);
          break;
        case PN:
          o.rowtitle = s[0];
          break;
        case BN:
          o.coltitle = s[0];
          break;
        default:
          o.marks.push(...s);
      }
  return o;
}
function KH(e) {
  return new pt().set(0, 0, e.width || 0, e.height || 0);
}
function JH(e) {
  const t = e.bounds.clone();
  return t.empty() ? t.set(0, 0, 0, 0) : t.translate(-(e.x || 0), -(e.y || 0));
}
function et(e, t, n) {
  const i = ne(e) ? e[t] : e;
  return i ?? (n !== void 0 ? n : 0);
}
function TA(e) {
  return e < 0 ? Math.ceil(-e) : 0;
}
function XN(e, t, n) {
  var i = !n.nodirty, r = n.bounds === vw ? KH : JH, s = Kt.set(0, 0, 0, 0), o = et(n.align, eo), a = et(n.align, to), l = et(n.padding, eo), u = et(n.padding, to), c = n.columns || t.length, f = c <= 0 ? 1 : Math.ceil(t.length / c), d = t.length, h = Array(d), g = Array(c), p = 0, m = Array(d), y = Array(f), b = 0, v = Array(d), _ = Array(d), x = Array(d), S, E, C, $, N, O, P, T, D, M, w;
  for (E = 0; E < c; ++E)
    g[E] = 0;
  for (E = 0; E < f; ++E)
    y[E] = 0;
  for (E = 0; E < d; ++E)
    O = t[E], N = x[E] = r(O), O.x = O.x || 0, v[E] = 0, O.y = O.y || 0, _[E] = 0, C = E % c, $ = ~~(E / c), p = Math.max(p, P = Math.ceil(N.x2)), b = Math.max(b, T = Math.ceil(N.y2)), g[C] = Math.max(g[C], P), y[$] = Math.max(y[$], T), h[E] = l + TA(N.x1), m[E] = u + TA(N.y1), i && e.dirty(t[E]);
  for (E = 0; E < d; ++E)
    E % c === 0 && (h[E] = 0), E < c && (m[E] = 0);
  if (o === db)
    for (C = 1; C < c; ++C) {
      for (w = 0, E = C; E < d; E += c)
        w < h[E] && (w = h[E]);
      for (E = C; E < d; E += c)
        h[E] = w + g[C - 1];
    }
  else if (o === eh) {
    for (w = 0, E = 0; E < d; ++E)
      E % c && w < h[E] && (w = h[E]);
    for (E = 0; E < d; ++E)
      E % c && (h[E] = w + p);
  } else
    for (o = !1, C = 1; C < c; ++C)
      for (E = C; E < d; E += c)
        h[E] += g[C - 1];
  if (a === db)
    for ($ = 1; $ < f; ++$) {
      for (w = 0, E = $ * c, S = E + c; E < S; ++E)
        w < m[E] && (w = m[E]);
      for (E = $ * c; E < S; ++E)
        m[E] = w + y[$ - 1];
    }
  else if (a === eh) {
    for (w = 0, E = c; E < d; ++E)
      w < m[E] && (w = m[E]);
    for (E = c; E < d; ++E)
      m[E] = w + b;
  } else
    for (a = !1, $ = 1; $ < f; ++$)
      for (E = $ * c, S = E + c; E < S; ++E)
        m[E] += y[$ - 1];
  for (D = 0, E = 0; E < d; ++E)
    D = h[E] + (E % c ? D : 0), v[E] += D - t[E].x;
  for (C = 0; C < c; ++C)
    for (M = 0, E = C; E < d; E += c)
      M += m[E], _[E] += M - t[E].y;
  if (o && et(n.center, eo) && f > 1)
    for (E = 0; E < d; ++E)
      N = o === eh ? p : g[E % c], D = N - x[E].x2 - t[E].x - v[E], D > 0 && (v[E] += D / 2);
  if (a && et(n.center, to) && c !== 1)
    for (E = 0; E < d; ++E)
      N = a === eh ? b : y[~~(E / c)], M = N - x[E].y2 - t[E].y - _[E], M > 0 && (_[E] += M / 2);
  for (E = 0; E < d; ++E)
    s.union(x[E].translate(v[E], _[E]));
  switch (D = et(n.anchor, RH), M = et(n.anchor, LH), et(n.anchor, eo)) {
    case dn:
      D -= s.width();
      break;
    case fb:
      D -= s.width() / 2;
  }
  switch (et(n.anchor, to)) {
    case dn:
      M -= s.height();
      break;
    case fb:
      M -= s.height() / 2;
  }
  for (D = Math.round(D), M = Math.round(M), s.clear(), E = 0; E < d; ++E)
    t[E].mark.bounds.clear();
  for (E = 0; E < d; ++E)
    O = t[E], O.x += v[E] += D, O.y += _[E] += M, s.union(O.mark.bounds.union(O.bounds.translate(v[E], _[E]))), i && e.dirty(O);
  return s;
}
function QH(e, t, n) {
  var i = XH(t), r = i.marks, s = n.bounds === vw ? ZH : eG, o = n.offset, a = n.columns || r.length, l = a <= 0 ? 1 : Math.ceil(r.length / a), u = l * a, c, f, d, h, g, p, m;
  const y = XN(e, r, n);
  y.empty() && y.set(0, 0, 0, 0), i.rowheaders && (p = et(n.headerBand, to, null), c = ih(e, i.rowheaders, r, a, l, -et(o, "rowHeader"), MA, 0, s, "x1", 0, a, 1, p)), i.colheaders && (p = et(n.headerBand, eo, null), f = ih(e, i.colheaders, r, a, a, -et(o, "columnHeader"), MA, 1, s, "y1", 0, 1, a, p)), i.rowfooters && (p = et(n.footerBand, to, null), d = ih(e, i.rowfooters, r, a, l, et(o, "rowFooter"), FA, 0, s, "x2", a - 1, a, 1, p)), i.colfooters && (p = et(n.footerBand, eo, null), h = ih(e, i.colfooters, r, a, a, et(o, "columnFooter"), FA, 1, s, "y2", u - a, 1, a, p)), i.rowtitle && (g = et(n.titleAnchor, to), m = et(o, "rowTitle"), m = g === dn ? d + m : c - m, p = et(n.titleBand, to, 0.5), OA(e, i.rowtitle, m, 0, y, p)), i.coltitle && (g = et(n.titleAnchor, eo), m = et(o, "columnTitle"), m = g === dn ? h + m : f - m, p = et(n.titleBand, eo, 0.5), OA(e, i.coltitle, m, 1, y, p));
}
function ZH(e, t) {
  return t === "x1" ? e.x || 0 : t === "y1" ? e.y || 0 : t === "x2" ? (e.x || 0) + (e.width || 0) : t === "y2" ? (e.y || 0) + (e.height || 0) : void 0;
}
function eG(e, t) {
  return e.bounds[t];
}
function ih(e, t, n, i, r, s, o, a, l, u, c, f, d, h) {
  var g = n.length, p = 0, m = 0, y, b, v, _, x, S, E, C, $;
  if (!g)
    return p;
  for (y = c; y < g; y += f)
    n[y] && (p = o(p, l(n[y], u)));
  if (!t.length)
    return p;
  for (t.length > r && (e.warn("Grid headers exceed limit: " + r), t = t.slice(0, r)), p += s, b = 0, _ = t.length; b < _; ++b)
    e.dirty(t[b]), t[b].mark.bounds.clear();
  for (y = c, b = 0, _ = t.length; b < _; ++b, y += f) {
    for (S = t[b], x = S.mark.bounds, v = y; v >= 0 && (E = n[v]) == null; v -= d)
      ;
    a ? (C = h == null ? E.x : Math.round(E.bounds.x1 + h * E.bounds.width()), $ = p) : (C = p, $ = h == null ? E.y : Math.round(E.bounds.y1 + h * E.bounds.height())), x.union(S.bounds.translate(C - (S.x || 0), $ - (S.y || 0))), S.x = C, S.y = $, e.dirty(S), m = o(m, x[u]);
  }
  return m;
}
function OA(e, t, n, i, r, s) {
  if (t) {
    e.dirty(t);
    var o = n, a = n;
    i ? o = Math.round(r.x1 + s * r.width()) : a = Math.round(r.y1 + s * r.height()), t.bounds.translate(o - (t.x || 0), a - (t.y || 0)), t.mark.bounds.clear().union(t.bounds), t.x = o, t.y = a, e.dirty(t);
  }
}
function tG(e, t) {
  const n = e[t] || {};
  return (i, r) => n[i] != null ? n[i] : e[i] != null ? e[i] : r;
}
function nG(e, t) {
  let n = -1 / 0;
  return e.forEach((i) => {
    i.offset != null && (n = Math.max(n, i.offset));
  }), n > -1 / 0 ? n : t;
}
function iG(e, t, n, i, r, s, o) {
  const a = tG(n, t), l = nG(e, a("offset", 0)), u = a("anchor", gw), c = u === dn ? 1 : u === fb ? 0.5 : 0, f = {
    align: db,
    bounds: a("bounds", vw),
    columns: a("direction") === "vertical" ? 1 : e.length,
    padding: a("margin", 8),
    center: a("center"),
    nodirty: !0
  };
  switch (t) {
    case Ui:
      f.anchor = {
        x: Math.floor(i.x1) - l,
        column: dn,
        y: c * (o || i.height() + 2 * i.y1),
        row: u
      };
      break;
    case qi:
      f.anchor = {
        x: Math.ceil(i.x2) + l,
        y: c * (o || i.height() + 2 * i.y1),
        row: u
      };
      break;
    case hu:
      f.anchor = {
        y: Math.floor(r.y1) - l,
        row: dn,
        x: c * (s || r.width() + 2 * r.x1),
        column: u
      };
      break;
    case _o:
      f.anchor = {
        y: Math.ceil(r.y2) + l,
        x: c * (s || r.width() + 2 * r.x1),
        column: u
      };
      break;
    case TH:
      f.anchor = {
        x: l,
        y: l
      };
      break;
    case OH:
      f.anchor = {
        x: s - l,
        y: l,
        column: dn
      };
      break;
    case NH:
      f.anchor = {
        x: l,
        y: o - l,
        row: dn
      };
      break;
    case DH:
      f.anchor = {
        x: s - l,
        y: o - l,
        column: dn,
        row: dn
      };
      break;
  }
  return f;
}
function rG(e, t) {
  var n = t.items[0], i = n.datum, r = n.orient, s = n.bounds, o = n.x, a = n.y, l, u;
  return n._bounds ? n._bounds.clear().union(s) : n._bounds = s.clone(), s.clear(), oG(e, n, n.items[0].items[0]), s = sG(n, s), l = 2 * n.padding, u = 2 * n.padding, s.empty() || (l = Math.ceil(s.width() + l), u = Math.ceil(s.height() + u)), i.type === BH && aG(n.items[0].items[0].items[0].items), r !== bw && (n.x = o = 0, n.y = a = 0), n.width = l, n.height = u, Fs(s.set(o, a, o + l, a + u), n), n.mark.bounds.clear().union(s), n;
}
function sG(e, t) {
  return e.items.forEach((n) => t.union(n.bounds)), t.x1 = e.padding, t.y1 = e.padding, t;
}
function oG(e, t, n) {
  var i = t.padding, r = i - n.x, s = i - n.y;
  if (!t.datum.title)
    (r || s) && pc(e, n, r, s);
  else {
    var o = t.items[1].items[0], a = o.anchor, l = t.titlePadding || 0, u = i - o.x, c = i - o.y;
    switch (o.orient) {
      case Ui:
        r += Math.ceil(o.bounds.width()) + l;
        break;
      case qi:
      case _o:
        break;
      default:
        s += o.bounds.height() + l;
    }
    switch ((r || s) && pc(e, n, r, s), o.orient) {
      case Ui:
        c += vl(t, n, o, a, 1, 1);
        break;
      case qi:
        u += vl(t, n, o, dn, 0, 0) + l, c += vl(t, n, o, a, 1, 1);
        break;
      case _o:
        u += vl(t, n, o, a, 0, 0), c += vl(t, n, o, dn, -1, 0, 1) + l;
        break;
      default:
        u += vl(t, n, o, a, 0, 0);
    }
    (u || c) && pc(e, o, u, c), (u = Math.round(o.bounds.x1 - i)) < 0 && (pc(e, n, -u, 0), pc(e, o, -u, 0));
  }
}
function vl(e, t, n, i, r, s, o) {
  const a = e.datum.type !== "symbol", l = n.datum.vgrad, u = a && (s || !l) && !o ? t.items[0] : t, c = u.bounds[r ? "y2" : "x2"] - e.padding, f = l && s ? c : 0, d = l && s ? 0 : c, h = r <= 0 ? 0 : ew(n);
  return Math.round(i === gw ? f : i === dn ? d - h : 0.5 * (c - h));
}
function pc(e, t, n, i) {
  t.x += n, t.y += i, t.bounds.translate(n, i), t.mark.bounds.translate(n, i), e.dirty(t);
}
function aG(e) {
  const t = e.reduce((n, i) => (n[i.column] = Math.max(i.bounds.x2 - i.x, n[i.column] || 0), n), {});
  e.forEach((n) => {
    n.width = t[n.column], n.height = n.bounds.y2 - n.y;
  });
}
function lG(e, t, n, i, r) {
  var s = t.items[0], o = s.frame, a = s.orient, l = s.anchor, u = s.offset, c = s.padding, f = s.items[0].items[0], d = s.items[1] && s.items[1].items[0], h = a === Ui || a === qi ? i : n, g = 0, p = 0, m = 0, y = 0, b = 0, v;
  if (o !== Nm ? a === Ui ? (g = r.y2, h = r.y1) : a === qi ? (g = r.y1, h = r.y2) : (g = r.x1, h = r.x2) : a === Ui && (g = i, h = 0), v = l === gw ? g : l === dn ? h : (g + h) / 2, d && d.text) {
    switch (a) {
      case hu:
      case _o:
        b = f.bounds.height() + c;
        break;
      case Ui:
        y = f.bounds.width() + c;
        break;
      case qi:
        y = -f.bounds.width() - c;
        break;
    }
    Kt.clear().union(d.bounds), Kt.translate(y - (d.x || 0), b - (d.y || 0)), Ll(d, "x", y) | Ll(d, "y", b) && (e.dirty(d), d.bounds.clear().union(Kt), d.mark.bounds.clear().union(Kt), e.dirty(d)), Kt.clear().union(d.bounds);
  } else
    Kt.clear();
  switch (Kt.union(f.bounds), a) {
    case hu:
      p = v, m = r.y1 - Kt.height() - u;
      break;
    case Ui:
      p = r.x1 - Kt.width() - u, m = v;
      break;
    case qi:
      p = r.x2 + Kt.width() + u, m = v;
      break;
    case _o:
      p = v, m = r.y2 + u;
      break;
    default:
      p = s.x, m = s.y;
  }
  return Ll(s, "x", p) | Ll(s, "y", m) && (Kt.translate(p, m), e.dirty(s), s.bounds.clear().union(Kt), t.bounds.clear().union(Kt), e.dirty(s)), s.bounds;
}
function KN(e) {
  I.call(this, null, e);
}
Y(KN, I, {
  transform(e, t) {
    const n = t.dataflow;
    return e.mark.items.forEach((i) => {
      e.layout && QH(n, i, e.layout), cG(n, i, e);
    }), uG(e.mark.group) ? t.reflow() : t;
  }
});
function uG(e) {
  return e && e.mark.role !== "legend-entry";
}
function cG(e, t, n) {
  var i = t.items, r = Math.max(0, t.width || 0), s = Math.max(0, t.height || 0), o = new pt().set(0, 0, r, s), a = o.clone(), l = o.clone(), u = [], c, f, d, h, g, p;
  for (g = 0, p = i.length; g < p; ++g)
    switch (f = i[g], f.role) {
      case pw:
        h = GH(f) ? a : l, h.union(YH(e, f, r, s));
        break;
      case mw:
        c = f;
        break;
      case yw:
        u.push(rG(e, f));
        break;
      case PH:
      case IH:
      case RN:
      case LN:
      case PN:
      case IN:
      case zN:
      case BN:
        a.union(f.bounds), l.union(f.bounds);
        break;
      default:
        o.union(f.bounds);
    }
  if (u.length) {
    const m = {};
    u.forEach((y) => {
      d = y.orient || qi, d !== bw && (m[d] || (m[d] = [])).push(y);
    });
    for (const y in m) {
      const b = m[y];
      XN(e, b, iG(b, y, n.legends, a, l, r, s));
    }
    u.forEach((y) => {
      const b = y.bounds;
      if (b.equals(y._bounds) || (y.bounds = y._bounds, e.dirty(y), y.bounds = b, e.dirty(y)), n.autosize && (n.autosize.type === jN || n.autosize.type === UN || n.autosize.type === qN))
        switch (y.orient) {
          case Ui:
          case qi:
            o.add(b.x1, 0).add(b.x2, 0);
            break;
          case hu:
          case _o:
            o.add(0, b.y1).add(0, b.y2);
        }
      else
        o.union(b);
    });
  }
  o.union(a).union(l), c && o.union(lG(e, c, r, s, o)), t.clip && o.set(0, 0, t.width || 0, t.height || 0), fG(e, t, o, n);
}
function fG(e, t, n, i) {
  const r = i.autosize || {}, s = r.type;
  if (e._autosize < 1 || !s)
    return;
  let o = e._width, a = e._height, l = Math.max(0, t.width || 0), u = Math.max(0, Math.ceil(-n.x1)), c = Math.max(0, t.height || 0), f = Math.max(0, Math.ceil(-n.y1));
  const d = Math.max(0, Math.ceil(n.x2 - l)), h = Math.max(0, Math.ceil(n.y2 - c));
  if (r.contains === zH) {
    const g = e.padding();
    o -= g.left + g.right, a -= g.top + g.bottom;
  }
  s === bw ? (u = 0, f = 0, l = o, c = a) : s === jN ? (l = Math.max(0, o - u - d), c = Math.max(0, a - f - h)) : s === UN ? (l = Math.max(0, o - u - d), a = c + f + h) : s === qN ? (o = l + u + d, c = Math.max(0, a - f - h)) : s === jH && (o = l + u + d, a = c + f + h), e._resizeView(o, a, l, c, [u, f], r.resize);
}
const dG = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  bound: WN,
  identifier: xw,
  mark: HN,
  overlap: GN,
  render: YN,
  viewlayout: KN
}, Symbol.toStringTag, { value: "Module" }));
function JN(e) {
  I.call(this, null, e);
}
Y(JN, I, {
  transform(e, t) {
    if (this.value && !e.modified())
      return t.StopPropagation;
    var n = t.dataflow.locale(), i = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = this.value, s = e.scale, o = e.count == null ? e.values ? e.values.length : 10 : e.count, a = R2(s, o, e.minstep), l = e.format || $O(n, s, a, e.formatSpecifier, e.formatType, !!e.values), u = e.values ? CO(s, e.values, a) : L2(s, a);
    return r && (i.rem = r), r = u.map((c, f) => je({
      index: f / (u.length - 1 || 1),
      value: c,
      label: l(c)
    })), e.extra && r.length && r.push(je({
      index: -1,
      extra: {
        value: r[0].value
      },
      label: ""
    })), i.source = r, i.add = r, this.value = r, i;
  }
});
function QN(e) {
  I.call(this, null, e);
}
function hG() {
  return je({});
}
function gG(e) {
  const t = Lu().test((n) => n.exit);
  return t.lookup = (n) => t.get(e(n)), t;
}
Y(QN, I, {
  transform(e, t) {
    var n = t.dataflow, i = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = e.item || hG, s = e.key || le, o = this.value;
    return U(i.encode) && (i.encode = null), o && (e.modified("key") || t.modified(s)) && j("DataJoin does not support modified key function or fields."), o || (t = t.addAll(), this.value = o = gG(s)), t.visit(t.ADD, (a) => {
      const l = s(a);
      let u = o.get(l);
      u ? u.exit ? (o.empty--, i.add.push(u)) : i.mod.push(u) : (u = r(a), o.set(l, u), i.add.push(u)), u.datum = a, u.exit = !1;
    }), t.visit(t.MOD, (a) => {
      const l = s(a), u = o.get(l);
      u && (u.datum = a, i.mod.push(u));
    }), t.visit(t.REM, (a) => {
      const l = s(a), u = o.get(l);
      a === u.datum && !u.exit && (i.rem.push(u), u.exit = !0, ++o.empty);
    }), t.changed(t.ADD_MOD) && i.modifies("datum"), (t.clean() || e.clean && o.empty > n.cleanThreshold) && n.runAfter(o.clean), i;
  }
});
function ZN(e) {
  I.call(this, null, e);
}
Y(ZN, I, {
  transform(e, t) {
    var n = t.fork(t.ADD_REM), i = e.mod || !1, r = e.encoders, s = t.encode;
    if (U(s))
      if (n.changed() || s.every((f) => r[f]))
        s = s[0], n.encode = null;
      else
        return t.StopPropagation;
    var o = s === "enter", a = r.update || js, l = r.enter || js, u = r.exit || js, c = (s && !o ? r[s] : a) || js;
    if (t.changed(t.ADD) && (t.visit(t.ADD, (f) => {
      l(f, e), a(f, e);
    }), n.modifies(l.output), n.modifies(a.output), c !== js && c !== a && (t.visit(t.ADD, (f) => {
      c(f, e);
    }), n.modifies(c.output))), t.changed(t.REM) && u !== js && (t.visit(t.REM, (f) => {
      u(f, e);
    }), n.modifies(u.output)), o || c !== js) {
      const f = t.MOD | (e.modified() ? t.REFLOW : 0);
      o ? (t.visit(f, (d) => {
        const h = l(d, e) || i;
        (c(d, e) || h) && n.mod.push(d);
      }), n.mod.length && n.modifies(l.output)) : t.visit(f, (d) => {
        (c(d, e) || i) && n.mod.push(d);
      }), n.mod.length && n.modifies(c.output);
    }
    return n.changed() ? n : t.StopPropagation;
  }
});
function eD(e) {
  I.call(this, [], e);
}
Y(eD, I, {
  transform(e, t) {
    if (this.value != null && !e.modified())
      return t.StopPropagation;
    var n = t.dataflow.locale(), i = t.fork(t.NO_SOURCE | t.NO_FIELDS), r = this.value, s = e.type || Rh, o = e.scale, a = +e.limit, l = R2(o, e.count == null ? 5 : e.count, e.minstep), u = !!e.values || s === Rh, c = e.format || OO(n, o, l, s, e.formatSpecifier, e.formatType, u), f = e.values || TO(o, l), d, h, g, p, m;
    return r && (i.rem = r), s === Rh ? (a && f.length > a ? (t.dataflow.warn("Symbol legend count exceeds limit, filtering items."), r = f.slice(0, a - 1), m = !0) : r = f, Ee(g = e.size) ? (!e.values && o(r[0]) === 0 && (r = r.slice(1)), p = r.reduce((y, b) => Math.max(y, g(b, e)), 0)) : g = ln(p = g || 8), r = r.map((y, b) => je({
      index: b,
      label: c(y, b, r),
      value: y,
      offset: p,
      size: g(y, e)
    })), m && (m = f[r.length], r.push(je({
      index: r.length,
      label: `…${f.length - r.length} entries`,
      value: m,
      offset: p,
      size: g(m, e)
    })))) : s === jU ? (d = o.domain(), h = SO(o, d[0], Te(d)), f.length < 3 && !e.values && d[0] !== Te(d) && (f = [d[0], Te(d)]), r = f.map((y, b) => je({
      index: b,
      label: c(y, b, f),
      value: y,
      perc: h(y)
    }))) : (g = f.length - 1, h = QU(o), r = f.map((y, b) => je({
      index: b,
      label: c(y, b, f),
      value: y,
      perc: b ? h(y) : 0,
      perc2: b === g ? 1 : h(f[b + 1])
    }))), i.source = r, i.add = r, this.value = r, i;
  }
});
const pG = (e) => e.source.x, mG = (e) => e.source.y, yG = (e) => e.target.x, bG = (e) => e.target.y;
function ww(e) {
  I.call(this, {}, e);
}
ww.Definition = {
  type: "LinkPath",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "sourceX",
    type: "field",
    default: "source.x"
  }, {
    name: "sourceY",
    type: "field",
    default: "source.y"
  }, {
    name: "targetX",
    type: "field",
    default: "target.x"
  }, {
    name: "targetY",
    type: "field",
    default: "target.y"
  }, {
    name: "orient",
    type: "enum",
    default: "vertical",
    values: ["horizontal", "vertical", "radial"]
  }, {
    name: "shape",
    type: "enum",
    default: "line",
    values: ["line", "arc", "curve", "diagonal", "orthogonal"]
  }, {
    name: "require",
    type: "signal"
  }, {
    name: "as",
    type: "string",
    default: "path"
  }]
};
Y(ww, I, {
  transform(e, t) {
    var n = e.sourceX || pG, i = e.sourceY || mG, r = e.targetX || yG, s = e.targetY || bG, o = e.as || "path", a = e.orient || "vertical", l = e.shape || "line", u = NA.get(l + "-" + a) || NA.get(l);
    return u || j("LinkPath unsupported type: " + e.shape + (e.orient ? "-" + e.orient : "")), t.visit(t.SOURCE, (c) => {
      c[o] = u(n(c), i(c), r(c), s(c));
    }), t.reflow(e.modified()).modifies(o);
  }
});
const tD = (e, t, n, i) => "M" + e + "," + t + "L" + n + "," + i, vG = (e, t, n, i) => tD(t * Math.cos(e), t * Math.sin(e), i * Math.cos(n), i * Math.sin(n)), nD = (e, t, n, i) => {
  var r = n - e, s = i - t, o = Math.hypot(r, s) / 2, a = 180 * Math.atan2(s, r) / Math.PI;
  return "M" + e + "," + t + "A" + o + "," + o + " " + a + " 0 1 " + n + "," + i;
}, xG = (e, t, n, i) => nD(t * Math.cos(e), t * Math.sin(e), i * Math.cos(n), i * Math.sin(n)), iD = (e, t, n, i) => {
  const r = n - e, s = i - t, o = 0.2 * (r + s), a = 0.2 * (s - r);
  return "M" + e + "," + t + "C" + (e + o) + "," + (t + a) + " " + (n + a) + "," + (i - o) + " " + n + "," + i;
}, wG = (e, t, n, i) => iD(t * Math.cos(e), t * Math.sin(e), i * Math.cos(n), i * Math.sin(n)), _G = (e, t, n, i) => "M" + e + "," + t + "V" + i + "H" + n, EG = (e, t, n, i) => "M" + e + "," + t + "H" + n + "V" + i, SG = (e, t, n, i) => {
  const r = Math.cos(e), s = Math.sin(e), o = Math.cos(n), a = Math.sin(n), l = Math.abs(n - e) > Math.PI ? n <= e : n > e;
  return "M" + t * r + "," + t * s + "A" + t + "," + t + " 0 0," + (l ? 1 : 0) + " " + t * o + "," + t * a + "L" + i * o + "," + i * a;
}, kG = (e, t, n, i) => {
  const r = (e + n) / 2;
  return "M" + e + "," + t + "C" + r + "," + t + " " + r + "," + i + " " + n + "," + i;
}, AG = (e, t, n, i) => {
  const r = (t + i) / 2;
  return "M" + e + "," + t + "C" + e + "," + r + " " + n + "," + r + " " + n + "," + i;
}, CG = (e, t, n, i) => {
  const r = Math.cos(e), s = Math.sin(e), o = Math.cos(n), a = Math.sin(n), l = (t + i) / 2;
  return "M" + t * r + "," + t * s + "C" + l * r + "," + l * s + " " + l * o + "," + l * a + " " + i * o + "," + i * a;
}, NA = Lu({
  line: tD,
  "line-radial": vG,
  arc: nD,
  "arc-radial": xG,
  curve: iD,
  "curve-radial": wG,
  "orthogonal-horizontal": _G,
  "orthogonal-vertical": EG,
  "orthogonal-radial": SG,
  "diagonal-horizontal": kG,
  "diagonal-vertical": AG,
  "diagonal-radial": CG
});
function _w(e) {
  I.call(this, null, e);
}
_w.Definition = {
  type: "Pie",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "startAngle",
    type: "number",
    default: 0
  }, {
    name: "endAngle",
    type: "number",
    default: 6.283185307179586
  }, {
    name: "sort",
    type: "boolean",
    default: !1
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["startAngle", "endAngle"]
  }]
};
Y(_w, I, {
  transform(e, t) {
    var n = e.as || ["startAngle", "endAngle"], i = n[0], r = n[1], s = e.field || Nu, o = e.startAngle || 0, a = e.endAngle != null ? e.endAngle : 2 * Math.PI, l = t.source, u = l.map(s), c = u.length, f = o, d = (a - o) / wF(u), h = Jn(c), g, p, m;
    for (e.sort && h.sort((y, b) => u[y] - u[b]), g = 0; g < c; ++g)
      m = u[h[g]], p = l[h[g]], p[i] = f, p[r] = f += m * d;
    return this.value = u, t.reflow(e.modified()).modifies(n);
  }
});
const $G = 5;
function MG(e) {
  const t = e.type;
  return !e.bins && (t === au || t === ld || t === ud);
}
function rD(e) {
  return O2(e) && e !== Er;
}
const FG = Ji(["set", "modified", "clear", "type", "scheme", "schemeExtent", "schemeCount", "domain", "domainMin", "domainMid", "domainMax", "domainRaw", "domainImplicit", "nice", "zero", "bins", "range", "rangeStep", "round", "reverse", "interpolate", "interpolateGamma"]);
function sD(e) {
  I.call(this, null, e), this.modified(!0);
}
Y(sD, I, {
  transform(e, t) {
    var n = t.dataflow, i = this.value, r = TG(e);
    (!i || r !== i.type) && (this.value = i = ze(r)());
    for (r in e)
      if (!FG[r]) {
        if (r === "padding" && rD(i.type))
          continue;
        Ee(i[r]) ? i[r](e[r]) : n.warn("Unsupported scale property: " + r);
      }
    return PG(i, e, LG(i, e, NG(i, e, n))), t.fork(t.NO_SOURCE | t.NO_FIELDS);
  }
});
function TG(e) {
  var t = e.type, n = "", i;
  return t === Er ? Er + "-" + au : (OG(e) && (i = e.rawDomain ? e.rawDomain.length : e.domain ? e.domain.length + +(e.domainMid != null) : 0, n = i === 2 ? Er + "-" : i === 3 ? Wu + "-" : ""), (n + t || au).toLowerCase());
}
function OG(e) {
  const t = e.type;
  return O2(t) && t !== Fa && t !== Ta && (e.scheme || e.range && e.range.length && e.range.every(te));
}
function NG(e, t, n) {
  const i = DG(e, t.domainRaw, n);
  if (i > -1)
    return i;
  var r = t.domain, s = e.type, o = t.zero || t.zero === void 0 && MG(e), a, l;
  if (!r)
    return 0;
  if (rD(s) && t.padding && r[0] !== Te(r) && (r = RG(s, r, t.range, t.padding, t.exponent, t.constant)), (o || t.domainMin != null || t.domainMax != null || t.domainMid != null) && (a = (r = r.slice()).length - 1 || 1, o && (r[0] > 0 && (r[0] = 0), r[a] < 0 && (r[a] = 0)), t.domainMin != null && (r[0] = t.domainMin), t.domainMax != null && (r[a] = t.domainMax), t.domainMid != null)) {
    l = t.domainMid;
    const u = l > r[a] ? a + 1 : l < r[0] ? 0 : a;
    u !== a && n.warn("Scale domainMid exceeds domain min or max.", l), r.splice(u, 0, l);
  }
  return e.domain(oD(s, r, n)), s === $2 && e.unknown(t.domainImplicit ? Wy : void 0), t.nice && e.nice && e.nice(t.nice !== !0 && R2(e, t.nice) || null), r.length;
}
function DG(e, t, n) {
  return t ? (e.domain(oD(e.type, t, n)), t.length) : -1;
}
function RG(e, t, n, i, r, s) {
  var o = Math.abs(Te(n) - n[0]), a = o / (o - 2 * i), l = e === _s ? Kv(t, null, a) : e === ud ? og(t, null, a, 0.5) : e === ld ? og(t, null, a, r || 1) : e === ym ? Jv(t, null, a, s || 1) : Xv(t, null, a);
  return t = t.slice(), t[0] = l[0], t[t.length - 1] = l[1], t;
}
function oD(e, t, n) {
  if (vO(e)) {
    var i = Math.abs(t.reduce((r, s) => r + (s < 0 ? -1 : s > 0 ? 1 : 0), 0));
    i !== t.length && n.warn("Log scale domain includes zero: " + X(t));
  }
  return t;
}
function LG(e, t, n) {
  let i = t.bins;
  if (i && !U(i)) {
    const r = e.domain(), s = r[0], o = Te(r), a = i.step;
    let l = i.start == null ? s : i.start, u = i.stop == null ? o : i.stop;
    a || j("Scale bins parameter missing step property."), l < s && (l = a * Math.ceil(s / a)), u > o && (u = a * Math.floor(o / a)), i = Jn(l, u + a / 2, a);
  }
  return i ? e.bins = i : e.bins && delete e.bins, e.type === M2 && (i ? !t.domain && !t.domainRaw && (e.domain(i), n = i.length) : e.bins = e.domain()), n;
}
function PG(e, t, n) {
  var i = e.type, r = t.round || !1, s = t.range;
  if (t.rangeStep != null)
    s = IG(i, t, n);
  else if (t.scheme && (s = zG(i, t, n), Ee(s))) {
    if (e.interpolator)
      return e.interpolator(s);
    j(`Scale type ${i} does not support interpolating color schemes.`);
  }
  if (s && xO(i))
    return e.interpolator(xm(hb(s, t.reverse), t.interpolate, t.interpolateGamma));
  s && t.interpolate && e.interpolate ? e.interpolate(N2(t.interpolate, t.interpolateGamma)) : Ee(e.round) ? e.round(r) : Ee(e.rangeRound) && e.interpolate(r ? od : Do), s && e.range(hb(s, t.reverse));
}
function IG(e, t, n) {
  e !== hO && e !== Jy && j("Only band and point scales support rangeStep.");
  var i = (t.paddingOuter != null ? t.paddingOuter : t.padding) || 0, r = e === Jy ? 1 : (t.paddingInner != null ? t.paddingInner : t.padding) || 0;
  return [0, t.rangeStep * C2(n, r, i)];
}
function zG(e, t, n) {
  var i = t.schemeExtent, r, s;
  return U(t.scheme) ? s = xm(t.scheme, t.interpolate, t.interpolateGamma) : (r = t.scheme.toLowerCase(), s = D2(r), s || j(`Unrecognized scheme name: ${t.scheme}`)), n = e === vm ? n + 1 : e === M2 ? n - 1 : e === lu || e === bm ? +t.schemeCount || $G : n, xO(e) ? DA(s, i, t.reverse) : Ee(s) ? EO(DA(s, i), n) : e === $2 ? s : s.slice(0, n);
}
function DA(e, t, n) {
  return Ee(e) && (t || n) ? _O(e, hb(t || [0, 1], n)) : e;
}
function hb(e, t) {
  return t ? e.slice().reverse() : e;
}
function aD(e) {
  I.call(this, null, e);
}
Y(aD, I, {
  transform(e, t) {
    const n = e.modified("sort") || t.changed(t.ADD) || t.modified(e.sort.fields) || t.modified("datum");
    return n && t.source.sort(el(e.sort)), this.modified(n), t;
  }
});
const RA = "zero", lD = "center", uD = "normalize", cD = ["y0", "y1"];
function Ew(e) {
  I.call(this, null, e);
}
Ew.Definition = {
  type: "Stack",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "offset",
    type: "enum",
    default: RA,
    values: [RA, lD, uD]
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: cD
  }]
};
Y(Ew, I, {
  transform(e, t) {
    var n = e.as || cD, i = n[0], r = n[1], s = el(e.sort), o = e.field || Nu, a = e.offset === lD ? BG : e.offset === uD ? jG : UG, l, u, c, f;
    for (l = qG(t.source, e.groupby, s, o), u = 0, c = l.length, f = l.max; u < c; ++u)
      a(l[u], f, o, i, r);
    return t.reflow(e.modified()).modifies(n);
  }
});
function BG(e, t, n, i, r) {
  for (var s = (t - e.sum) / 2, o = e.length, a = 0, l; a < o; ++a)
    l = e[a], l[i] = s, l[r] = s += Math.abs(n(l));
}
function jG(e, t, n, i, r) {
  for (var s = 1 / e.sum, o = 0, a = e.length, l = 0, u = 0, c; l < a; ++l)
    c = e[l], c[i] = o, c[r] = o = s * (u += Math.abs(n(c)));
}
function UG(e, t, n, i, r) {
  for (var s = 0, o = 0, a = e.length, l = 0, u, c; l < a; ++l)
    c = e[l], u = +n(c), u < 0 ? (c[i] = o, c[r] = o += u) : (c[i] = s, c[r] = s += u);
}
function qG(e, t, n, i) {
  var r = [], s = (p) => p(c), o, a, l, u, c, f, d, h, g;
  if (t == null)
    r.push(e.slice());
  else
    for (o = {}, a = 0, l = e.length; a < l; ++a)
      c = e[a], f = t.map(s), d = o[f], d || (o[f] = d = [], r.push(d)), d.push(c);
  for (f = 0, g = 0, u = r.length; f < u; ++f) {
    for (d = r[f], a = 0, h = 0, l = d.length; a < l; ++a)
      h += Math.abs(i(d[a]));
    d.sum = h, h > g && (g = h), n && d.sort(n);
  }
  return r.max = g, r;
}
const WG = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  axisticks: JN,
  datajoin: QN,
  encode: ZN,
  legendentries: eD,
  linkpath: ww,
  pie: _w,
  scale: sD,
  sortitems: aD,
  stack: Ew
}, Symbol.toStringTag, { value: "Module" }));
var fe = 1e-6, Lg = 1e-12, Ae = Math.PI, lt = Ae / 2, Pg = Ae / 4, wn = Ae * 2, ct = 180 / Ae, ke = Ae / 180, Fe = Math.abs, Gu = Math.atan, Ai = Math.atan2, de = Math.cos, rh = Math.ceil, fD = Math.exp, gb = Math.hypot, Ig = Math.log, w1 = Math.pow, ue = Math.sin, pi = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, _n = Math.sqrt, Sw = Math.tan;
function dD(e) {
  return e > 1 ? 0 : e < -1 ? Ae : Math.acos(e);
}
function Bn(e) {
  return e > 1 ? lt : e < -1 ? -lt : Math.asin(e);
}
function jt() {
}
function zg(e, t) {
  e && PA.hasOwnProperty(e.type) && PA[e.type](e, t);
}
var LA = {
  Feature: function(e, t) {
    zg(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, i = -1, r = n.length; ++i < r; )
      zg(n[i].geometry, t);
  }
}, PA = {
  Sphere: function(e, t) {
    t.sphere();
  },
  Point: function(e, t) {
    e = e.coordinates, t.point(e[0], e[1], e[2]);
  },
  MultiPoint: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      e = n[i], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    pb(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      pb(n[i], t, 0);
  },
  Polygon: function(e, t) {
    IA(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      IA(n[i], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, i = -1, r = n.length; ++i < r; )
      zg(n[i], t);
  }
};
function pb(e, t, n) {
  var i = -1, r = e.length - n, s;
  for (t.lineStart(); ++i < r; )
    s = e[i], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function IA(e, t) {
  var n = -1, i = e.length;
  for (t.polygonStart(); ++n < i; )
    pb(e[n], t, 1);
  t.polygonEnd();
}
function ss(e, t) {
  e && LA.hasOwnProperty(e.type) ? LA[e.type](e, t) : zg(e, t);
}
var Bg = new bn(), jg = new bn(), hD, gD, mb, yb, bb, Or = {
  point: jt,
  lineStart: jt,
  lineEnd: jt,
  polygonStart: function() {
    Bg = new bn(), Or.lineStart = HG, Or.lineEnd = GG;
  },
  polygonEnd: function() {
    var e = +Bg;
    jg.add(e < 0 ? wn + e : e), this.lineStart = this.lineEnd = this.point = jt;
  },
  sphere: function() {
    jg.add(wn);
  }
};
function HG() {
  Or.point = VG;
}
function GG() {
  pD(hD, gD);
}
function VG(e, t) {
  Or.point = pD, hD = e, gD = t, e *= ke, t *= ke, mb = e, yb = de(t = t / 2 + Pg), bb = ue(t);
}
function pD(e, t) {
  e *= ke, t *= ke, t = t / 2 + Pg;
  var n = e - mb, i = n >= 0 ? 1 : -1, r = i * n, s = de(t), o = ue(t), a = bb * o, l = yb * s + a * de(r), u = a * i * ue(r);
  Bg.add(Ai(u, l)), mb = e, yb = s, bb = o;
}
function YG(e) {
  return jg = new bn(), ss(e, Or), jg * 2;
}
function Ug(e) {
  return [Ai(e[1], e[0]), Bn(e[2])];
}
function Na(e) {
  var t = e[0], n = e[1], i = de(n);
  return [i * de(t), i * ue(t), ue(n)];
}
function sh(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function gu(e, t) {
  return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]];
}
function _1(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function oh(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function qg(e) {
  var t = _n(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var it, Mn, rt, Yn, sa, mD, yD, Wl, sf, Gs, Es, ns = {
  point: vb,
  lineStart: zA,
  lineEnd: BA,
  polygonStart: function() {
    ns.point = vD, ns.lineStart = XG, ns.lineEnd = KG, sf = new bn(), Or.polygonStart();
  },
  polygonEnd: function() {
    Or.polygonEnd(), ns.point = vb, ns.lineStart = zA, ns.lineEnd = BA, Bg < 0 ? (it = -(rt = 180), Mn = -(Yn = 90)) : sf > fe ? Yn = 90 : sf < -fe && (Mn = -90), Es[0] = it, Es[1] = rt;
  },
  sphere: function() {
    it = -(rt = 180), Mn = -(Yn = 90);
  }
};
function vb(e, t) {
  Gs.push(Es = [it = e, rt = e]), t < Mn && (Mn = t), t > Yn && (Yn = t);
}
function bD(e, t) {
  var n = Na([e * ke, t * ke]);
  if (Wl) {
    var i = gu(Wl, n), r = [i[1], -i[0], 0], s = gu(r, i);
    qg(s), s = Ug(s);
    var o = e - sa, a = o > 0 ? 1 : -1, l = s[0] * ct * a, u, c = Fe(o) > 180;
    c ^ (a * sa < l && l < a * e) ? (u = s[1] * ct, u > Yn && (Yn = u)) : (l = (l + 360) % 360 - 180, c ^ (a * sa < l && l < a * e) ? (u = -s[1] * ct, u < Mn && (Mn = u)) : (t < Mn && (Mn = t), t > Yn && (Yn = t))), c ? e < sa ? Vn(it, e) > Vn(it, rt) && (rt = e) : Vn(e, rt) > Vn(it, rt) && (it = e) : rt >= it ? (e < it && (it = e), e > rt && (rt = e)) : e > sa ? Vn(it, e) > Vn(it, rt) && (rt = e) : Vn(e, rt) > Vn(it, rt) && (it = e);
  } else
    Gs.push(Es = [it = e, rt = e]);
  t < Mn && (Mn = t), t > Yn && (Yn = t), Wl = n, sa = e;
}
function zA() {
  ns.point = bD;
}
function BA() {
  Es[0] = it, Es[1] = rt, ns.point = vb, Wl = null;
}
function vD(e, t) {
  if (Wl) {
    var n = e - sa;
    sf.add(Fe(n) > 180 ? n + (n > 0 ? 360 : -360) : n);
  } else
    mD = e, yD = t;
  Or.point(e, t), bD(e, t);
}
function XG() {
  Or.lineStart();
}
function KG() {
  vD(mD, yD), Or.lineEnd(), Fe(sf) > fe && (it = -(rt = 180)), Es[0] = it, Es[1] = rt, Wl = null;
}
function Vn(e, t) {
  return (t -= e) < 0 ? t + 360 : t;
}
function JG(e, t) {
  return e[0] - t[0];
}
function jA(e, t) {
  return e[0] <= e[1] ? e[0] <= t && t <= e[1] : t < e[0] || e[1] < t;
}
function QG(e) {
  var t, n, i, r, s, o, a;
  if (Yn = rt = -(it = Mn = 1 / 0), Gs = [], ss(e, ns), n = Gs.length) {
    for (Gs.sort(JG), t = 1, i = Gs[0], s = [i]; t < n; ++t)
      r = Gs[t], jA(i, r[0]) || jA(i, r[1]) ? (Vn(i[0], r[1]) > Vn(i[0], i[1]) && (i[1] = r[1]), Vn(r[0], i[1]) > Vn(i[0], i[1]) && (i[0] = r[0])) : s.push(i = r);
    for (o = -1 / 0, n = s.length - 1, t = 0, i = s[n]; t <= n; i = r, ++t)
      r = s[t], (a = Vn(i[1], r[0])) > o && (o = a, it = r[0], rt = i[1]);
  }
  return Gs = Es = null, it === 1 / 0 || Mn === 1 / 0 ? [[NaN, NaN], [NaN, NaN]] : [[it, Mn], [rt, Yn]];
}
var zc, Wg, Hg, Gg, Vg, Yg, Xg, Kg, xb, wb, _b, xD, wD, hn, gn, pn, Wi = {
  sphere: jt,
  point: kw,
  lineStart: UA,
  lineEnd: qA,
  polygonStart: function() {
    Wi.lineStart = tV, Wi.lineEnd = nV;
  },
  polygonEnd: function() {
    Wi.lineStart = UA, Wi.lineEnd = qA;
  }
};
function kw(e, t) {
  e *= ke, t *= ke;
  var n = de(t);
  vd(n * de(e), n * ue(e), ue(t));
}
function vd(e, t, n) {
  ++zc, Hg += (e - Hg) / zc, Gg += (t - Gg) / zc, Vg += (n - Vg) / zc;
}
function UA() {
  Wi.point = ZG;
}
function ZG(e, t) {
  e *= ke, t *= ke;
  var n = de(t);
  hn = n * de(e), gn = n * ue(e), pn = ue(t), Wi.point = eV, vd(hn, gn, pn);
}
function eV(e, t) {
  e *= ke, t *= ke;
  var n = de(t), i = n * de(e), r = n * ue(e), s = ue(t), o = Ai(_n((o = gn * s - pn * r) * o + (o = pn * i - hn * s) * o + (o = hn * r - gn * i) * o), hn * i + gn * r + pn * s);
  Wg += o, Yg += o * (hn + (hn = i)), Xg += o * (gn + (gn = r)), Kg += o * (pn + (pn = s)), vd(hn, gn, pn);
}
function qA() {
  Wi.point = kw;
}
function tV() {
  Wi.point = iV;
}
function nV() {
  _D(xD, wD), Wi.point = kw;
}
function iV(e, t) {
  xD = e, wD = t, e *= ke, t *= ke, Wi.point = _D;
  var n = de(t);
  hn = n * de(e), gn = n * ue(e), pn = ue(t), vd(hn, gn, pn);
}
function _D(e, t) {
  e *= ke, t *= ke;
  var n = de(t), i = n * de(e), r = n * ue(e), s = ue(t), o = gn * s - pn * r, a = pn * i - hn * s, l = hn * r - gn * i, u = gb(o, a, l), c = Bn(u), f = u && -c / u;
  xb.add(f * o), wb.add(f * a), _b.add(f * l), Wg += c, Yg += c * (hn + (hn = i)), Xg += c * (gn + (gn = r)), Kg += c * (pn + (pn = s)), vd(hn, gn, pn);
}
function rV(e) {
  zc = Wg = Hg = Gg = Vg = Yg = Xg = Kg = 0, xb = new bn(), wb = new bn(), _b = new bn(), ss(e, Wi);
  var t = +xb, n = +wb, i = +_b, r = gb(t, n, i);
  return r < Lg && (t = Yg, n = Xg, i = Kg, Wg < fe && (t = Hg, n = Gg, i = Vg), r = gb(t, n, i), r < Lg) ? [NaN, NaN] : [Ai(n, t) * ct, Bn(i / r) * ct];
}
function Eb(e, t) {
  function n(i, r) {
    return i = e(i, r), t(i[0], i[1]);
  }
  return e.invert && t.invert && (n.invert = function(i, r) {
    return i = t.invert(i, r), i && e.invert(i[0], i[1]);
  }), n;
}
function Sb(e, t) {
  return Fe(e) > Ae && (e -= Math.round(e / wn) * wn), [e, t];
}
Sb.invert = Sb;
function ED(e, t, n) {
  return (e %= wn) ? t || n ? Eb(HA(e), GA(t, n)) : HA(e) : t || n ? GA(t, n) : Sb;
}
function WA(e) {
  return function(t, n) {
    return t += e, Fe(t) > Ae && (t -= Math.round(t / wn) * wn), [t, n];
  };
}
function HA(e) {
  var t = WA(e);
  return t.invert = WA(-e), t;
}
function GA(e, t) {
  var n = de(e), i = ue(e), r = de(t), s = ue(t);
  function o(a, l) {
    var u = de(l), c = de(a) * u, f = ue(a) * u, d = ue(l), h = d * n + c * i;
    return [
      Ai(f * r - h * s, c * n - d * i),
      Bn(h * r + f * s)
    ];
  }
  return o.invert = function(a, l) {
    var u = de(l), c = de(a) * u, f = ue(a) * u, d = ue(l), h = d * r - f * s;
    return [
      Ai(f * r + d * s, c * n + h * i),
      Bn(h * n - c * i)
    ];
  }, o;
}
function sV(e) {
  e = ED(e[0] * ke, e[1] * ke, e.length > 2 ? e[2] * ke : 0);
  function t(n) {
    return n = e(n[0] * ke, n[1] * ke), n[0] *= ct, n[1] *= ct, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * ke, n[1] * ke), n[0] *= ct, n[1] *= ct, n;
  }, t;
}
function oV(e, t, n, i, r, s) {
  if (n) {
    var o = de(t), a = ue(t), l = i * n;
    r == null ? (r = t + i * wn, s = t - l / 2) : (r = VA(o, r), s = VA(o, s), (i > 0 ? r < s : r > s) && (r += i * wn));
    for (var u, c = r; i > 0 ? c > s : c < s; c -= l)
      u = Ug([o, -a * de(c), -a * ue(c)]), e.point(u[0], u[1]);
  }
}
function VA(e, t) {
  t = Na(t), t[0] -= e, qg(t);
  var n = dD(-t[1]);
  return ((-t[2] < 0 ? -n : n) + wn - fe) % wn;
}
function SD() {
  var e = [], t;
  return {
    point: function(n, i, r) {
      t.push([n, i, r]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: jt,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function qh(e, t) {
  return Fe(e[0] - t[0]) < fe && Fe(e[1] - t[1]) < fe;
}
function ah(e, t, n, i) {
  this.x = e, this.z = t, this.o = n, this.e = i, this.v = !1, this.n = this.p = null;
}
function kD(e, t, n, i, r) {
  var s = [], o = [], a, l;
  if (e.forEach(function(g) {
    if (!((p = g.length - 1) <= 0)) {
      var p, m = g[0], y = g[p], b;
      if (qh(m, y)) {
        if (!m[2] && !y[2]) {
          for (r.lineStart(), a = 0; a < p; ++a)
            r.point((m = g[a])[0], m[1]);
          r.lineEnd();
          return;
        }
        y[0] += 2 * fe;
      }
      s.push(b = new ah(m, g, null, !0)), o.push(b.o = new ah(m, null, b, !1)), s.push(b = new ah(y, g, null, !1)), o.push(b.o = new ah(y, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), YA(s), YA(o), a = 0, l = o.length; a < l; ++a)
      o[a].e = n = !n;
    for (var u = s[0], c, f; ; ) {
      for (var d = u, h = !0; d.v; )
        if ((d = d.n) === u)
          return;
      c = d.z, r.lineStart();
      do {
        if (d.v = d.o.v = !0, d.e) {
          if (h)
            for (a = 0, l = c.length; a < l; ++a)
              r.point((f = c[a])[0], f[1]);
          else
            i(d.x, d.n.x, 1, r);
          d = d.n;
        } else {
          if (h)
            for (c = d.p.z, a = c.length - 1; a >= 0; --a)
              r.point((f = c[a])[0], f[1]);
          else
            i(d.x, d.p.x, -1, r);
          d = d.p;
        }
        d = d.o, c = d.z, h = !h;
      } while (!d.v);
      r.lineEnd();
    }
  }
}
function YA(e) {
  if (t = e.length) {
    for (var t, n = 0, i = e[0], r; ++n < t; )
      i.n = r = e[n], r.p = i, i = r;
    i.n = r = e[0], r.p = i;
  }
}
function E1(e) {
  return Fe(e[0]) <= Ae ? e[0] : pi(e[0]) * ((Fe(e[0]) + Ae) % wn - Ae);
}
function aV(e, t) {
  var n = E1(t), i = t[1], r = ue(i), s = [ue(n), -de(n), 0], o = 0, a = 0, l = new bn();
  r === 1 ? i = lt + fe : r === -1 && (i = -lt - fe);
  for (var u = 0, c = e.length; u < c; ++u)
    if (d = (f = e[u]).length)
      for (var f, d, h = f[d - 1], g = E1(h), p = h[1] / 2 + Pg, m = ue(p), y = de(p), b = 0; b < d; ++b, g = _, m = S, y = E, h = v) {
        var v = f[b], _ = E1(v), x = v[1] / 2 + Pg, S = ue(x), E = de(x), C = _ - g, $ = C >= 0 ? 1 : -1, N = $ * C, O = N > Ae, P = m * S;
        if (l.add(Ai(P * $ * ue(N), y * E + P * de(N))), o += O ? C + $ * wn : C, O ^ g >= n ^ _ >= n) {
          var T = gu(Na(h), Na(v));
          qg(T);
          var D = gu(s, T);
          qg(D);
          var M = (O ^ C >= 0 ? -1 : 1) * Bn(D[2]);
          (i > M || i === M && (T[0] || T[1])) && (a += O ^ C >= 0 ? 1 : -1);
        }
      }
  return (o < -fe || o < fe && l < -Lg) ^ a & 1;
}
function AD(e, t, n, i) {
  return function(r) {
    var s = t(r), o = SD(), a = t(o), l = !1, u, c, f, d = {
      point: h,
      lineStart: p,
      lineEnd: m,
      polygonStart: function() {
        d.point = y, d.lineStart = b, d.lineEnd = v, c = [], u = [];
      },
      polygonEnd: function() {
        d.point = h, d.lineStart = p, d.lineEnd = m, c = xF(c);
        var _ = aV(u, i);
        c.length ? (l || (r.polygonStart(), l = !0), kD(c, uV, _, n, r)) : _ && (l || (r.polygonStart(), l = !0), r.lineStart(), n(null, null, 1, r), r.lineEnd()), l && (r.polygonEnd(), l = !1), c = u = null;
      },
      sphere: function() {
        r.polygonStart(), r.lineStart(), n(null, null, 1, r), r.lineEnd(), r.polygonEnd();
      }
    };
    function h(_, x) {
      e(_, x) && r.point(_, x);
    }
    function g(_, x) {
      s.point(_, x);
    }
    function p() {
      d.point = g, s.lineStart();
    }
    function m() {
      d.point = h, s.lineEnd();
    }
    function y(_, x) {
      f.push([_, x]), a.point(_, x);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function v() {
      y(f[0][0], f[0][1]), a.lineEnd();
      var _ = a.clean(), x = o.result(), S, E = x.length, C, $, N;
      if (f.pop(), u.push(f), f = null, !!E) {
        if (_ & 1) {
          if ($ = x[0], (C = $.length - 1) > 0) {
            for (l || (r.polygonStart(), l = !0), r.lineStart(), S = 0; S < C; ++S)
              r.point((N = $[S])[0], N[1]);
            r.lineEnd();
          }
          return;
        }
        E > 1 && _ & 2 && x.push(x.pop().concat(x.shift())), c.push(x.filter(lV));
      }
    }
    return d;
  };
}
function lV(e) {
  return e.length > 1;
}
function uV(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - lt - fe : lt - e[1]) - ((t = t.x)[0] < 0 ? t[1] - lt - fe : lt - t[1]);
}
const XA = AD(
  function() {
    return !0;
  },
  cV,
  dV,
  [-Ae, -lt]
);
function cV(e) {
  var t = NaN, n = NaN, i = NaN, r;
  return {
    lineStart: function() {
      e.lineStart(), r = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? Ae : -Ae, l = Fe(s - t);
      Fe(l - Ae) < fe ? (e.point(t, n = (n + o) / 2 > 0 ? lt : -lt), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), r = 0) : i !== a && l >= Ae && (Fe(t - i) < fe && (t -= i * fe), Fe(s - a) < fe && (s -= a * fe), n = fV(t, n, s, o), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), r = 0), e.point(t = s, n = o), i = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - r;
    }
  };
}
function fV(e, t, n, i) {
  var r, s, o = ue(e - n);
  return Fe(o) > fe ? Gu((ue(t) * (s = de(i)) * ue(n) - ue(i) * (r = de(t)) * ue(e)) / (r * s * o)) : (t + i) / 2;
}
function dV(e, t, n, i) {
  var r;
  if (e == null)
    r = n * lt, i.point(-Ae, r), i.point(0, r), i.point(Ae, r), i.point(Ae, 0), i.point(Ae, -r), i.point(0, -r), i.point(-Ae, -r), i.point(-Ae, 0), i.point(-Ae, r);
  else if (Fe(e[0] - t[0]) > fe) {
    var s = e[0] < t[0] ? Ae : -Ae;
    r = n * s / 2, i.point(-s, r), i.point(0, r), i.point(s, r);
  } else
    i.point(t[0], t[1]);
}
function hV(e) {
  var t = de(e), n = 6 * ke, i = t > 0, r = Fe(t) > fe;
  function s(c, f, d, h) {
    oV(h, e, n, d, c, f);
  }
  function o(c, f) {
    return de(c) * de(f) > t;
  }
  function a(c) {
    var f, d, h, g, p;
    return {
      lineStart: function() {
        g = h = !1, p = 1;
      },
      point: function(m, y) {
        var b = [m, y], v, _ = o(m, y), x = i ? _ ? 0 : u(m, y) : _ ? u(m + (m < 0 ? Ae : -Ae), y) : 0;
        if (!f && (g = h = _) && c.lineStart(), _ !== h && (v = l(f, b), (!v || qh(f, v) || qh(b, v)) && (b[2] = 1)), _ !== h)
          p = 0, _ ? (c.lineStart(), v = l(b, f), c.point(v[0], v[1])) : (v = l(f, b), c.point(v[0], v[1], 2), c.lineEnd()), f = v;
        else if (r && f && i ^ _) {
          var S;
          !(x & d) && (S = l(b, f, !0)) && (p = 0, i ? (c.lineStart(), c.point(S[0][0], S[0][1]), c.point(S[1][0], S[1][1]), c.lineEnd()) : (c.point(S[1][0], S[1][1]), c.lineEnd(), c.lineStart(), c.point(S[0][0], S[0][1], 3)));
        }
        _ && (!f || !qh(f, b)) && c.point(b[0], b[1]), f = b, h = _, d = x;
      },
      lineEnd: function() {
        h && c.lineEnd(), f = null;
      },
      // Rejoin first and last segments if there were intersections and the first
      // and last points were visible.
      clean: function() {
        return p | (g && h) << 1;
      }
    };
  }
  function l(c, f, d) {
    var h = Na(c), g = Na(f), p = [1, 0, 0], m = gu(h, g), y = sh(m, m), b = m[0], v = y - b * b;
    if (!v)
      return !d && c;
    var _ = t * y / v, x = -t * b / v, S = gu(p, m), E = oh(p, _), C = oh(m, x);
    _1(E, C);
    var $ = S, N = sh(E, $), O = sh($, $), P = N * N - O * (sh(E, E) - 1);
    if (!(P < 0)) {
      var T = _n(P), D = oh($, (-N - T) / O);
      if (_1(D, E), D = Ug(D), !d)
        return D;
      var M = c[0], w = f[0], k = c[1], A = f[1], F;
      w < M && (F = M, M = w, w = F);
      var R = w - M, L = Fe(R - Ae) < fe, V = L || R < fe;
      if (!L && A < k && (F = k, k = A, A = F), V ? L ? k + A > 0 ^ D[1] < (Fe(D[0] - M) < fe ? k : A) : k <= D[1] && D[1] <= A : R > Ae ^ (M <= D[0] && D[0] <= w)) {
        var K = oh($, (-N + T) / O);
        return _1(K, E), [D, Ug(K)];
      }
    }
  }
  function u(c, f) {
    var d = i ? e : Ae - e, h = 0;
    return c < -d ? h |= 1 : c > d && (h |= 2), f < -d ? h |= 4 : f > d && (h |= 8), h;
  }
  return AD(o, a, s, i ? [0, -e] : [-Ae, e - Ae]);
}
function gV(e, t, n, i, r, s) {
  var o = e[0], a = e[1], l = t[0], u = t[1], c = 0, f = 1, d = l - o, h = u - a, g;
  if (g = n - o, !(!d && g > 0)) {
    if (g /= d, d < 0) {
      if (g < c)
        return;
      g < f && (f = g);
    } else if (d > 0) {
      if (g > f)
        return;
      g > c && (c = g);
    }
    if (g = r - o, !(!d && g < 0)) {
      if (g /= d, d < 0) {
        if (g > f)
          return;
        g > c && (c = g);
      } else if (d > 0) {
        if (g < c)
          return;
        g < f && (f = g);
      }
      if (g = i - a, !(!h && g > 0)) {
        if (g /= h, h < 0) {
          if (g < c)
            return;
          g < f && (f = g);
        } else if (h > 0) {
          if (g > f)
            return;
          g > c && (c = g);
        }
        if (g = s - a, !(!h && g < 0)) {
          if (g /= h, h < 0) {
            if (g > f)
              return;
            g > c && (c = g);
          } else if (h > 0) {
            if (g < c)
              return;
            g < f && (f = g);
          }
          return c > 0 && (e[0] = o + c * d, e[1] = a + c * h), f < 1 && (t[0] = o + f * d, t[1] = a + f * h), !0;
        }
      }
    }
  }
}
var Bc = 1e9, lh = -Bc;
function CD(e, t, n, i) {
  function r(u, c) {
    return e <= u && u <= n && t <= c && c <= i;
  }
  function s(u, c, f, d) {
    var h = 0, g = 0;
    if (u == null || (h = o(u, f)) !== (g = o(c, f)) || l(u, c) < 0 ^ f > 0)
      do
        d.point(h === 0 || h === 3 ? e : n, h > 1 ? i : t);
      while ((h = (h + f + 4) % 4) !== g);
    else
      d.point(c[0], c[1]);
  }
  function o(u, c) {
    return Fe(u[0] - e) < fe ? c > 0 ? 0 : 3 : Fe(u[0] - n) < fe ? c > 0 ? 2 : 1 : Fe(u[1] - t) < fe ? c > 0 ? 1 : 0 : c > 0 ? 3 : 2;
  }
  function a(u, c) {
    return l(u.x, c.x);
  }
  function l(u, c) {
    var f = o(u, 1), d = o(c, 1);
    return f !== d ? f - d : f === 0 ? c[1] - u[1] : f === 1 ? u[0] - c[0] : f === 2 ? u[1] - c[1] : c[0] - u[0];
  }
  return function(u) {
    var c = u, f = SD(), d, h, g, p, m, y, b, v, _, x, S, E = {
      point: C,
      lineStart: P,
      lineEnd: T,
      polygonStart: N,
      polygonEnd: O
    };
    function C(M, w) {
      r(M, w) && c.point(M, w);
    }
    function $() {
      for (var M = 0, w = 0, k = h.length; w < k; ++w)
        for (var A = h[w], F = 1, R = A.length, L = A[0], V, K, Q = L[0], ie = L[1]; F < R; ++F)
          V = Q, K = ie, L = A[F], Q = L[0], ie = L[1], K <= i ? ie > i && (Q - V) * (i - K) > (ie - K) * (e - V) && ++M : ie <= i && (Q - V) * (i - K) < (ie - K) * (e - V) && --M;
      return M;
    }
    function N() {
      c = f, d = [], h = [], S = !0;
    }
    function O() {
      var M = $(), w = S && M, k = (d = xF(d)).length;
      (w || k) && (u.polygonStart(), w && (u.lineStart(), s(null, null, 1, u), u.lineEnd()), k && kD(d, a, M, s, u), u.polygonEnd()), c = u, d = h = g = null;
    }
    function P() {
      E.point = D, h && h.push(g = []), x = !0, _ = !1, b = v = NaN;
    }
    function T() {
      d && (D(p, m), y && _ && f.rejoin(), d.push(f.result())), E.point = C, _ && c.lineEnd();
    }
    function D(M, w) {
      var k = r(M, w);
      if (h && g.push([M, w]), x)
        p = M, m = w, y = k, x = !1, k && (c.lineStart(), c.point(M, w));
      else if (k && _)
        c.point(M, w);
      else {
        var A = [b = Math.max(lh, Math.min(Bc, b)), v = Math.max(lh, Math.min(Bc, v))], F = [M = Math.max(lh, Math.min(Bc, M)), w = Math.max(lh, Math.min(Bc, w))];
        gV(A, F, e, t, n, i) ? (_ || (c.lineStart(), c.point(A[0], A[1])), c.point(F[0], F[1]), k || c.lineEnd(), S = !1) : k && (c.lineStart(), c.point(M, w), S = !1);
      }
      b = M, v = w, _ = k;
    }
    return E;
  };
}
function KA(e, t, n) {
  var i = Jn(e, t - fe, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [r, s];
    });
  };
}
function JA(e, t, n) {
  var i = Jn(e, t - fe, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [s, r];
    });
  };
}
function pV() {
  var e, t, n, i, r, s, o, a, l = 10, u = l, c = 90, f = 360, d, h, g, p, m = 2.5;
  function y() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return Jn(rh(i / c) * c, n, c).map(g).concat(Jn(rh(a / f) * f, o, f).map(p)).concat(Jn(rh(t / l) * l, e, l).filter(function(v) {
      return Fe(v % c) > fe;
    }).map(d)).concat(Jn(rh(s / u) * u, r, u).filter(function(v) {
      return Fe(v % f) > fe;
    }).map(h));
  }
  return y.lines = function() {
    return b().map(function(v) {
      return { type: "LineString", coordinates: v };
    });
  }, y.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        g(i).concat(
          p(o).slice(1),
          g(n).reverse().slice(1),
          p(a).reverse().slice(1)
        )
      ]
    };
  }, y.extent = function(v) {
    return arguments.length ? y.extentMajor(v).extentMinor(v) : y.extentMinor();
  }, y.extentMajor = function(v) {
    return arguments.length ? (i = +v[0][0], n = +v[1][0], a = +v[0][1], o = +v[1][1], i > n && (v = i, i = n, n = v), a > o && (v = a, a = o, o = v), y.precision(m)) : [[i, a], [n, o]];
  }, y.extentMinor = function(v) {
    return arguments.length ? (t = +v[0][0], e = +v[1][0], s = +v[0][1], r = +v[1][1], t > e && (v = t, t = e, e = v), s > r && (v = s, s = r, r = v), y.precision(m)) : [[t, s], [e, r]];
  }, y.step = function(v) {
    return arguments.length ? y.stepMajor(v).stepMinor(v) : y.stepMinor();
  }, y.stepMajor = function(v) {
    return arguments.length ? (c = +v[0], f = +v[1], y) : [c, f];
  }, y.stepMinor = function(v) {
    return arguments.length ? (l = +v[0], u = +v[1], y) : [l, u];
  }, y.precision = function(v) {
    return arguments.length ? (m = +v, d = KA(s, r, 90), h = JA(t, e, m), g = KA(a, o, 90), p = JA(i, n, m), y) : m;
  }, y.extentMajor([[-180, -90 + fe], [180, 90 - fe]]).extentMinor([[-180, -80 - fe], [180, 80 + fe]]);
}
const Nf = (e) => e;
var S1 = new bn(), kb = new bn(), $D, MD, Ab, Cb, os = {
  point: jt,
  lineStart: jt,
  lineEnd: jt,
  polygonStart: function() {
    os.lineStart = mV, os.lineEnd = bV;
  },
  polygonEnd: function() {
    os.lineStart = os.lineEnd = os.point = jt, S1.add(Fe(kb)), kb = new bn();
  },
  result: function() {
    var e = S1 / 2;
    return S1 = new bn(), e;
  }
};
function mV() {
  os.point = yV;
}
function yV(e, t) {
  os.point = FD, $D = Ab = e, MD = Cb = t;
}
function FD(e, t) {
  kb.add(Cb * e - Ab * t), Ab = e, Cb = t;
}
function bV() {
  FD($D, MD);
}
var pu = 1 / 0, Jg = pu, Df = -pu, Qg = Df, Zg = {
  point: vV,
  lineStart: jt,
  lineEnd: jt,
  polygonStart: jt,
  polygonEnd: jt,
  result: function() {
    var e = [[pu, Jg], [Df, Qg]];
    return Df = Qg = -(Jg = pu = 1 / 0), e;
  }
};
function vV(e, t) {
  e < pu && (pu = e), e > Df && (Df = e), t < Jg && (Jg = t), t > Qg && (Qg = t);
}
var $b = 0, Mb = 0, jc = 0, ep = 0, tp = 0, Pl = 0, Fb = 0, Tb = 0, Uc = 0, TD, OD, br, vr, hi = {
  point: Da,
  lineStart: QA,
  lineEnd: ZA,
  polygonStart: function() {
    hi.lineStart = _V, hi.lineEnd = EV;
  },
  polygonEnd: function() {
    hi.point = Da, hi.lineStart = QA, hi.lineEnd = ZA;
  },
  result: function() {
    var e = Uc ? [Fb / Uc, Tb / Uc] : Pl ? [ep / Pl, tp / Pl] : jc ? [$b / jc, Mb / jc] : [NaN, NaN];
    return $b = Mb = jc = ep = tp = Pl = Fb = Tb = Uc = 0, e;
  }
};
function Da(e, t) {
  $b += e, Mb += t, ++jc;
}
function QA() {
  hi.point = xV;
}
function xV(e, t) {
  hi.point = wV, Da(br = e, vr = t);
}
function wV(e, t) {
  var n = e - br, i = t - vr, r = _n(n * n + i * i);
  ep += r * (br + e) / 2, tp += r * (vr + t) / 2, Pl += r, Da(br = e, vr = t);
}
function ZA() {
  hi.point = Da;
}
function _V() {
  hi.point = SV;
}
function EV() {
  ND(TD, OD);
}
function SV(e, t) {
  hi.point = ND, Da(TD = br = e, OD = vr = t);
}
function ND(e, t) {
  var n = e - br, i = t - vr, r = _n(n * n + i * i);
  ep += r * (br + e) / 2, tp += r * (vr + t) / 2, Pl += r, r = vr * e - br * t, Fb += r * (br + e), Tb += r * (vr + t), Uc += r * 3, Da(br = e, vr = t);
}
function DD(e) {
  this._context = e;
}
DD.prototype = {
  _radius: 4.5,
  pointRadius: function(e) {
    return this._radius = e, this;
  },
  polygonStart: function() {
    this._line = 0;
  },
  polygonEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    this._line === 0 && this._context.closePath(), this._point = NaN;
  },
  point: function(e, t) {
    switch (this._point) {
      case 0: {
        this._context.moveTo(e, t), this._point = 1;
        break;
      }
      case 1: {
        this._context.lineTo(e, t);
        break;
      }
      default: {
        this._context.moveTo(e + this._radius, t), this._context.arc(e, t, this._radius, 0, wn);
        break;
      }
    }
  },
  result: jt
};
var Ob = new bn(), k1, RD, LD, qc, Wc, Rf = {
  point: jt,
  lineStart: function() {
    Rf.point = kV;
  },
  lineEnd: function() {
    k1 && PD(RD, LD), Rf.point = jt;
  },
  polygonStart: function() {
    k1 = !0;
  },
  polygonEnd: function() {
    k1 = null;
  },
  result: function() {
    var e = +Ob;
    return Ob = new bn(), e;
  }
};
function kV(e, t) {
  Rf.point = PD, RD = qc = e, LD = Wc = t;
}
function PD(e, t) {
  qc -= e, Wc -= t, Ob.add(_n(qc * qc + Wc * Wc)), qc = e, Wc = t;
}
let eC, np, tC, nC;
class iC {
  constructor(t) {
    this._append = t == null ? ID : AV(t), this._radius = 4.5, this._ = "";
  }
  pointRadius(t) {
    return this._radius = +t, this;
  }
  polygonStart() {
    this._line = 0;
  }
  polygonEnd() {
    this._line = NaN;
  }
  lineStart() {
    this._point = 0;
  }
  lineEnd() {
    this._line === 0 && (this._ += "Z"), this._point = NaN;
  }
  point(t, n) {
    switch (this._point) {
      case 0: {
        this._append`M${t},${n}`, this._point = 1;
        break;
      }
      case 1: {
        this._append`L${t},${n}`;
        break;
      }
      default: {
        if (this._append`M${t},${n}`, this._radius !== tC || this._append !== np) {
          const i = this._radius, r = this._;
          this._ = "", this._append`m0,${i}a${i},${i} 0 1,1 0,${-2 * i}a${i},${i} 0 1,1 0,${2 * i}z`, tC = i, np = this._append, nC = this._, this._ = r;
        }
        this._ += nC;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function ID(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function AV(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return ID;
  if (t !== eC) {
    const n = 10 ** t;
    eC = t, np = function(r) {
      let s = 1;
      this._ += r[0];
      for (const o = r.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + r[s];
    };
  }
  return np;
}
function zD(e, t) {
  let n = 3, i = 4.5, r, s;
  function o(a) {
    return a && (typeof i == "function" && s.pointRadius(+i.apply(this, arguments)), ss(a, r(s))), s.result();
  }
  return o.area = function(a) {
    return ss(a, r(os)), os.result();
  }, o.measure = function(a) {
    return ss(a, r(Rf)), Rf.result();
  }, o.bounds = function(a) {
    return ss(a, r(Zg)), Zg.result();
  }, o.centroid = function(a) {
    return ss(a, r(hi)), hi.result();
  }, o.projection = function(a) {
    return arguments.length ? (r = a == null ? (e = null, Nf) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new iC(n)) : new DD(t = a), typeof i != "function" && s.pointRadius(i), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (i = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : i;
  }, o.digits = function(a) {
    if (!arguments.length)
      return n;
    if (a == null)
      n = null;
    else {
      const l = Math.floor(a);
      if (!(l >= 0))
        throw new RangeError(`invalid digits: ${a}`);
      n = l;
    }
    return t === null && (s = new iC(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function Dm(e) {
  return function(t) {
    var n = new Nb();
    for (var i in e)
      n[i] = e[i];
    return n.stream = t, n;
  };
}
function Nb() {
}
Nb.prototype = {
  constructor: Nb,
  point: function(e, t) {
    this.stream.point(e, t);
  },
  sphere: function() {
    this.stream.sphere();
  },
  lineStart: function() {
    this.stream.lineStart();
  },
  lineEnd: function() {
    this.stream.lineEnd();
  },
  polygonStart: function() {
    this.stream.polygonStart();
  },
  polygonEnd: function() {
    this.stream.polygonEnd();
  }
};
function Aw(e, t, n) {
  var i = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), i != null && e.clipExtent(null), ss(n, e.stream(Zg)), t(Zg.result()), i != null && e.clipExtent(i), e;
}
function Rm(e, t, n) {
  return Aw(e, function(i) {
    var r = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(r / (i[1][0] - i[0][0]), s / (i[1][1] - i[0][1])), a = +t[0][0] + (r - o * (i[1][0] + i[0][0])) / 2, l = +t[0][1] + (s - o * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * o).translate([a, l]);
  }, n);
}
function Cw(e, t, n) {
  return Rm(e, [[0, 0], t], n);
}
function $w(e, t, n) {
  return Aw(e, function(i) {
    var r = +t, s = r / (i[1][0] - i[0][0]), o = (r - s * (i[1][0] + i[0][0])) / 2, a = -s * i[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function Mw(e, t, n) {
  return Aw(e, function(i) {
    var r = +t, s = r / (i[1][1] - i[0][1]), o = -s * i[0][0], a = (r - s * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var rC = 16, CV = de(30 * ke);
function sC(e, t) {
  return +t ? MV(e, t) : $V(e);
}
function $V(e) {
  return Dm({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function MV(e, t) {
  function n(i, r, s, o, a, l, u, c, f, d, h, g, p, m) {
    var y = u - i, b = c - r, v = y * y + b * b;
    if (v > 4 * t && p--) {
      var _ = o + d, x = a + h, S = l + g, E = _n(_ * _ + x * x + S * S), C = Bn(S /= E), $ = Fe(Fe(S) - 1) < fe || Fe(s - f) < fe ? (s + f) / 2 : Ai(x, _), N = e($, C), O = N[0], P = N[1], T = O - i, D = P - r, M = b * T - y * D;
      (M * M / v > t || Fe((y * T + b * D) / v - 0.5) > 0.3 || o * d + a * h + l * g < CV) && (n(i, r, s, o, a, l, O, P, $, _ /= E, x /= E, S, p, m), m.point(O, P), n(O, P, $, _, x, S, u, c, f, d, h, g, p, m));
    }
  }
  return function(i) {
    var r, s, o, a, l, u, c, f, d, h, g, p, m = {
      point: y,
      lineStart: b,
      lineEnd: _,
      polygonStart: function() {
        i.polygonStart(), m.lineStart = x;
      },
      polygonEnd: function() {
        i.polygonEnd(), m.lineStart = b;
      }
    };
    function y(C, $) {
      C = e(C, $), i.point(C[0], C[1]);
    }
    function b() {
      f = NaN, m.point = v, i.lineStart();
    }
    function v(C, $) {
      var N = Na([C, $]), O = e(C, $);
      n(f, d, c, h, g, p, f = O[0], d = O[1], c = C, h = N[0], g = N[1], p = N[2], rC, i), i.point(f, d);
    }
    function _() {
      m.point = y, i.lineEnd();
    }
    function x() {
      b(), m.point = S, m.lineEnd = E;
    }
    function S(C, $) {
      v(r = C, $), s = f, o = d, a = h, l = g, u = p, m.point = v;
    }
    function E() {
      n(f, d, c, h, g, p, s, o, r, a, l, u, rC, i), m.lineEnd = _, _();
    }
    return m;
  };
}
var FV = Dm({
  point: function(e, t) {
    this.stream.point(e * ke, t * ke);
  }
});
function TV(e) {
  return Dm({
    point: function(t, n) {
      var i = e(t, n);
      return this.stream.point(i[0], i[1]);
    }
  });
}
function OV(e, t, n, i, r) {
  function s(o, a) {
    return o *= i, a *= r, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * i, (n - a) / e * r];
  }, s;
}
function oC(e, t, n, i, r, s) {
  if (!s)
    return OV(e, t, n, i, r);
  var o = de(s), a = ue(s), l = o * e, u = a * e, c = o / e, f = a / e, d = (a * n - o * t) / e, h = (a * t + o * n) / e;
  function g(p, m) {
    return p *= i, m *= r, [l * p - u * m + t, n - u * p - l * m];
  }
  return g.invert = function(p, m) {
    return [i * (c * p - f * m + d), r * (h - f * p - c * m)];
  }, g;
}
function Br(e) {
  return BD(function() {
    return e;
  })();
}
function BD(e) {
  var t, n = 150, i = 480, r = 250, s = 0, o = 0, a = 0, l = 0, u = 0, c, f = 0, d = 1, h = 1, g = null, p = XA, m = null, y, b, v, _ = Nf, x = 0.5, S, E, C, $, N;
  function O(M) {
    return C(M[0] * ke, M[1] * ke);
  }
  function P(M) {
    return M = C.invert(M[0], M[1]), M && [M[0] * ct, M[1] * ct];
  }
  O.stream = function(M) {
    return $ && N === M ? $ : $ = FV(TV(c)(p(S(_(N = M)))));
  }, O.preclip = function(M) {
    return arguments.length ? (p = M, g = void 0, D()) : p;
  }, O.postclip = function(M) {
    return arguments.length ? (_ = M, m = y = b = v = null, D()) : _;
  }, O.clipAngle = function(M) {
    return arguments.length ? (p = +M ? hV(g = M * ke) : (g = null, XA), D()) : g * ct;
  }, O.clipExtent = function(M) {
    return arguments.length ? (_ = M == null ? (m = y = b = v = null, Nf) : CD(m = +M[0][0], y = +M[0][1], b = +M[1][0], v = +M[1][1]), D()) : m == null ? null : [[m, y], [b, v]];
  }, O.scale = function(M) {
    return arguments.length ? (n = +M, T()) : n;
  }, O.translate = function(M) {
    return arguments.length ? (i = +M[0], r = +M[1], T()) : [i, r];
  }, O.center = function(M) {
    return arguments.length ? (s = M[0] % 360 * ke, o = M[1] % 360 * ke, T()) : [s * ct, o * ct];
  }, O.rotate = function(M) {
    return arguments.length ? (a = M[0] % 360 * ke, l = M[1] % 360 * ke, u = M.length > 2 ? M[2] % 360 * ke : 0, T()) : [a * ct, l * ct, u * ct];
  }, O.angle = function(M) {
    return arguments.length ? (f = M % 360 * ke, T()) : f * ct;
  }, O.reflectX = function(M) {
    return arguments.length ? (d = M ? -1 : 1, T()) : d < 0;
  }, O.reflectY = function(M) {
    return arguments.length ? (h = M ? -1 : 1, T()) : h < 0;
  }, O.precision = function(M) {
    return arguments.length ? (S = sC(E, x = M * M), D()) : _n(x);
  }, O.fitExtent = function(M, w) {
    return Rm(O, M, w);
  }, O.fitSize = function(M, w) {
    return Cw(O, M, w);
  }, O.fitWidth = function(M, w) {
    return $w(O, M, w);
  }, O.fitHeight = function(M, w) {
    return Mw(O, M, w);
  };
  function T() {
    var M = oC(n, 0, 0, d, h, f).apply(null, t(s, o)), w = oC(n, i - M[0], r - M[1], d, h, f);
    return c = ED(a, l, u), E = Eb(t, w), C = Eb(c, E), S = sC(E, x), D();
  }
  function D() {
    return $ = N = null, O;
  }
  return function() {
    return t = e.apply(this, arguments), O.invert = t.invert && P, T();
  };
}
function Fw(e) {
  var t = 0, n = Ae / 3, i = BD(e), r = i(t, n);
  return r.parallels = function(s) {
    return arguments.length ? i(t = s[0] * ke, n = s[1] * ke) : [t * ct, n * ct];
  }, r;
}
function NV(e) {
  var t = de(e);
  function n(i, r) {
    return [i * t, ue(r) / t];
  }
  return n.invert = function(i, r) {
    return [i / t, Bn(r * t)];
  }, n;
}
function DV(e, t) {
  var n = ue(e), i = (n + ue(t)) / 2;
  if (Fe(i) < fe)
    return NV(e);
  var r = 1 + n * (2 * i - n), s = _n(r) / i;
  function o(a, l) {
    var u = _n(r - 2 * i * ue(l)) / i;
    return [u * ue(a *= i), s - u * de(a)];
  }
  return o.invert = function(a, l) {
    var u = s - l, c = Ai(a, Fe(u)) * pi(u);
    return u * i < 0 && (c -= Ae * pi(a) * pi(u)), [c / i, Bn((r - (a * a + u * u) * i * i) / (2 * i))];
  }, o;
}
function ip() {
  return Fw(DV).scale(155.424).center([0, 33.6442]);
}
function jD() {
  return ip().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function RV(e) {
  var t = e.length;
  return {
    point: function(n, i) {
      for (var r = -1; ++r < t; )
        e[r].point(n, i);
    },
    sphere: function() {
      for (var n = -1; ++n < t; )
        e[n].sphere();
    },
    lineStart: function() {
      for (var n = -1; ++n < t; )
        e[n].lineStart();
    },
    lineEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].lineEnd();
    },
    polygonStart: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonStart();
    },
    polygonEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonEnd();
    }
  };
}
function LV() {
  var e, t, n = jD(), i, r = ip().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = ip().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, l, u = { point: function(d, h) {
    l = [d, h];
  } };
  function c(d) {
    var h = d[0], g = d[1];
    return l = null, i.point(h, g), l || (s.point(h, g), l) || (a.point(h, g), l);
  }
  c.invert = function(d) {
    var h = n.scale(), g = n.translate(), p = (d[0] - g[0]) / h, m = (d[1] - g[1]) / h;
    return (m >= 0.12 && m < 0.234 && p >= -0.425 && p < -0.214 ? r : m >= 0.166 && m < 0.234 && p >= -0.214 && p < -0.115 ? o : n).invert(d);
  }, c.stream = function(d) {
    return e && t === d ? e : e = RV([n.stream(t = d), r.stream(d), o.stream(d)]);
  }, c.precision = function(d) {
    return arguments.length ? (n.precision(d), r.precision(d), o.precision(d), f()) : n.precision();
  }, c.scale = function(d) {
    return arguments.length ? (n.scale(d), r.scale(d * 0.35), o.scale(d), c.translate(n.translate())) : n.scale();
  }, c.translate = function(d) {
    if (!arguments.length)
      return n.translate();
    var h = n.scale(), g = +d[0], p = +d[1];
    return i = n.translate(d).clipExtent([[g - 0.455 * h, p - 0.238 * h], [g + 0.455 * h, p + 0.238 * h]]).stream(u), s = r.translate([g - 0.307 * h, p + 0.201 * h]).clipExtent([[g - 0.425 * h + fe, p + 0.12 * h + fe], [g - 0.214 * h - fe, p + 0.234 * h - fe]]).stream(u), a = o.translate([g - 0.205 * h, p + 0.212 * h]).clipExtent([[g - 0.214 * h + fe, p + 0.166 * h + fe], [g - 0.115 * h - fe, p + 0.234 * h - fe]]).stream(u), f();
  }, c.fitExtent = function(d, h) {
    return Rm(c, d, h);
  }, c.fitSize = function(d, h) {
    return Cw(c, d, h);
  }, c.fitWidth = function(d, h) {
    return $w(c, d, h);
  }, c.fitHeight = function(d, h) {
    return Mw(c, d, h);
  };
  function f() {
    return e = t = null, c;
  }
  return c.scale(1070);
}
function UD(e) {
  return function(t, n) {
    var i = de(t), r = de(n), s = e(i * r);
    return s === 1 / 0 ? [2, 0] : [
      s * r * ue(t),
      s * ue(n)
    ];
  };
}
function xd(e) {
  return function(t, n) {
    var i = _n(t * t + n * n), r = e(i), s = ue(r), o = de(r);
    return [
      Ai(t * s, i * o),
      Bn(i && n * s / i)
    ];
  };
}
var qD = UD(function(e) {
  return _n(2 / (1 + e));
});
qD.invert = xd(function(e) {
  return 2 * Bn(e / 2);
});
function PV() {
  return Br(qD).scale(124.75).clipAngle(180 - 1e-3);
}
var WD = UD(function(e) {
  return (e = dD(e)) && e / ue(e);
});
WD.invert = xd(function(e) {
  return e;
});
function IV() {
  return Br(WD).scale(79.4188).clipAngle(180 - 1e-3);
}
function Lm(e, t) {
  return [e, Ig(Sw((lt + t) / 2))];
}
Lm.invert = function(e, t) {
  return [e, 2 * Gu(fD(t)) - lt];
};
function zV() {
  return HD(Lm).scale(961 / wn);
}
function HD(e) {
  var t = Br(e), n = t.center, i = t.scale, r = t.translate, s = t.clipExtent, o = null, a, l, u;
  t.scale = function(f) {
    return arguments.length ? (i(f), c()) : i();
  }, t.translate = function(f) {
    return arguments.length ? (r(f), c()) : r();
  }, t.center = function(f) {
    return arguments.length ? (n(f), c()) : n();
  }, t.clipExtent = function(f) {
    return arguments.length ? (f == null ? o = a = l = u = null : (o = +f[0][0], a = +f[0][1], l = +f[1][0], u = +f[1][1]), c()) : o == null ? null : [[o, a], [l, u]];
  };
  function c() {
    var f = Ae * i(), d = t(sV(t.rotate()).invert([0, 0]));
    return s(o == null ? [[d[0] - f, d[1] - f], [d[0] + f, d[1] + f]] : e === Lm ? [[Math.max(d[0] - f, o), a], [Math.min(d[0] + f, l), u]] : [[o, Math.max(d[1] - f, a)], [l, Math.min(d[1] + f, u)]]);
  }
  return c();
}
function uh(e) {
  return Sw((lt + e) / 2);
}
function BV(e, t) {
  var n = de(e), i = e === t ? ue(e) : Ig(n / de(t)) / Ig(uh(t) / uh(e)), r = n * w1(uh(e), i) / i;
  if (!i)
    return Lm;
  function s(o, a) {
    r > 0 ? a < -lt + fe && (a = -lt + fe) : a > lt - fe && (a = lt - fe);
    var l = r / w1(uh(a), i);
    return [l * ue(i * o), r - l * de(i * o)];
  }
  return s.invert = function(o, a) {
    var l = r - a, u = pi(i) * _n(o * o + l * l), c = Ai(o, Fe(l)) * pi(l);
    return l * i < 0 && (c -= Ae * pi(o) * pi(l)), [c / i, 2 * Gu(w1(r / u, 1 / i)) - lt];
  }, s;
}
function jV() {
  return Fw(BV).scale(109.5).parallels([30, 30]);
}
function rp(e, t) {
  return [e, t];
}
rp.invert = rp;
function UV() {
  return Br(rp).scale(152.63);
}
function qV(e, t) {
  var n = de(e), i = e === t ? ue(e) : (n - de(t)) / (t - e), r = n / i + e;
  if (Fe(i) < fe)
    return rp;
  function s(o, a) {
    var l = r - a, u = i * o;
    return [l * ue(u), r - l * de(u)];
  }
  return s.invert = function(o, a) {
    var l = r - a, u = Ai(o, Fe(l)) * pi(l);
    return l * i < 0 && (u -= Ae * pi(o) * pi(l)), [u / i, r - pi(i) * _n(o * o + l * l)];
  }, s;
}
function WV() {
  return Fw(qV).scale(131.154).center([0, 13.9389]);
}
var of = 1.340264, af = -0.081106, lf = 893e-6, uf = 3796e-6, sp = _n(3) / 2, HV = 12;
function GD(e, t) {
  var n = Bn(sp * ue(t)), i = n * n, r = i * i * i;
  return [
    e * de(n) / (sp * (of + 3 * af * i + r * (7 * lf + 9 * uf * i))),
    n * (of + af * i + r * (lf + uf * i))
  ];
}
GD.invert = function(e, t) {
  for (var n = t, i = n * n, r = i * i * i, s = 0, o, a, l; s < HV && (a = n * (of + af * i + r * (lf + uf * i)) - t, l = of + 3 * af * i + r * (7 * lf + 9 * uf * i), n -= o = a / l, i = n * n, r = i * i * i, !(Fe(o) < Lg)); ++s)
    ;
  return [
    sp * e * (of + 3 * af * i + r * (7 * lf + 9 * uf * i)) / de(n),
    Bn(ue(n) / sp)
  ];
};
function GV() {
  return Br(GD).scale(177.158);
}
function VD(e, t) {
  var n = de(t), i = de(e) * n;
  return [n * ue(e) / i, ue(t) / i];
}
VD.invert = xd(Gu);
function VV() {
  return Br(VD).scale(144.049).clipAngle(60);
}
function YV() {
  var e = 1, t = 0, n = 0, i = 1, r = 1, s = 0, o, a, l = null, u, c, f, d = 1, h = 1, g = Dm({
    point: function(_, x) {
      var S = v([_, x]);
      this.stream.point(S[0], S[1]);
    }
  }), p = Nf, m, y;
  function b() {
    return d = e * i, h = e * r, m = y = null, v;
  }
  function v(_) {
    var x = _[0] * d, S = _[1] * h;
    if (s) {
      var E = S * o - x * a;
      x = x * o + S * a, S = E;
    }
    return [x + t, S + n];
  }
  return v.invert = function(_) {
    var x = _[0] - t, S = _[1] - n;
    if (s) {
      var E = S * o + x * a;
      x = x * o - S * a, S = E;
    }
    return [x / d, S / h];
  }, v.stream = function(_) {
    return m && y === _ ? m : m = g(p(y = _));
  }, v.postclip = function(_) {
    return arguments.length ? (p = _, l = u = c = f = null, b()) : p;
  }, v.clipExtent = function(_) {
    return arguments.length ? (p = _ == null ? (l = u = c = f = null, Nf) : CD(l = +_[0][0], u = +_[0][1], c = +_[1][0], f = +_[1][1]), b()) : l == null ? null : [[l, u], [c, f]];
  }, v.scale = function(_) {
    return arguments.length ? (e = +_, b()) : e;
  }, v.translate = function(_) {
    return arguments.length ? (t = +_[0], n = +_[1], b()) : [t, n];
  }, v.angle = function(_) {
    return arguments.length ? (s = _ % 360 * ke, a = ue(s), o = de(s), b()) : s * ct;
  }, v.reflectX = function(_) {
    return arguments.length ? (i = _ ? -1 : 1, b()) : i < 0;
  }, v.reflectY = function(_) {
    return arguments.length ? (r = _ ? -1 : 1, b()) : r < 0;
  }, v.fitExtent = function(_, x) {
    return Rm(v, _, x);
  }, v.fitSize = function(_, x) {
    return Cw(v, _, x);
  }, v.fitWidth = function(_, x) {
    return $w(v, _, x);
  }, v.fitHeight = function(_, x) {
    return Mw(v, _, x);
  }, v;
}
function YD(e, t) {
  var n = t * t, i = n * n;
  return [
    e * (0.8707 - 0.131979 * n + i * (-0.013791 + i * (3971e-6 * n - 1529e-6 * i))),
    t * (1.007226 + n * (0.015085 + i * (-0.044475 + 0.028874 * n - 5916e-6 * i)))
  ];
}
YD.invert = function(e, t) {
  var n = t, i = 25, r;
  do {
    var s = n * n, o = s * s;
    n -= r = (n * (1.007226 + s * (0.015085 + o * (-0.044475 + 0.028874 * s - 5916e-6 * o))) - t) / (1.007226 + s * (0.015085 * 3 + o * (-0.044475 * 7 + 0.028874 * 9 * s - 5916e-6 * 11 * o)));
  } while (Fe(r) > fe && --i > 0);
  return [
    e / (0.8707 + (s = n * n) * (-0.131979 + s * (-0.013791 + s * s * s * (3971e-6 - 1529e-6 * s)))),
    n
  ];
};
function XV() {
  return Br(YD).scale(175.295);
}
function XD(e, t) {
  return [de(t) * ue(e), ue(t)];
}
XD.invert = xd(Bn);
function KV() {
  return Br(XD).scale(249.5).clipAngle(90 + fe);
}
function KD(e, t) {
  var n = de(t), i = 1 + de(e) * n;
  return [n * ue(e) / i, ue(t) / i];
}
KD.invert = xd(function(e) {
  return 2 * Gu(e);
});
function JV() {
  return Br(KD).scale(250).clipAngle(142);
}
function JD(e, t) {
  return [Ig(Sw((lt + t) / 2)), -e];
}
JD.invert = function(e, t) {
  return [-t, 2 * Gu(fD(e)) - lt];
};
function QV() {
  var e = HD(JD), t = e.center, n = e.rotate;
  return e.center = function(i) {
    return arguments.length ? t([-i[1], i[0]]) : (i = t(), [i[1], -i[0]]);
  }, e.rotate = function(i) {
    return arguments.length ? n([i[0], i[1], i.length > 2 ? i[2] + 90 : 90]) : (i = n(), [i[0], i[1], i[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
var ZV = Math.abs, Db = Math.cos, op = Math.sin, eY = 1e-6, QD = Math.PI, Rb = QD / 2, aC = tY(2);
function lC(e) {
  return e > 1 ? Rb : e < -1 ? -Rb : Math.asin(e);
}
function tY(e) {
  return e > 0 ? Math.sqrt(e) : 0;
}
function nY(e, t) {
  var n = e * op(t), i = 30, r;
  do
    t -= r = (t + op(t) - n) / (1 + Db(t));
  while (ZV(r) > eY && --i > 0);
  return t / 2;
}
function iY(e, t, n) {
  function i(r, s) {
    return [e * r * Db(s = nY(n, s)), t * op(s)];
  }
  return i.invert = function(r, s) {
    return s = lC(s / t), [r / (e * Db(s)), lC((2 * s + op(2 * s)) / n)];
  }, i;
}
var rY = iY(aC / Rb, aC, QD);
function sY() {
  return Br(rY).scale(169.529);
}
const oY = zD(), Lb = [
  // standard properties in d3-geo
  "clipAngle",
  "clipExtent",
  "scale",
  "translate",
  "center",
  "rotate",
  "parallels",
  "precision",
  "reflectX",
  "reflectY",
  // extended properties in d3-geo-projections
  "coefficient",
  "distance",
  "fraction",
  "lobes",
  "parallel",
  "radius",
  "ratio",
  "spacing",
  "tilt"
];
function aY(e, t) {
  return function n() {
    const i = t();
    return i.type = e, i.path = zD().projection(i), i.copy = i.copy || function() {
      const r = n();
      return Lb.forEach((s) => {
        i[s] && r[s](i[s]());
      }), r.path.pointRadius(i.path.pointRadius()), r;
    }, yO(i);
  };
}
function Tw(e, t) {
  if (!e || typeof e != "string")
    throw new Error("Projection type must be a name string.");
  return e = e.toLowerCase(), arguments.length > 1 ? (ap[e] = aY(e, t), this) : ap[e] || null;
}
function ZD(e) {
  return e && e.path || oY;
}
const ap = {
  // base d3-geo projection types
  albers: jD,
  albersusa: LV,
  azimuthalequalarea: PV,
  azimuthalequidistant: IV,
  conicconformal: jV,
  conicequalarea: ip,
  conicequidistant: WV,
  equalEarth: GV,
  equirectangular: UV,
  gnomonic: VV,
  identity: YV,
  mercator: zV,
  mollweide: sY,
  naturalEarth1: XV,
  orthographic: KV,
  stereographic: JV,
  transversemercator: QV
};
for (const e in ap)
  Tw(e, ap[e]);
function lY() {
}
const Jr = [[], [[[1, 1.5], [0.5, 1]]], [[[1.5, 1], [1, 1.5]]], [[[1.5, 1], [0.5, 1]]], [[[1, 0.5], [1.5, 1]]], [[[1, 1.5], [0.5, 1]], [[1, 0.5], [1.5, 1]]], [[[1, 0.5], [1, 1.5]]], [[[1, 0.5], [0.5, 1]]], [[[0.5, 1], [1, 0.5]]], [[[1, 1.5], [1, 0.5]]], [[[0.5, 1], [1, 0.5]], [[1.5, 1], [1, 1.5]]], [[[1.5, 1], [1, 0.5]]], [[[0.5, 1], [1.5, 1]]], [[[1, 1.5], [1.5, 1]]], [[[0.5, 1], [1, 1.5]]], []];
function eR() {
  var e = 1, t = 1, n = a;
  function i(l, u) {
    return u.map((c) => r(l, c));
  }
  function r(l, u) {
    var c = [], f = [];
    return s(l, u, (d) => {
      n(d, l, u), uY(d) > 0 ? c.push([d]) : f.push(d);
    }), f.forEach((d) => {
      for (var h = 0, g = c.length, p; h < g; ++h)
        if (cY((p = c[h])[0], d) !== -1) {
          p.push(d);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: u,
      coordinates: c
    };
  }
  function s(l, u, c) {
    var f = new Array(), d = new Array(), h, g, p, m, y, b;
    for (h = g = -1, m = l[0] >= u, Jr[m << 1].forEach(v); ++h < e - 1; )
      p = m, m = l[h + 1] >= u, Jr[p | m << 1].forEach(v);
    for (Jr[m << 0].forEach(v); ++g < t - 1; ) {
      for (h = -1, m = l[g * e + e] >= u, y = l[g * e] >= u, Jr[m << 1 | y << 2].forEach(v); ++h < e - 1; )
        p = m, m = l[g * e + e + h + 1] >= u, b = y, y = l[g * e + h + 1] >= u, Jr[p | m << 1 | y << 2 | b << 3].forEach(v);
      Jr[m | y << 3].forEach(v);
    }
    for (h = -1, y = l[g * e] >= u, Jr[y << 2].forEach(v); ++h < e - 1; )
      b = y, y = l[g * e + h + 1] >= u, Jr[y << 2 | b << 3].forEach(v);
    Jr[y << 3].forEach(v);
    function v(_) {
      var x = [_[0][0] + h, _[0][1] + g], S = [_[1][0] + h, _[1][1] + g], E = o(x), C = o(S), $, N;
      ($ = d[E]) ? (N = f[C]) ? (delete d[$.end], delete f[N.start], $ === N ? ($.ring.push(S), c($.ring)) : f[$.start] = d[N.end] = {
        start: $.start,
        end: N.end,
        ring: $.ring.concat(N.ring)
      }) : (delete d[$.end], $.ring.push(S), d[$.end = C] = $) : ($ = f[C]) ? (N = d[E]) ? (delete f[$.start], delete d[N.end], $ === N ? ($.ring.push(S), c($.ring)) : f[N.start] = d[$.end] = {
        start: N.start,
        end: $.end,
        ring: N.ring.concat($.ring)
      }) : (delete f[$.start], $.ring.unshift(x), f[$.start = E] = $) : f[E] = d[C] = {
        start: E,
        end: C,
        ring: [x, S]
      };
    }
  }
  function o(l) {
    return l[0] * 2 + l[1] * (e + 1) * 4;
  }
  function a(l, u, c) {
    l.forEach((f) => {
      var d = f[0], h = f[1], g = d | 0, p = h | 0, m, y = u[p * e + g];
      d > 0 && d < e && g === d && (m = u[p * e + g - 1], f[0] = d + (c - m) / (y - m) - 0.5), h > 0 && h < t && p === h && (m = u[(p - 1) * e + g], f[1] = h + (c - m) / (y - m) - 0.5);
    });
  }
  return i.contour = r, i.size = function(l) {
    if (!arguments.length)
      return [e, t];
    var u = Math.floor(l[0]), c = Math.floor(l[1]);
    return u >= 0 && c >= 0 || j("invalid size"), e = u, t = c, i;
  }, i.smooth = function(l) {
    return arguments.length ? (n = l ? a : lY, i) : n === a;
  }, i;
}
function uY(e) {
  for (var t = 0, n = e.length, i = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; )
    i += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return i;
}
function cY(e, t) {
  for (var n = -1, i = t.length, r; ++n < i; )
    if (r = fY(e, t[n]))
      return r;
  return 0;
}
function fY(e, t) {
  for (var n = t[0], i = t[1], r = -1, s = 0, o = e.length, a = o - 1; s < o; a = s++) {
    var l = e[s], u = l[0], c = l[1], f = e[a], d = f[0], h = f[1];
    if (dY(l, f, t))
      return 0;
    c > i != h > i && n < (d - u) * (i - c) / (h - c) + u && (r = -r);
  }
  return r;
}
function dY(e, t, n) {
  var i;
  return hY(e, t, n) && gY(e[i = +(e[0] === t[0])], n[i], t[i]);
}
function hY(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function gY(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function tR(e, t, n) {
  return function(i) {
    var r = $r(i), s = n ? Math.min(r[0], 0) : r[0], o = r[1], a = o - s, l = t ? ho(s, o, e) : a / (e + 1);
    return Jn(s + l, o, l);
  };
}
function Ow(e) {
  I.call(this, null, e);
}
Ow.Definition = {
  type: "Isocontour",
  metadata: {
    generates: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "thresholds",
    type: "number",
    array: !0
  }, {
    name: "levels",
    type: "number"
  }, {
    name: "nice",
    type: "boolean",
    default: !1
  }, {
    name: "resolve",
    type: "enum",
    values: ["shared", "independent"],
    default: "independent"
  }, {
    name: "zero",
    type: "boolean",
    default: !0
  }, {
    name: "smooth",
    type: "boolean",
    default: !0
  }, {
    name: "scale",
    type: "number",
    expr: !0
  }, {
    name: "translate",
    type: "number",
    array: !0,
    expr: !0
  }, {
    name: "as",
    type: "string",
    null: !0,
    default: "contour"
  }]
};
Y(Ow, I, {
  transform(e, t) {
    if (this.value && !t.changed() && !e.modified())
      return t.StopPropagation;
    var n = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = t.materialize(t.SOURCE).source, r = e.field || an, s = eR().smooth(e.smooth !== !1), o = e.thresholds || pY(i, r, e), a = e.as === null ? null : e.as || "contour", l = [];
    return i.forEach((u) => {
      const c = r(u), f = s.size([c.width, c.height])(c.values, U(o) ? o : o(c.values));
      mY(f, c, u, e), f.forEach((d) => {
        l.push(Qp(u, je(a != null ? {
          [a]: d
        } : d)));
      });
    }), this.value && (n.rem = this.value), this.value = n.source = n.add = l, n;
  }
});
function pY(e, t, n) {
  const i = tR(n.levels || 10, n.nice, n.zero !== !1);
  return n.resolve !== "shared" ? i : i(e.map((r) => va(t(r).values)));
}
function mY(e, t, n, i) {
  let r = i.scale || t.scale, s = i.translate || t.translate;
  if (Ee(r) && (r = r(n, i)), Ee(s) && (s = s(n, i)), (r === 1 || r == null) && !s)
    return;
  const o = (Re(r) ? r : r[0]) || 1, a = (Re(r) ? r : r[1]) || 1, l = s && s[0] || 0, u = s && s[1] || 0;
  e.forEach(nR(t, o, a, l, u));
}
function nR(e, t, n, i, r) {
  const s = e.x1 || 0, o = e.y1 || 0, a = t * n < 0;
  function l(f) {
    f.forEach(u);
  }
  function u(f) {
    a && f.reverse(), f.forEach(c);
  }
  function c(f) {
    f[0] = (f[0] - s) * t + i, f[1] = (f[1] - o) * n + r;
  }
  return function(f) {
    return f.coordinates.forEach(l), f;
  };
}
function uC(e, t, n) {
  const i = e >= 0 ? e : wx(t, n);
  return Math.round((Math.sqrt(4 * i * i + 1) - 1) / 2);
}
function A1(e) {
  return Ee(e) ? e : ln(+e);
}
function iR() {
  var e = (l) => l[0], t = (l) => l[1], n = Nu, i = [-1, -1], r = 960, s = 500, o = 2;
  function a(l, u) {
    const c = uC(i[0], l, e) >> o, f = uC(i[1], l, t) >> o, d = c ? c + 2 : 0, h = f ? f + 2 : 0, g = 2 * d + (r >> o), p = 2 * h + (s >> o), m = new Float32Array(g * p), y = new Float32Array(g * p);
    let b = m;
    l.forEach((_) => {
      const x = d + (+e(_) >> o), S = h + (+t(_) >> o);
      x >= 0 && x < g && S >= 0 && S < p && (m[x + S * g] += +n(_));
    }), c > 0 && f > 0 ? (xl(g, p, m, y, c), wl(g, p, y, m, f), xl(g, p, m, y, c), wl(g, p, y, m, f), xl(g, p, m, y, c), wl(g, p, y, m, f)) : c > 0 ? (xl(g, p, m, y, c), xl(g, p, y, m, c), xl(g, p, m, y, c), b = y) : f > 0 && (wl(g, p, m, y, f), wl(g, p, y, m, f), wl(g, p, m, y, f), b = y);
    const v = u ? Math.pow(2, -2 * o) : 1 / wF(b);
    for (let _ = 0, x = g * p; _ < x; ++_)
      b[_] *= v;
    return {
      values: b,
      scale: 1 << o,
      width: g,
      height: p,
      x1: d,
      y1: h,
      x2: d + (r >> o),
      y2: h + (s >> o)
    };
  }
  return a.x = function(l) {
    return arguments.length ? (e = A1(l), a) : e;
  }, a.y = function(l) {
    return arguments.length ? (t = A1(l), a) : t;
  }, a.weight = function(l) {
    return arguments.length ? (n = A1(l), a) : n;
  }, a.size = function(l) {
    if (!arguments.length)
      return [r, s];
    var u = +l[0], c = +l[1];
    return u >= 0 && c >= 0 || j("invalid size"), r = u, s = c, a;
  }, a.cellSize = function(l) {
    return arguments.length ? ((l = +l) >= 1 || j("invalid cell size"), o = Math.floor(Math.log(l) / Math.LN2), a) : 1 << o;
  }, a.bandwidth = function(l) {
    return arguments.length ? (l = ee(l), l.length === 1 && (l = [+l[0], +l[0]]), l.length !== 2 && j("invalid bandwidth"), i = l, a) : i;
  }, a;
}
function xl(e, t, n, i, r) {
  const s = (r << 1) + 1;
  for (let o = 0; o < t; ++o)
    for (let a = 0, l = 0; a < e + r; ++a)
      a < e && (l += n[a + o * e]), a >= r && (a >= s && (l -= n[a - s + o * e]), i[a - r + o * e] = l / Math.min(a + 1, e - 1 + s - a, s));
}
function wl(e, t, n, i, r) {
  const s = (r << 1) + 1;
  for (let o = 0; o < e; ++o)
    for (let a = 0, l = 0; a < t + r; ++a)
      a < t && (l += n[o + a * e]), a >= r && (a >= s && (l -= n[o + (a - s) * e]), i[o + (a - r) * e] = l / Math.min(a + 1, t - 1 + s - a, s));
}
function Nw(e) {
  I.call(this, null, e);
}
Nw.Definition = {
  type: "KDE2D",
  metadata: {
    generates: !0
  },
  params: [{
    name: "size",
    type: "number",
    array: !0,
    length: 2,
    required: !0
  }, {
    name: "x",
    type: "field",
    required: !0
  }, {
    name: "y",
    type: "field",
    required: !0
  }, {
    name: "weight",
    type: "field"
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "cellSize",
    type: "number"
  }, {
    name: "bandwidth",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "counts",
    type: "boolean",
    default: !1
  }, {
    name: "as",
    type: "string",
    default: "grid"
  }]
};
const yY = ["x", "y", "weight", "size", "cellSize", "bandwidth"];
function rR(e, t) {
  return yY.forEach((n) => t[n] != null ? e[n](t[n]) : 0), e;
}
Y(Nw, I, {
  transform(e, t) {
    if (this.value && !t.changed() && !e.modified())
      return t.StopPropagation;
    var n = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = t.materialize(t.SOURCE).source, r = bY(i, e.groupby), s = (e.groupby || []).map(ut), o = rR(iR(), e), a = e.as || "grid", l = [];
    function u(c, f) {
      for (let d = 0; d < s.length; ++d)
        c[s[d]] = f[d];
      return c;
    }
    return l = r.map((c) => je(u({
      [a]: o(c, e.counts)
    }, c.dims))), this.value && (n.rem = this.value), this.value = n.source = n.add = l, n;
  }
});
function bY(e, t) {
  var n = [], i = (c) => c(a), r, s, o, a, l, u;
  if (t == null)
    n.push(e);
  else
    for (r = {}, s = 0, o = e.length; s < o; ++s)
      a = e[s], l = t.map(i), u = r[l], u || (r[l] = u = [], u.dims = l, n.push(u)), u.push(a);
  return n;
}
function Dw(e) {
  I.call(this, null, e);
}
Dw.Definition = {
  type: "Contour",
  metadata: {
    generates: !0
  },
  params: [{
    name: "size",
    type: "number",
    array: !0,
    length: 2,
    required: !0
  }, {
    name: "values",
    type: "number",
    array: !0
  }, {
    name: "x",
    type: "field"
  }, {
    name: "y",
    type: "field"
  }, {
    name: "weight",
    type: "field"
  }, {
    name: "cellSize",
    type: "number"
  }, {
    name: "bandwidth",
    type: "number"
  }, {
    name: "count",
    type: "number"
  }, {
    name: "nice",
    type: "boolean",
    default: !1
  }, {
    name: "thresholds",
    type: "number",
    array: !0
  }, {
    name: "smooth",
    type: "boolean",
    default: !0
  }]
};
Y(Dw, I, {
  transform(e, t) {
    if (this.value && !t.changed() && !e.modified())
      return t.StopPropagation;
    var n = t.fork(t.NO_SOURCE | t.NO_FIELDS), i = eR().smooth(e.smooth !== !1), r = e.values, s = e.thresholds || tR(e.count || 10, e.nice, !!r), o = e.size, a, l;
    return r || (r = t.materialize(t.SOURCE).source, a = rR(iR(), e)(r, !0), l = nR(a, a.scale || 1, a.scale || 1, 0, 0), o = [a.width, a.height], r = a.values), s = U(s) ? s : s(r), r = i.size(o)(r, s), l && r.forEach(l), this.value && (n.rem = this.value), this.value = n.source = n.add = (r || []).map(je), n;
  }
});
const Pb = "Feature", Rw = "FeatureCollection", vY = "MultiPoint";
function Lw(e) {
  I.call(this, null, e);
}
Lw.Definition = {
  type: "GeoJSON",
  metadata: {},
  params: [{
    name: "fields",
    type: "field",
    array: !0,
    length: 2
  }, {
    name: "geojson",
    type: "field"
  }]
};
Y(Lw, I, {
  transform(e, t) {
    var n = this._features, i = this._points, r = e.fields, s = r && r[0], o = r && r[1], a = e.geojson || !r && an, l = t.ADD, u;
    u = e.modified() || t.changed(t.REM) || t.modified(nn(a)) || s && t.modified(nn(s)) || o && t.modified(nn(o)), (!this.value || u) && (l = t.SOURCE, this._features = n = [], this._points = i = []), a && t.visit(l, (c) => n.push(a(c))), s && o && (t.visit(l, (c) => {
      var f = s(c), d = o(c);
      f != null && d != null && (f = +f) === f && (d = +d) === d && i.push([f, d]);
    }), n = n.concat({
      type: Pb,
      geometry: {
        type: vY,
        coordinates: i
      }
    })), this.value = {
      type: Rw,
      features: n
    };
  }
});
function Pw(e) {
  I.call(this, null, e);
}
Pw.Definition = {
  type: "GeoPath",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "projection",
    type: "projection"
  }, {
    name: "field",
    type: "field"
  }, {
    name: "pointRadius",
    type: "number",
    expr: !0
  }, {
    name: "as",
    type: "string",
    default: "path"
  }]
};
Y(Pw, I, {
  transform(e, t) {
    var n = t.fork(t.ALL), i = this.value, r = e.field || an, s = e.as || "path", o = n.SOURCE;
    !i || e.modified() ? (this.value = i = ZD(e.projection), n.materialize().reflow()) : o = r === an || t.modified(r.fields) ? n.ADD_MOD : n.ADD;
    const a = xY(i, e.pointRadius);
    return n.visit(o, (l) => l[s] = i(r(l))), i.pointRadius(a), n.modifies(s);
  }
});
function xY(e, t) {
  const n = e.pointRadius();
  return e.context(null), t != null && e.pointRadius(t), n;
}
function Iw(e) {
  I.call(this, null, e);
}
Iw.Definition = {
  type: "GeoPoint",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "projection",
    type: "projection",
    required: !0
  }, {
    name: "fields",
    type: "field",
    array: !0,
    required: !0,
    length: 2
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 2,
    default: ["x", "y"]
  }]
};
Y(Iw, I, {
  transform(e, t) {
    var n = e.projection, i = e.fields[0], r = e.fields[1], s = e.as || ["x", "y"], o = s[0], a = s[1], l;
    function u(c) {
      const f = n([i(c), r(c)]);
      f ? (c[o] = f[0], c[a] = f[1]) : (c[o] = void 0, c[a] = void 0);
    }
    return e.modified() ? t = t.materialize().reflow(!0).visit(t.SOURCE, u) : (l = t.modified(i.fields) || t.modified(r.fields), t.visit(l ? t.ADD_MOD : t.ADD, u)), t.modifies(s);
  }
});
function zw(e) {
  I.call(this, null, e);
}
zw.Definition = {
  type: "GeoShape",
  metadata: {
    modifies: !0,
    nomod: !0
  },
  params: [{
    name: "projection",
    type: "projection"
  }, {
    name: "field",
    type: "field",
    default: "datum"
  }, {
    name: "pointRadius",
    type: "number",
    expr: !0
  }, {
    name: "as",
    type: "string",
    default: "shape"
  }]
};
Y(zw, I, {
  transform(e, t) {
    var n = t.fork(t.ALL), i = this.value, r = e.as || "shape", s = n.ADD;
    return (!i || e.modified()) && (this.value = i = wY(ZD(e.projection), e.field || _i("datum"), e.pointRadius), n.materialize().reflow(), s = n.SOURCE), n.visit(s, (o) => o[r] = i), n.modifies(r);
  }
});
function wY(e, t, n) {
  const i = n == null ? (r) => e(t(r)) : (r) => {
    var s = e.pointRadius(), o = e.pointRadius(n)(t(r));
    return e.pointRadius(s), o;
  };
  return i.context = (r) => (e.context(r), i), i;
}
function Bw(e) {
  I.call(this, [], e), this.generator = pV();
}
Bw.Definition = {
  type: "Graticule",
  metadata: {
    changes: !0,
    generates: !0
  },
  params: [{
    name: "extent",
    type: "array",
    array: !0,
    length: 2,
    content: {
      type: "number",
      array: !0,
      length: 2
    }
  }, {
    name: "extentMajor",
    type: "array",
    array: !0,
    length: 2,
    content: {
      type: "number",
      array: !0,
      length: 2
    }
  }, {
    name: "extentMinor",
    type: "array",
    array: !0,
    length: 2,
    content: {
      type: "number",
      array: !0,
      length: 2
    }
  }, {
    name: "step",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "stepMajor",
    type: "number",
    array: !0,
    length: 2,
    default: [90, 360]
  }, {
    name: "stepMinor",
    type: "number",
    array: !0,
    length: 2,
    default: [10, 10]
  }, {
    name: "precision",
    type: "number",
    default: 2.5
  }]
};
Y(Bw, I, {
  transform(e, t) {
    var n = this.value, i = this.generator, r;
    if (!n.length || e.modified())
      for (const s in e)
        Ee(i[s]) && i[s](e[s]);
    return r = i(), n.length ? t.mod.push(mT(n[0], r)) : t.add.push(je(r)), n[0] = r, t;
  }
});
function jw(e) {
  I.call(this, null, e);
}
jw.Definition = {
  type: "heatmap",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "color",
    type: "string",
    expr: !0
  }, {
    name: "opacity",
    type: "number",
    expr: !0
  }, {
    name: "resolve",
    type: "enum",
    values: ["shared", "independent"],
    default: "independent"
  }, {
    name: "as",
    type: "string",
    default: "image"
  }]
};
Y(jw, I, {
  transform(e, t) {
    if (!t.changed() && !e.modified())
      return t.StopPropagation;
    var n = t.materialize(t.SOURCE).source, i = e.resolve === "shared", r = e.field || an, s = EY(e.opacity, e), o = _Y(e.color, e), a = e.as || "image", l = {
      $x: 0,
      $y: 0,
      $value: 0,
      $max: i ? va(n.map((u) => va(r(u).values))) : 0
    };
    return n.forEach((u) => {
      const c = r(u), f = we({}, u, l);
      i || (f.$max = va(c.values || [])), u[a] = SY(c, f, o.dep ? o : ln(o(f)), s.dep ? s : ln(s(f)));
    }), t.reflow(!0).modifies(a);
  }
});
function _Y(e, t) {
  let n;
  return Ee(e) ? (n = (i) => mo(e(i, t)), n.dep = sR(e)) : n = ln(mo(e || "#888")), n;
}
function EY(e, t) {
  let n;
  return Ee(e) ? (n = (i) => e(i, t), n.dep = sR(e)) : e ? n = ln(e) : (n = (i) => i.$value / i.$max || 0, n.dep = !0), n;
}
function sR(e) {
  if (!Ee(e))
    return !1;
  const t = Ji(nn(e));
  return t.$x || t.$y || t.$value || t.$max;
}
function SY(e, t, n, i) {
  const r = e.width, s = e.height, o = e.x1 || 0, a = e.y1 || 0, l = e.x2 || r, u = e.y2 || s, c = e.values, f = c ? (m) => c[m] : Xs, d = lo(l - o, u - a), h = d.getContext("2d"), g = h.getImageData(0, 0, l - o, u - a), p = g.data;
  for (let m = a, y = 0; m < u; ++m) {
    t.$y = m - a;
    for (let b = o, v = m * r; b < l; ++b, y += 4) {
      t.$x = b - o, t.$value = f(b + v);
      const _ = n(t);
      p[y + 0] = _.r, p[y + 1] = _.g, p[y + 2] = _.b, p[y + 3] = ~~(255 * i(t));
    }
  }
  return h.putImageData(g, 0, 0), d;
}
function oR(e) {
  I.call(this, null, e), this.modified(!0);
}
Y(oR, I, {
  transform(e, t) {
    let n = this.value;
    return !n || e.modified("type") ? (this.value = n = AY(e.type), Lb.forEach((i) => {
      e[i] != null && cC(n, i, e[i]);
    })) : Lb.forEach((i) => {
      e.modified(i) && cC(n, i, e[i]);
    }), e.pointRadius != null && n.path.pointRadius(e.pointRadius), e.fit && kY(n, e), t.fork(t.NO_SOURCE | t.NO_FIELDS);
  }
});
function kY(e, t) {
  const n = CY(t.fit);
  t.extent ? e.fitExtent(t.extent, n) : t.size && e.fitSize(t.size, n);
}
function AY(e) {
  const t = Tw((e || "mercator").toLowerCase());
  return t || j("Unrecognized projection type: " + e), t();
}
function cC(e, t, n) {
  Ee(e[t]) && e[t](n);
}
function CY(e) {
  return e = ee(e), e.length === 1 ? e[0] : {
    type: Rw,
    features: e.reduce((t, n) => t.concat($Y(n)), [])
  };
}
function $Y(e) {
  return e.type === Rw ? e.features : ee(e).filter((t) => t != null).map((t) => t.type === Pb ? t : {
    type: Pb,
    geometry: t
  });
}
const MY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  contour: Dw,
  geojson: Lw,
  geopath: Pw,
  geopoint: Iw,
  geoshape: zw,
  graticule: Bw,
  heatmap: jw,
  isocontour: Ow,
  kde2d: Nw,
  projection: oR
}, Symbol.toStringTag, { value: "Module" }));
function FY(e, t) {
  var n, i = 1;
  e == null && (e = 0), t == null && (t = 0);
  function r() {
    var s, o = n.length, a, l = 0, u = 0;
    for (s = 0; s < o; ++s)
      a = n[s], l += a.x, u += a.y;
    for (l = (l / o - e) * i, u = (u / o - t) * i, s = 0; s < o; ++s)
      a = n[s], a.x -= l, a.y -= u;
  }
  return r.initialize = function(s) {
    n = s;
  }, r.x = function(s) {
    return arguments.length ? (e = +s, r) : e;
  }, r.y = function(s) {
    return arguments.length ? (t = +s, r) : t;
  }, r.strength = function(s) {
    return arguments.length ? (i = +s, r) : i;
  }, r;
}
function TY(e) {
  const t = +this._x.call(null, e), n = +this._y.call(null, e);
  return aR(this.cover(t, n), t, n, e);
}
function aR(e, t, n, i) {
  if (isNaN(t) || isNaN(n))
    return e;
  var r, s = e._root, o = { data: i }, a = e._x0, l = e._y0, u = e._x1, c = e._y1, f, d, h, g, p, m, y, b;
  if (!s)
    return e._root = o, e;
  for (; s.length; )
    if ((p = t >= (f = (a + u) / 2)) ? a = f : u = f, (m = n >= (d = (l + c) / 2)) ? l = d : c = d, r = s, !(s = s[y = m << 1 | p]))
      return r[y] = o, e;
  if (h = +e._x.call(null, s.data), g = +e._y.call(null, s.data), t === h && n === g)
    return o.next = s, r ? r[y] = o : e._root = o, e;
  do
    r = r ? r[y] = new Array(4) : e._root = new Array(4), (p = t >= (f = (a + u) / 2)) ? a = f : u = f, (m = n >= (d = (l + c) / 2)) ? l = d : c = d;
  while ((y = m << 1 | p) === (b = (g >= d) << 1 | h >= f));
  return r[b] = s, r[y] = o, e;
}
function OY(e) {
  var t, n, i = e.length, r, s, o = new Array(i), a = new Array(i), l = 1 / 0, u = 1 / 0, c = -1 / 0, f = -1 / 0;
  for (n = 0; n < i; ++n)
    isNaN(r = +this._x.call(null, t = e[n])) || isNaN(s = +this._y.call(null, t)) || (o[n] = r, a[n] = s, r < l && (l = r), r > c && (c = r), s < u && (u = s), s > f && (f = s));
  if (l > c || u > f)
    return this;
  for (this.cover(l, u).cover(c, f), n = 0; n < i; ++n)
    aR(this, o[n], a[n], e[n]);
  return this;
}
function NY(e, t) {
  if (isNaN(e = +e) || isNaN(t = +t))
    return this;
  var n = this._x0, i = this._y0, r = this._x1, s = this._y1;
  if (isNaN(n))
    r = (n = Math.floor(e)) + 1, s = (i = Math.floor(t)) + 1;
  else {
    for (var o = r - n || 1, a = this._root, l, u; n > e || e >= r || i > t || t >= s; )
      switch (u = (t < i) << 1 | e < n, l = new Array(4), l[u] = a, a = l, o *= 2, u) {
        case 0:
          r = n + o, s = i + o;
          break;
        case 1:
          n = r - o, s = i + o;
          break;
        case 2:
          r = n + o, i = s - o;
          break;
        case 3:
          n = r - o, i = s - o;
          break;
      }
    this._root && this._root.length && (this._root = a);
  }
  return this._x0 = n, this._y0 = i, this._x1 = r, this._y1 = s, this;
}
function DY() {
  var e = [];
  return this.visit(function(t) {
    if (!t.length)
      do
        e.push(t.data);
      while (t = t.next);
  }), e;
}
function RY(e) {
  return arguments.length ? this.cover(+e[0][0], +e[0][1]).cover(+e[1][0], +e[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
}
function mn(e, t, n, i, r) {
  this.node = e, this.x0 = t, this.y0 = n, this.x1 = i, this.y1 = r;
}
function LY(e, t, n) {
  var i, r = this._x0, s = this._y0, o, a, l, u, c = this._x1, f = this._y1, d = [], h = this._root, g, p;
  for (h && d.push(new mn(h, r, s, c, f)), n == null ? n = 1 / 0 : (r = e - n, s = t - n, c = e + n, f = t + n, n *= n); g = d.pop(); )
    if (!(!(h = g.node) || (o = g.x0) > c || (a = g.y0) > f || (l = g.x1) < r || (u = g.y1) < s))
      if (h.length) {
        var m = (o + l) / 2, y = (a + u) / 2;
        d.push(
          new mn(h[3], m, y, l, u),
          new mn(h[2], o, y, m, u),
          new mn(h[1], m, a, l, y),
          new mn(h[0], o, a, m, y)
        ), (p = (t >= y) << 1 | e >= m) && (g = d[d.length - 1], d[d.length - 1] = d[d.length - 1 - p], d[d.length - 1 - p] = g);
      } else {
        var b = e - +this._x.call(null, h.data), v = t - +this._y.call(null, h.data), _ = b * b + v * v;
        if (_ < n) {
          var x = Math.sqrt(n = _);
          r = e - x, s = t - x, c = e + x, f = t + x, i = h.data;
        }
      }
  return i;
}
function PY(e) {
  if (isNaN(c = +this._x.call(null, e)) || isNaN(f = +this._y.call(null, e)))
    return this;
  var t, n = this._root, i, r, s, o = this._x0, a = this._y0, l = this._x1, u = this._y1, c, f, d, h, g, p, m, y;
  if (!n)
    return this;
  if (n.length)
    for (; ; ) {
      if ((g = c >= (d = (o + l) / 2)) ? o = d : l = d, (p = f >= (h = (a + u) / 2)) ? a = h : u = h, t = n, !(n = n[m = p << 1 | g]))
        return this;
      if (!n.length)
        break;
      (t[m + 1 & 3] || t[m + 2 & 3] || t[m + 3 & 3]) && (i = t, y = m);
    }
  for (; n.data !== e; )
    if (r = n, !(n = n.next))
      return this;
  return (s = n.next) && delete n.next, r ? (s ? r.next = s : delete r.next, this) : t ? (s ? t[m] = s : delete t[m], (n = t[0] || t[1] || t[2] || t[3]) && n === (t[3] || t[2] || t[1] || t[0]) && !n.length && (i ? i[y] = n : this._root = n), this) : (this._root = s, this);
}
function IY(e) {
  for (var t = 0, n = e.length; t < n; ++t)
    this.remove(e[t]);
  return this;
}
function zY() {
  return this._root;
}
function BY() {
  var e = 0;
  return this.visit(function(t) {
    if (!t.length)
      do
        ++e;
      while (t = t.next);
  }), e;
}
function jY(e) {
  var t = [], n, i = this._root, r, s, o, a, l;
  for (i && t.push(new mn(i, this._x0, this._y0, this._x1, this._y1)); n = t.pop(); )
    if (!e(i = n.node, s = n.x0, o = n.y0, a = n.x1, l = n.y1) && i.length) {
      var u = (s + a) / 2, c = (o + l) / 2;
      (r = i[3]) && t.push(new mn(r, u, c, a, l)), (r = i[2]) && t.push(new mn(r, s, c, u, l)), (r = i[1]) && t.push(new mn(r, u, o, a, c)), (r = i[0]) && t.push(new mn(r, s, o, u, c));
    }
  return this;
}
function UY(e) {
  var t = [], n = [], i;
  for (this._root && t.push(new mn(this._root, this._x0, this._y0, this._x1, this._y1)); i = t.pop(); ) {
    var r = i.node;
    if (r.length) {
      var s, o = i.x0, a = i.y0, l = i.x1, u = i.y1, c = (o + l) / 2, f = (a + u) / 2;
      (s = r[0]) && t.push(new mn(s, o, a, c, f)), (s = r[1]) && t.push(new mn(s, c, a, l, f)), (s = r[2]) && t.push(new mn(s, o, f, c, u)), (s = r[3]) && t.push(new mn(s, c, f, l, u));
    }
    n.push(i);
  }
  for (; i = n.pop(); )
    e(i.node, i.x0, i.y0, i.x1, i.y1);
  return this;
}
function qY(e) {
  return e[0];
}
function WY(e) {
  return arguments.length ? (this._x = e, this) : this._x;
}
function HY(e) {
  return e[1];
}
function GY(e) {
  return arguments.length ? (this._y = e, this) : this._y;
}
function Uw(e, t, n) {
  var i = new qw(t ?? qY, n ?? HY, NaN, NaN, NaN, NaN);
  return e == null ? i : i.addAll(e);
}
function qw(e, t, n, i, r, s) {
  this._x = e, this._y = t, this._x0 = n, this._y0 = i, this._x1 = r, this._y1 = s, this._root = void 0;
}
function fC(e) {
  for (var t = { data: e.data }, n = t; e = e.next; )
    n = n.next = { data: e.data };
  return t;
}
var Sn = Uw.prototype = qw.prototype;
Sn.copy = function() {
  var e = new qw(this._x, this._y, this._x0, this._y0, this._x1, this._y1), t = this._root, n, i;
  if (!t)
    return e;
  if (!t.length)
    return e._root = fC(t), e;
  for (n = [{ source: t, target: e._root = new Array(4) }]; t = n.pop(); )
    for (var r = 0; r < 4; ++r)
      (i = t.source[r]) && (i.length ? n.push({ source: i, target: t.target[r] = new Array(4) }) : t.target[r] = fC(i));
  return e;
};
Sn.add = TY;
Sn.addAll = OY;
Sn.cover = NY;
Sn.data = DY;
Sn.extent = RY;
Sn.find = LY;
Sn.remove = PY;
Sn.removeAll = IY;
Sn.root = zY;
Sn.size = BY;
Sn.visit = jY;
Sn.visitAfter = UY;
Sn.x = WY;
Sn.y = GY;
function yn(e) {
  return function() {
    return e;
  };
}
function no(e) {
  return (e() - 0.5) * 1e-6;
}
function VY(e) {
  return e.x + e.vx;
}
function YY(e) {
  return e.y + e.vy;
}
function XY(e) {
  var t, n, i, r = 1, s = 1;
  typeof e != "function" && (e = yn(e == null ? 1 : +e));
  function o() {
    for (var u, c = t.length, f, d, h, g, p, m, y = 0; y < s; ++y)
      for (f = Uw(t, VY, YY).visitAfter(a), u = 0; u < c; ++u)
        d = t[u], p = n[d.index], m = p * p, h = d.x + d.vx, g = d.y + d.vy, f.visit(b);
    function b(v, _, x, S, E) {
      var C = v.data, $ = v.r, N = p + $;
      if (C) {
        if (C.index > d.index) {
          var O = h - C.x - C.vx, P = g - C.y - C.vy, T = O * O + P * P;
          T < N * N && (O === 0 && (O = no(i), T += O * O), P === 0 && (P = no(i), T += P * P), T = (N - (T = Math.sqrt(T))) / T * r, d.vx += (O *= T) * (N = ($ *= $) / (m + $)), d.vy += (P *= T) * N, C.vx -= O * (N = 1 - N), C.vy -= P * N);
        }
        return;
      }
      return _ > h + N || S < h - N || x > g + N || E < g - N;
    }
  }
  function a(u) {
    if (u.data)
      return u.r = n[u.data.index];
    for (var c = u.r = 0; c < 4; ++c)
      u[c] && u[c].r > u.r && (u.r = u[c].r);
  }
  function l() {
    if (t) {
      var u, c = t.length, f;
      for (n = new Array(c), u = 0; u < c; ++u)
        f = t[u], n[f.index] = +e(f, u, t);
    }
  }
  return o.initialize = function(u, c) {
    t = u, i = c, l();
  }, o.iterations = function(u) {
    return arguments.length ? (s = +u, o) : s;
  }, o.strength = function(u) {
    return arguments.length ? (r = +u, o) : r;
  }, o.radius = function(u) {
    return arguments.length ? (e = typeof u == "function" ? u : yn(+u), l(), o) : e;
  }, o;
}
function KY(e) {
  return e.index;
}
function dC(e, t) {
  var n = e.get(t);
  if (!n)
    throw new Error("node not found: " + t);
  return n;
}
function JY(e) {
  var t = KY, n = f, i, r = yn(30), s, o, a, l, u, c = 1;
  e == null && (e = []);
  function f(m) {
    return 1 / Math.min(a[m.source.index], a[m.target.index]);
  }
  function d(m) {
    for (var y = 0, b = e.length; y < c; ++y)
      for (var v = 0, _, x, S, E, C, $, N; v < b; ++v)
        _ = e[v], x = _.source, S = _.target, E = S.x + S.vx - x.x - x.vx || no(u), C = S.y + S.vy - x.y - x.vy || no(u), $ = Math.sqrt(E * E + C * C), $ = ($ - s[v]) / $ * m * i[v], E *= $, C *= $, S.vx -= E * (N = l[v]), S.vy -= C * N, x.vx += E * (N = 1 - N), x.vy += C * N;
  }
  function h() {
    if (o) {
      var m, y = o.length, b = e.length, v = new Map(o.map((x, S) => [t(x, S, o), x])), _;
      for (m = 0, a = new Array(y); m < b; ++m)
        _ = e[m], _.index = m, typeof _.source != "object" && (_.source = dC(v, _.source)), typeof _.target != "object" && (_.target = dC(v, _.target)), a[_.source.index] = (a[_.source.index] || 0) + 1, a[_.target.index] = (a[_.target.index] || 0) + 1;
      for (m = 0, l = new Array(b); m < b; ++m)
        _ = e[m], l[m] = a[_.source.index] / (a[_.source.index] + a[_.target.index]);
      i = new Array(b), g(), s = new Array(b), p();
    }
  }
  function g() {
    if (o)
      for (var m = 0, y = e.length; m < y; ++m)
        i[m] = +n(e[m], m, e);
  }
  function p() {
    if (o)
      for (var m = 0, y = e.length; m < y; ++m)
        s[m] = +r(e[m], m, e);
  }
  return d.initialize = function(m, y) {
    o = m, u = y, h();
  }, d.links = function(m) {
    return arguments.length ? (e = m, h(), d) : e;
  }, d.id = function(m) {
    return arguments.length ? (t = m, d) : t;
  }, d.iterations = function(m) {
    return arguments.length ? (c = +m, d) : c;
  }, d.strength = function(m) {
    return arguments.length ? (n = typeof m == "function" ? m : yn(+m), g(), d) : n;
  }, d.distance = function(m) {
    return arguments.length ? (r = typeof m == "function" ? m : yn(+m), p(), d) : r;
  }, d;
}
var QY = { value: () => {
} };
function lR() {
  for (var e = 0, t = arguments.length, n = {}, i; e < t; ++e) {
    if (!(i = arguments[e] + "") || i in n || /[\s.]/.test(i))
      throw new Error("illegal type: " + i);
    n[i] = [];
  }
  return new Wh(n);
}
function Wh(e) {
  this._ = e;
}
function ZY(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var i = "", r = n.indexOf(".");
    if (r >= 0 && (i = n.slice(r + 1), n = n.slice(0, r)), n && !t.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    return { type: n, name: i };
  });
}
Wh.prototype = lR.prototype = {
  constructor: Wh,
  on: function(e, t) {
    var n = this._, i = ZY(e + "", n), r, s = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((r = (e = i[s]).type) && (r = eX(n[r], e.name)))
          return r;
      return;
    }
    if (t != null && typeof t != "function")
      throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (r = (e = i[s]).type)
        n[r] = hC(n[r], e.name, t);
      else if (t == null)
        for (r in n)
          n[r] = hC(n[r], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t)
      e[n] = t[n].slice();
    return new Wh(e);
  },
  call: function(e, t) {
    if ((r = arguments.length - 2) > 0)
      for (var n = new Array(r), i = 0, r, s; i < r; ++i)
        n[i] = arguments[i + 2];
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (s = this._[e], i = 0, r = s.length; i < r; ++i)
      s[i].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (var i = this._[e], r = 0, s = i.length; r < s; ++r)
      i[r].value.apply(t, n);
  }
};
function eX(e, t) {
  for (var n = 0, i = e.length, r; n < i; ++n)
    if ((r = e[n]).name === t)
      return r.value;
}
function hC(e, t, n) {
  for (var i = 0, r = e.length; i < r; ++i)
    if (e[i].name === t) {
      e[i] = QY, e = e.slice(0, i).concat(e.slice(i + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var mu = 0, Hc = 0, mc = 0, uR = 1e3, lp, Gc, up = 0, Ra = 0, Pm = 0, Lf = typeof performance == "object" && performance.now ? performance : Date, cR = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function Ww() {
  return Ra || (cR(tX), Ra = Lf.now() + Pm);
}
function tX() {
  Ra = 0;
}
function cp() {
  this._call = this._time = this._next = null;
}
cp.prototype = fR.prototype = {
  constructor: cp,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? Ww() : +n) + (t == null ? 0 : +t), !this._next && Gc !== this && (Gc ? Gc._next = this : lp = this, Gc = this), this._call = e, this._time = n, Ib();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Ib());
  }
};
function fR(e, t, n) {
  var i = new cp();
  return i.restart(e, t, n), i;
}
function nX() {
  Ww(), ++mu;
  for (var e = lp, t; e; )
    (t = Ra - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --mu;
}
function gC() {
  Ra = (up = Lf.now()) + Pm, mu = Hc = 0;
  try {
    nX();
  } finally {
    mu = 0, rX(), Ra = 0;
  }
}
function iX() {
  var e = Lf.now(), t = e - up;
  t > uR && (Pm -= t, up = e);
}
function rX() {
  for (var e, t = lp, n, i = 1 / 0; t; )
    t._call ? (i > t._time && (i = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : lp = n);
  Gc = e, Ib(i);
}
function Ib(e) {
  if (!mu) {
    Hc && (Hc = clearTimeout(Hc));
    var t = e - Ra;
    t > 24 ? (e < 1 / 0 && (Hc = setTimeout(gC, e - Lf.now() - Pm)), mc && (mc = clearInterval(mc))) : (mc || (up = Lf.now(), mc = setInterval(iX, uR)), mu = 1, cR(gC));
  }
}
function sX(e, t, n) {
  var i = new cp(), r = t;
  return t == null ? (i.restart(e, t, n), i) : (i._restart = i.restart, i.restart = function(s, o, a) {
    o = +o, a = a == null ? Ww() : +a, i._restart(function l(u) {
      u += r, i._restart(l, r += o, a), s(u);
    }, o, a);
  }, i.restart(e, t, n), i);
}
const oX = 1664525, aX = 1013904223, pC = 4294967296;
function lX() {
  let e = 1;
  return () => (e = (oX * e + aX) % pC) / pC;
}
function uX(e) {
  return e.x;
}
function cX(e) {
  return e.y;
}
var fX = 10, dX = Math.PI * (3 - Math.sqrt(5));
function hX(e) {
  var t, n = 1, i = 1e-3, r = 1 - Math.pow(i, 1 / 300), s = 0, o = 0.6, a = /* @__PURE__ */ new Map(), l = fR(f), u = lR("tick", "end"), c = lX();
  e == null && (e = []);
  function f() {
    d(), u.call("tick", t), n < i && (l.stop(), u.call("end", t));
  }
  function d(p) {
    var m, y = e.length, b;
    p === void 0 && (p = 1);
    for (var v = 0; v < p; ++v)
      for (n += (s - n) * r, a.forEach(function(_) {
        _(n);
      }), m = 0; m < y; ++m)
        b = e[m], b.fx == null ? b.x += b.vx *= o : (b.x = b.fx, b.vx = 0), b.fy == null ? b.y += b.vy *= o : (b.y = b.fy, b.vy = 0);
    return t;
  }
  function h() {
    for (var p = 0, m = e.length, y; p < m; ++p) {
      if (y = e[p], y.index = p, y.fx != null && (y.x = y.fx), y.fy != null && (y.y = y.fy), isNaN(y.x) || isNaN(y.y)) {
        var b = fX * Math.sqrt(0.5 + p), v = p * dX;
        y.x = b * Math.cos(v), y.y = b * Math.sin(v);
      }
      (isNaN(y.vx) || isNaN(y.vy)) && (y.vx = y.vy = 0);
    }
  }
  function g(p) {
    return p.initialize && p.initialize(e, c), p;
  }
  return h(), t = {
    tick: d,
    restart: function() {
      return l.restart(f), t;
    },
    stop: function() {
      return l.stop(), t;
    },
    nodes: function(p) {
      return arguments.length ? (e = p, h(), a.forEach(g), t) : e;
    },
    alpha: function(p) {
      return arguments.length ? (n = +p, t) : n;
    },
    alphaMin: function(p) {
      return arguments.length ? (i = +p, t) : i;
    },
    alphaDecay: function(p) {
      return arguments.length ? (r = +p, t) : +r;
    },
    alphaTarget: function(p) {
      return arguments.length ? (s = +p, t) : s;
    },
    velocityDecay: function(p) {
      return arguments.length ? (o = 1 - p, t) : 1 - o;
    },
    randomSource: function(p) {
      return arguments.length ? (c = p, a.forEach(g), t) : c;
    },
    force: function(p, m) {
      return arguments.length > 1 ? (m == null ? a.delete(p) : a.set(p, g(m)), t) : a.get(p);
    },
    find: function(p, m, y) {
      var b = 0, v = e.length, _, x, S, E, C;
      for (y == null ? y = 1 / 0 : y *= y, b = 0; b < v; ++b)
        E = e[b], _ = p - E.x, x = m - E.y, S = _ * _ + x * x, S < y && (C = E, y = S);
      return C;
    },
    on: function(p, m) {
      return arguments.length > 1 ? (u.on(p, m), t) : u.on(p);
    }
  };
}
function gX() {
  var e, t, n, i, r = yn(-30), s, o = 1, a = 1 / 0, l = 0.81;
  function u(h) {
    var g, p = e.length, m = Uw(e, uX, cX).visitAfter(f);
    for (i = h, g = 0; g < p; ++g)
      t = e[g], m.visit(d);
  }
  function c() {
    if (e) {
      var h, g = e.length, p;
      for (s = new Array(g), h = 0; h < g; ++h)
        p = e[h], s[p.index] = +r(p, h, e);
    }
  }
  function f(h) {
    var g = 0, p, m, y = 0, b, v, _;
    if (h.length) {
      for (b = v = _ = 0; _ < 4; ++_)
        (p = h[_]) && (m = Math.abs(p.value)) && (g += p.value, y += m, b += m * p.x, v += m * p.y);
      h.x = b / y, h.y = v / y;
    } else {
      p = h, p.x = p.data.x, p.y = p.data.y;
      do
        g += s[p.data.index];
      while (p = p.next);
    }
    h.value = g;
  }
  function d(h, g, p, m) {
    if (!h.value)
      return !0;
    var y = h.x - t.x, b = h.y - t.y, v = m - g, _ = y * y + b * b;
    if (v * v / l < _)
      return _ < a && (y === 0 && (y = no(n), _ += y * y), b === 0 && (b = no(n), _ += b * b), _ < o && (_ = Math.sqrt(o * _)), t.vx += y * h.value * i / _, t.vy += b * h.value * i / _), !0;
    if (h.length || _ >= a)
      return;
    (h.data !== t || h.next) && (y === 0 && (y = no(n), _ += y * y), b === 0 && (b = no(n), _ += b * b), _ < o && (_ = Math.sqrt(o * _)));
    do
      h.data !== t && (v = s[h.data.index] * i / _, t.vx += y * v, t.vy += b * v);
    while (h = h.next);
  }
  return u.initialize = function(h, g) {
    e = h, n = g, c();
  }, u.strength = function(h) {
    return arguments.length ? (r = typeof h == "function" ? h : yn(+h), c(), u) : r;
  }, u.distanceMin = function(h) {
    return arguments.length ? (o = h * h, u) : Math.sqrt(o);
  }, u.distanceMax = function(h) {
    return arguments.length ? (a = h * h, u) : Math.sqrt(a);
  }, u.theta = function(h) {
    return arguments.length ? (l = h * h, u) : Math.sqrt(l);
  }, u;
}
function pX(e) {
  var t = yn(0.1), n, i, r;
  typeof e != "function" && (e = yn(e == null ? 0 : +e));
  function s(a) {
    for (var l = 0, u = n.length, c; l < u; ++l)
      c = n[l], c.vx += (r[l] - c.x) * i[l] * a;
  }
  function o() {
    if (n) {
      var a, l = n.length;
      for (i = new Array(l), r = new Array(l), a = 0; a < l; ++a)
        i[a] = isNaN(r[a] = +e(n[a], a, n)) ? 0 : +t(n[a], a, n);
    }
  }
  return s.initialize = function(a) {
    n = a, o();
  }, s.strength = function(a) {
    return arguments.length ? (t = typeof a == "function" ? a : yn(+a), o(), s) : t;
  }, s.x = function(a) {
    return arguments.length ? (e = typeof a == "function" ? a : yn(+a), o(), s) : e;
  }, s;
}
function mX(e) {
  var t = yn(0.1), n, i, r;
  typeof e != "function" && (e = yn(e == null ? 0 : +e));
  function s(a) {
    for (var l = 0, u = n.length, c; l < u; ++l)
      c = n[l], c.vy += (r[l] - c.y) * i[l] * a;
  }
  function o() {
    if (n) {
      var a, l = n.length;
      for (i = new Array(l), r = new Array(l), a = 0; a < l; ++a)
        i[a] = isNaN(r[a] = +e(n[a], a, n)) ? 0 : +t(n[a], a, n);
    }
  }
  return s.initialize = function(a) {
    n = a, o();
  }, s.strength = function(a) {
    return arguments.length ? (t = typeof a == "function" ? a : yn(+a), o(), s) : t;
  }, s.y = function(a) {
    return arguments.length ? (e = typeof a == "function" ? a : yn(+a), o(), s) : e;
  }, s;
}
const mC = {
  center: FY,
  collide: XY,
  nbody: gX,
  link: JY,
  x: pX,
  y: mX
}, Vc = "forces", zb = ["alpha", "alphaMin", "alphaTarget", "velocityDecay", "forces"], yX = ["static", "iterations"], dR = ["x", "y", "vx", "vy"];
function Hw(e) {
  I.call(this, null, e);
}
Hw.Definition = {
  type: "Force",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "static",
    type: "boolean",
    default: !1
  }, {
    name: "restart",
    type: "boolean",
    default: !1
  }, {
    name: "iterations",
    type: "number",
    default: 300
  }, {
    name: "alpha",
    type: "number",
    default: 1
  }, {
    name: "alphaMin",
    type: "number",
    default: 1e-3
  }, {
    name: "alphaTarget",
    type: "number",
    default: 0
  }, {
    name: "velocityDecay",
    type: "number",
    default: 0.4
  }, {
    name: "forces",
    type: "param",
    array: !0,
    params: [{
      key: {
        force: "center"
      },
      params: [{
        name: "x",
        type: "number",
        default: 0
      }, {
        name: "y",
        type: "number",
        default: 0
      }]
    }, {
      key: {
        force: "collide"
      },
      params: [{
        name: "radius",
        type: "number",
        expr: !0
      }, {
        name: "strength",
        type: "number",
        default: 0.7
      }, {
        name: "iterations",
        type: "number",
        default: 1
      }]
    }, {
      key: {
        force: "nbody"
      },
      params: [{
        name: "strength",
        type: "number",
        default: -30,
        expr: !0
      }, {
        name: "theta",
        type: "number",
        default: 0.9
      }, {
        name: "distanceMin",
        type: "number",
        default: 1
      }, {
        name: "distanceMax",
        type: "number"
      }]
    }, {
      key: {
        force: "link"
      },
      params: [{
        name: "links",
        type: "data"
      }, {
        name: "id",
        type: "field"
      }, {
        name: "distance",
        type: "number",
        default: 30,
        expr: !0
      }, {
        name: "strength",
        type: "number",
        expr: !0
      }, {
        name: "iterations",
        type: "number",
        default: 1
      }]
    }, {
      key: {
        force: "x"
      },
      params: [{
        name: "strength",
        type: "number",
        default: 0.1
      }, {
        name: "x",
        type: "field"
      }]
    }, {
      key: {
        force: "y"
      },
      params: [{
        name: "strength",
        type: "number",
        default: 0.1
      }, {
        name: "y",
        type: "field"
      }]
    }]
  }, {
    name: "as",
    type: "string",
    array: !0,
    modify: !1,
    default: dR
  }]
};
Y(Hw, I, {
  transform(e, t) {
    var n = this.value, i = t.changed(t.ADD_REM), r = e.modified(zb), s = e.iterations || 300;
    if (n ? (i && (t.modifies("index"), n.nodes(t.source)), (r || t.changed(t.MOD)) && hR(n, e, 0, t)) : (this.value = n = vX(t.source, e), n.on("tick", bX(t.dataflow, this)), e.static || (i = !0, n.tick()), t.modifies("index")), r || i || e.modified(yX) || t.changed() && e.restart) {
      if (n.alpha(Math.max(n.alpha(), e.alpha || 1)).alphaDecay(1 - Math.pow(n.alphaMin(), 1 / s)), e.static)
        for (n.stop(); --s >= 0; )
          n.tick();
      else if (n.stopped() && n.restart(), !i)
        return t.StopPropagation;
    }
    return this.finish(e, t);
  },
  finish(e, t) {
    const n = t.dataflow;
    for (let a = this._argops, l = 0, u = a.length, c; l < u; ++l)
      if (c = a[l], !(c.name !== Vc || c.op._argval.force !== "link")) {
        for (var i = c.op._argops, r = 0, s = i.length, o; r < s; ++r)
          if (i[r].name === "links" && (o = i[r].op.source)) {
            n.pulse(o, n.changeset().reflow());
            break;
          }
      }
    return t.reflow(e.modified()).modifies(dR);
  }
});
function bX(e, t) {
  return () => e.touch(t).run();
}
function vX(e, t) {
  const n = hX(e), i = n.stop, r = n.restart;
  let s = !1;
  return n.stopped = () => s, n.restart = () => (s = !1, r()), n.stop = () => (s = !0, i()), hR(n, t, !0).on("end", () => s = !0);
}
function hR(e, t, n, i) {
  var r = ee(t.forces), s, o, a, l;
  for (s = 0, o = zb.length; s < o; ++s)
    a = zb[s], a !== Vc && t.modified(a) && e[a](t[a]);
  for (s = 0, o = r.length; s < o; ++s)
    l = Vc + s, a = n || t.modified(Vc, s) ? wX(r[s]) : i && xX(r[s], i) ? e.force(l) : null, a && e.force(l, a);
  for (o = e.numForces || 0; s < o; ++s)
    e.force(Vc + s, null);
  return e.numForces = r.length, e;
}
function xX(e, t) {
  var n, i;
  for (n in e)
    if (Ee(i = e[n]) && t.modified(nn(i)))
      return 1;
  return 0;
}
function wX(e) {
  var t, n;
  ce(mC, e.force) || j("Unrecognized force: " + e.force), t = mC[e.force]();
  for (n in e)
    Ee(t[n]) && _X(t[n], e[n], e);
  return t;
}
function _X(e, t, n) {
  e(Ee(t) ? (i) => t(i, n) : t);
}
const EX = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  force: Hw
}, Symbol.toStringTag, { value: "Module" }));
function SX(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function kX(e) {
  return e.reduce(AX, 0) / e.length;
}
function AX(e, t) {
  return e + t.x;
}
function CX(e) {
  return 1 + e.reduce($X, 0);
}
function $X(e, t) {
  return Math.max(e, t.y);
}
function MX(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function FX(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function TX() {
  var e = SX, t = 1, n = 1, i = !1;
  function r(s) {
    var o, a = 0;
    s.eachAfter(function(d) {
      var h = d.children;
      h ? (d.x = kX(h), d.y = CX(h)) : (d.x = o ? a += e(d, o) : 0, d.y = 0, o = d);
    });
    var l = MX(s), u = FX(s), c = l.x - e(l, u) / 2, f = u.x + e(u, l) / 2;
    return s.eachAfter(i ? function(d) {
      d.x = (d.x - s.x) * t, d.y = (s.y - d.y) * n;
    } : function(d) {
      d.x = (d.x - c) / (f - c) * t, d.y = (1 - (s.y ? d.y / s.y : 1)) * n;
    });
  }
  return r.separation = function(s) {
    return arguments.length ? (e = s, r) : e;
  }, r.size = function(s) {
    return arguments.length ? (i = !1, t = +s[0], n = +s[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(s) {
    return arguments.length ? (i = !0, t = +s[0], n = +s[1], r) : i ? [t, n] : null;
  }, r;
}
function OX(e) {
  var t = 0, n = e.children, i = n && n.length;
  if (!i)
    t = 1;
  else
    for (; --i >= 0; )
      t += n[i].value;
  e.value = t;
}
function NX() {
  return this.eachAfter(OX);
}
function DX(e, t) {
  let n = -1;
  for (const i of this)
    e.call(t, i, ++n, this);
  return this;
}
function RX(e, t) {
  for (var n = this, i = [n], r, s, o = -1; n = i.pop(); )
    if (e.call(t, n, ++o, this), r = n.children)
      for (s = r.length - 1; s >= 0; --s)
        i.push(r[s]);
  return this;
}
function LX(e, t) {
  for (var n = this, i = [n], r = [], s, o, a, l = -1; n = i.pop(); )
    if (r.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        i.push(s[o]);
  for (; n = r.pop(); )
    e.call(t, n, ++l, this);
  return this;
}
function PX(e, t) {
  let n = -1;
  for (const i of this)
    if (e.call(t, i, ++n, this))
      return i;
}
function IX(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
      n += i[r].value;
    t.value = n;
  });
}
function zX(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function BX(e) {
  for (var t = this, n = jX(t, e), i = [t]; t !== n; )
    t = t.parent, i.push(t);
  for (var r = i.length; e !== n; )
    i.splice(r, 0, e), e = e.parent;
  return i;
}
function jX(e, t) {
  if (e === t)
    return e;
  var n = e.ancestors(), i = t.ancestors(), r = null;
  for (e = n.pop(), t = i.pop(); e === t; )
    r = e, e = n.pop(), t = i.pop();
  return r;
}
function UX() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function qX() {
  return Array.from(this);
}
function WX() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function HX() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* GX() {
  var e = this, t, n = [e], i, r, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, i = e.children)
        for (r = 0, s = i.length; r < s; ++r)
          n.push(i[r]);
  while (n.length);
}
function Gw(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = XX)) : t === void 0 && (t = YX);
  for (var n = new yu(e), i, r = [n], s, o, a, l; i = r.pop(); )
    if ((o = t(i.data)) && (l = (o = Array.from(o)).length))
      for (i.children = o, a = l - 1; a >= 0; --a)
        r.push(s = o[a] = new yu(o[a])), s.parent = i, s.depth = i.depth + 1;
  return n.eachBefore(gR);
}
function VX() {
  return Gw(this).eachBefore(KX);
}
function YX(e) {
  return e.children;
}
function XX(e) {
  return Array.isArray(e) ? e[1] : null;
}
function KX(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function gR(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function yu(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
yu.prototype = Gw.prototype = {
  constructor: yu,
  count: NX,
  each: DX,
  eachAfter: LX,
  eachBefore: RX,
  find: PX,
  sum: IX,
  sort: zX,
  path: BX,
  ancestors: UX,
  descendants: qX,
  leaves: WX,
  links: HX,
  copy: VX,
  [Symbol.iterator]: GX
};
function Hh(e) {
  return e == null ? null : pR(e);
}
function pR(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
function ca() {
  return 0;
}
function Tl(e) {
  return function() {
    return e;
  };
}
const JX = 1664525, QX = 1013904223, yC = 4294967296;
function ZX() {
  let e = 1;
  return () => (e = (JX * e + QX) % yC) / yC;
}
function eK(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function tK(e, t) {
  let n = e.length, i, r;
  for (; n; )
    r = t() * n-- | 0, i = e[n], e[n] = e[r], e[r] = i;
  return e;
}
function nK(e, t) {
  for (var n = 0, i = (e = tK(Array.from(e), t)).length, r = [], s, o; n < i; )
    s = e[n], o && mR(o, s) ? ++n : (o = rK(r = iK(r, s)), n = 0);
  return o;
}
function iK(e, t) {
  var n, i;
  if (C1(t, e))
    return [t];
  for (n = 0; n < e.length; ++n)
    if (ch(t, e[n]) && C1(Yc(e[n], t), e))
      return [e[n], t];
  for (n = 0; n < e.length - 1; ++n)
    for (i = n + 1; i < e.length; ++i)
      if (ch(Yc(e[n], e[i]), t) && ch(Yc(e[n], t), e[i]) && ch(Yc(e[i], t), e[n]) && C1(yR(e[n], e[i], t), e))
        return [e[n], e[i], t];
  throw new Error();
}
function ch(e, t) {
  var n = e.r - t.r, i = t.x - e.x, r = t.y - e.y;
  return n < 0 || n * n < i * i + r * r;
}
function mR(e, t) {
  var n = e.r - t.r + Math.max(e.r, t.r, 1) * 1e-9, i = t.x - e.x, r = t.y - e.y;
  return n > 0 && n * n > i * i + r * r;
}
function C1(e, t) {
  for (var n = 0; n < t.length; ++n)
    if (!mR(e, t[n]))
      return !1;
  return !0;
}
function rK(e) {
  switch (e.length) {
    case 1:
      return sK(e[0]);
    case 2:
      return Yc(e[0], e[1]);
    case 3:
      return yR(e[0], e[1], e[2]);
  }
}
function sK(e) {
  return {
    x: e.x,
    y: e.y,
    r: e.r
  };
}
function Yc(e, t) {
  var n = e.x, i = e.y, r = e.r, s = t.x, o = t.y, a = t.r, l = s - n, u = o - i, c = a - r, f = Math.sqrt(l * l + u * u);
  return {
    x: (n + s + l / f * c) / 2,
    y: (i + o + u / f * c) / 2,
    r: (f + r + a) / 2
  };
}
function yR(e, t, n) {
  var i = e.x, r = e.y, s = e.r, o = t.x, a = t.y, l = t.r, u = n.x, c = n.y, f = n.r, d = i - o, h = i - u, g = r - a, p = r - c, m = l - s, y = f - s, b = i * i + r * r - s * s, v = b - o * o - a * a + l * l, _ = b - u * u - c * c + f * f, x = h * g - d * p, S = (g * _ - p * v) / (x * 2) - i, E = (p * m - g * y) / x, C = (h * v - d * _) / (x * 2) - r, $ = (d * y - h * m) / x, N = E * E + $ * $ - 1, O = 2 * (s + S * E + C * $), P = S * S + C * C - s * s, T = -(Math.abs(N) > 1e-6 ? (O + Math.sqrt(O * O - 4 * N * P)) / (2 * N) : P / O);
  return {
    x: i + S + E * T,
    y: r + C + $ * T,
    r: T
  };
}
function bC(e, t, n) {
  var i = e.x - t.x, r, s, o = e.y - t.y, a, l, u = i * i + o * o;
  u ? (s = t.r + n.r, s *= s, l = e.r + n.r, l *= l, s > l ? (r = (u + l - s) / (2 * u), a = Math.sqrt(Math.max(0, l / u - r * r)), n.x = e.x - r * i - a * o, n.y = e.y - r * o + a * i) : (r = (u + s - l) / (2 * u), a = Math.sqrt(Math.max(0, s / u - r * r)), n.x = t.x + r * i - a * o, n.y = t.y + r * o + a * i)) : (n.x = t.x + n.r, n.y = t.y);
}
function vC(e, t) {
  var n = e.r + t.r - 1e-6, i = t.x - e.x, r = t.y - e.y;
  return n > 0 && n * n > i * i + r * r;
}
function xC(e) {
  var t = e._, n = e.next._, i = t.r + n.r, r = (t.x * n.r + n.x * t.r) / i, s = (t.y * n.r + n.y * t.r) / i;
  return r * r + s * s;
}
function fh(e) {
  this._ = e, this.next = null, this.previous = null;
}
function oK(e, t) {
  if (!(s = (e = eK(e)).length))
    return 0;
  var n, i, r, s, o, a, l, u, c, f, d;
  if (n = e[0], n.x = 0, n.y = 0, !(s > 1))
    return n.r;
  if (i = e[1], n.x = -i.r, i.x = n.r, i.y = 0, !(s > 2))
    return n.r + i.r;
  bC(i, n, r = e[2]), n = new fh(n), i = new fh(i), r = new fh(r), n.next = r.previous = i, i.next = n.previous = r, r.next = i.previous = n;
  e:
    for (l = 3; l < s; ++l) {
      bC(n._, i._, r = e[l]), r = new fh(r), u = i.next, c = n.previous, f = i._.r, d = n._.r;
      do
        if (f <= d) {
          if (vC(u._, r._)) {
            i = u, n.next = i, i.previous = n, --l;
            continue e;
          }
          f += u._.r, u = u.next;
        } else {
          if (vC(c._, r._)) {
            n = c, n.next = i, i.previous = n, --l;
            continue e;
          }
          d += c._.r, c = c.previous;
        }
      while (u !== c.next);
      for (r.previous = n, r.next = i, n.next = i.previous = i = r, o = xC(n); (r = r.next) !== i; )
        (a = xC(r)) < o && (n = r, o = a);
      i = n.next;
    }
  for (n = [i._], r = i; (r = r.next) !== i; )
    n.push(r._);
  for (r = nK(n, t), l = 0; l < s; ++l)
    n = e[l], n.x -= r.x, n.y -= r.y;
  return r.r;
}
function aK(e) {
  return Math.sqrt(e.value);
}
function lK() {
  var e = null, t = 1, n = 1, i = ca;
  function r(s) {
    const o = ZX();
    return s.x = t / 2, s.y = n / 2, e ? s.eachBefore(wC(e)).eachAfter($1(i, 0.5, o)).eachBefore(_C(1)) : s.eachBefore(wC(aK)).eachAfter($1(ca, 1, o)).eachAfter($1(i, s.r / Math.min(t, n), o)).eachBefore(_C(Math.min(t, n) / (2 * s.r))), s;
  }
  return r.radius = function(s) {
    return arguments.length ? (e = Hh(s), r) : e;
  }, r.size = function(s) {
    return arguments.length ? (t = +s[0], n = +s[1], r) : [t, n];
  }, r.padding = function(s) {
    return arguments.length ? (i = typeof s == "function" ? s : Tl(+s), r) : i;
  }, r;
}
function wC(e) {
  return function(t) {
    t.children || (t.r = Math.max(0, +e(t) || 0));
  };
}
function $1(e, t, n) {
  return function(i) {
    if (r = i.children) {
      var r, s, o = r.length, a = e(i) * t || 0, l;
      if (a)
        for (s = 0; s < o; ++s)
          r[s].r += a;
      if (l = oK(r, n), a)
        for (s = 0; s < o; ++s)
          r[s].r -= a;
      i.r = l + a;
    }
  };
}
function _C(e) {
  return function(t) {
    var n = t.parent;
    t.r *= e, n && (t.x = n.x + e * t.x, t.y = n.y + e * t.y);
  };
}
function bR(e) {
  e.x0 = Math.round(e.x0), e.y0 = Math.round(e.y0), e.x1 = Math.round(e.x1), e.y1 = Math.round(e.y1);
}
function wd(e, t, n, i, r) {
  for (var s = e.children, o, a = -1, l = s.length, u = e.value && (i - t) / e.value; ++a < l; )
    o = s[a], o.y0 = n, o.y1 = r, o.x0 = t, o.x1 = t += o.value * u;
}
function uK() {
  var e = 1, t = 1, n = 0, i = !1;
  function r(o) {
    var a = o.height + 1;
    return o.x0 = o.y0 = n, o.x1 = e, o.y1 = t / a, o.eachBefore(s(t, a)), i && o.eachBefore(bR), o;
  }
  function s(o, a) {
    return function(l) {
      l.children && wd(l, l.x0, o * (l.depth + 1) / a, l.x1, o * (l.depth + 2) / a);
      var u = l.x0, c = l.y0, f = l.x1 - n, d = l.y1 - n;
      f < u && (u = f = (u + f) / 2), d < c && (c = d = (c + d) / 2), l.x0 = u, l.y0 = c, l.x1 = f, l.y1 = d;
    };
  }
  return r.round = function(o) {
    return arguments.length ? (i = !!o, r) : i;
  }, r.size = function(o) {
    return arguments.length ? (e = +o[0], t = +o[1], r) : [e, t];
  }, r.padding = function(o) {
    return arguments.length ? (n = +o, r) : n;
  }, r;
}
var cK = { depth: -1 }, EC = {}, M1 = {};
function fK(e) {
  return e.id;
}
function dK(e) {
  return e.parentId;
}
function SC() {
  var e = fK, t = dK, n;
  function i(r) {
    var s = Array.from(r), o = e, a = t, l, u, c, f, d, h, g, p, m = /* @__PURE__ */ new Map();
    if (n != null) {
      const y = s.map((_, x) => hK(n(_, x, r))), b = y.map(kC), v = new Set(y).add("");
      for (const _ of b)
        v.has(_) || (v.add(_), y.push(_), b.push(kC(_)), s.push(M1));
      o = (_, x) => y[x], a = (_, x) => b[x];
    }
    for (c = 0, l = s.length; c < l; ++c)
      u = s[c], h = s[c] = new yu(u), (g = o(u, c, r)) != null && (g += "") && (p = h.id = g, m.set(p, m.has(p) ? EC : h)), (g = a(u, c, r)) != null && (g += "") && (h.parent = g);
    for (c = 0; c < l; ++c)
      if (h = s[c], g = h.parent) {
        if (d = m.get(g), !d)
          throw new Error("missing: " + g);
        if (d === EC)
          throw new Error("ambiguous: " + g);
        d.children ? d.children.push(h) : d.children = [h], h.parent = d;
      } else {
        if (f)
          throw new Error("multiple roots");
        f = h;
      }
    if (!f)
      throw new Error("no root");
    if (n != null) {
      for (; f.data === M1 && f.children.length === 1; )
        f = f.children[0], --l;
      for (let y = s.length - 1; y >= 0 && (h = s[y], h.data === M1); --y)
        h.data = null;
    }
    if (f.parent = cK, f.eachBefore(function(y) {
      y.depth = y.parent.depth + 1, --l;
    }).eachBefore(gR), f.parent = null, l > 0)
      throw new Error("cycle");
    return f;
  }
  return i.id = function(r) {
    return arguments.length ? (e = Hh(r), i) : e;
  }, i.parentId = function(r) {
    return arguments.length ? (t = Hh(r), i) : t;
  }, i.path = function(r) {
    return arguments.length ? (n = Hh(r), i) : n;
  }, i;
}
function hK(e) {
  e = `${e}`;
  let t = e.length;
  return Bb(e, t - 1) && !Bb(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function kC(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !Bb(e, t); )
    ;
  return e.slice(0, t);
}
function Bb(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function gK(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function F1(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function T1(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function pK(e, t, n) {
  var i = n / (t.i - e.i);
  t.c -= i, t.s += n, e.c += i, t.z += n, t.m += n;
}
function mK(e) {
  for (var t = 0, n = 0, i = e.children, r = i.length, s; --r >= 0; )
    s = i[r], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function yK(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function Gh(e, t) {
  this._ = e, this.parent = null, this.children = null, this.A = null, this.a = this, this.z = 0, this.m = 0, this.c = 0, this.s = 0, this.t = null, this.i = t;
}
Gh.prototype = Object.create(yu.prototype);
function bK(e) {
  for (var t = new Gh(e, 0), n, i = [t], r, s, o, a; n = i.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        i.push(r = n.children[o] = new Gh(s[o], o)), r.parent = n;
  return (t.parent = new Gh(null, 0)).children = [t], t;
}
function vK() {
  var e = gK, t = 1, n = 1, i = null;
  function r(u) {
    var c = bK(u);
    if (c.eachAfter(s), c.parent.m = -c.z, c.eachBefore(o), i)
      u.eachBefore(l);
    else {
      var f = u, d = u, h = u;
      u.eachBefore(function(b) {
        b.x < f.x && (f = b), b.x > d.x && (d = b), b.depth > h.depth && (h = b);
      });
      var g = f === d ? 1 : e(f, d) / 2, p = g - f.x, m = t / (d.x + g + p), y = n / (h.depth || 1);
      u.eachBefore(function(b) {
        b.x = (b.x + p) * m, b.y = b.depth * y;
      });
    }
    return u;
  }
  function s(u) {
    var c = u.children, f = u.parent.children, d = u.i ? f[u.i - 1] : null;
    if (c) {
      mK(u);
      var h = (c[0].z + c[c.length - 1].z) / 2;
      d ? (u.z = d.z + e(u._, d._), u.m = u.z - h) : u.z = h;
    } else
      d && (u.z = d.z + e(u._, d._));
    u.parent.A = a(u, d, u.parent.A || f[0]);
  }
  function o(u) {
    u._.x = u.z + u.parent.m, u.m += u.parent.m;
  }
  function a(u, c, f) {
    if (c) {
      for (var d = u, h = u, g = c, p = d.parent.children[0], m = d.m, y = h.m, b = g.m, v = p.m, _; g = T1(g), d = F1(d), g && d; )
        p = F1(p), h = T1(h), h.a = u, _ = g.z + b - d.z - m + e(g._, d._), _ > 0 && (pK(yK(g, u, f), u, _), m += _, y += _), b += g.m, m += d.m, v += p.m, y += h.m;
      g && !T1(h) && (h.t = g, h.m += b - y), d && !F1(p) && (p.t = d, p.m += m - v, f = u);
    }
    return f;
  }
  function l(u) {
    u.x *= t, u.y = u.depth * n;
  }
  return r.separation = function(u) {
    return arguments.length ? (e = u, r) : e;
  }, r.size = function(u) {
    return arguments.length ? (i = !1, t = +u[0], n = +u[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(u) {
    return arguments.length ? (i = !0, t = +u[0], n = +u[1], r) : i ? [t, n] : null;
  }, r;
}
function Im(e, t, n, i, r) {
  for (var s = e.children, o, a = -1, l = s.length, u = e.value && (r - n) / e.value; ++a < l; )
    o = s[a], o.x0 = t, o.x1 = i, o.y0 = n, o.y1 = n += o.value * u;
}
var vR = (1 + Math.sqrt(5)) / 2;
function xR(e, t, n, i, r, s) {
  for (var o = [], a = t.children, l, u, c = 0, f = 0, d = a.length, h, g, p = t.value, m, y, b, v, _, x, S; c < d; ) {
    h = r - n, g = s - i;
    do
      m = a[f++].value;
    while (!m && f < d);
    for (y = b = m, x = Math.max(g / h, h / g) / (p * e), S = m * m * x, _ = Math.max(b / S, S / y); f < d; ++f) {
      if (m += u = a[f].value, u < y && (y = u), u > b && (b = u), S = m * m * x, v = Math.max(b / S, S / y), v > _) {
        m -= u;
        break;
      }
      _ = v;
    }
    o.push(l = { value: m, dice: h < g, children: a.slice(c, f) }), l.dice ? wd(l, n, i, r, p ? i += g * m / p : s) : Im(l, n, i, p ? n += h * m / p : r, s), p -= m, c = f;
  }
  return o;
}
const wR = function e(t) {
  function n(i, r, s, o, a) {
    xR(t, i, r, s, o, a);
  }
  return n.ratio = function(i) {
    return e((i = +i) > 1 ? i : 1);
  }, n;
}(vR);
function xK() {
  var e = wR, t = !1, n = 1, i = 1, r = [0], s = ca, o = ca, a = ca, l = ca, u = ca;
  function c(d) {
    return d.x0 = d.y0 = 0, d.x1 = n, d.y1 = i, d.eachBefore(f), r = [0], t && d.eachBefore(bR), d;
  }
  function f(d) {
    var h = r[d.depth], g = d.x0 + h, p = d.y0 + h, m = d.x1 - h, y = d.y1 - h;
    m < g && (g = m = (g + m) / 2), y < p && (p = y = (p + y) / 2), d.x0 = g, d.y0 = p, d.x1 = m, d.y1 = y, d.children && (h = r[d.depth + 1] = s(d) / 2, g += u(d) - h, p += o(d) - h, m -= a(d) - h, y -= l(d) - h, m < g && (g = m = (g + m) / 2), y < p && (p = y = (p + y) / 2), e(d, g, p, m, y));
  }
  return c.round = function(d) {
    return arguments.length ? (t = !!d, c) : t;
  }, c.size = function(d) {
    return arguments.length ? (n = +d[0], i = +d[1], c) : [n, i];
  }, c.tile = function(d) {
    return arguments.length ? (e = pR(d), c) : e;
  }, c.padding = function(d) {
    return arguments.length ? c.paddingInner(d).paddingOuter(d) : c.paddingInner();
  }, c.paddingInner = function(d) {
    return arguments.length ? (s = typeof d == "function" ? d : Tl(+d), c) : s;
  }, c.paddingOuter = function(d) {
    return arguments.length ? c.paddingTop(d).paddingRight(d).paddingBottom(d).paddingLeft(d) : c.paddingTop();
  }, c.paddingTop = function(d) {
    return arguments.length ? (o = typeof d == "function" ? d : Tl(+d), c) : o;
  }, c.paddingRight = function(d) {
    return arguments.length ? (a = typeof d == "function" ? d : Tl(+d), c) : a;
  }, c.paddingBottom = function(d) {
    return arguments.length ? (l = typeof d == "function" ? d : Tl(+d), c) : l;
  }, c.paddingLeft = function(d) {
    return arguments.length ? (u = typeof d == "function" ? d : Tl(+d), c) : u;
  }, c;
}
function wK(e, t, n, i, r) {
  var s = e.children, o, a = s.length, l, u = new Array(a + 1);
  for (u[0] = l = o = 0; o < a; ++o)
    u[o + 1] = l += s[o].value;
  c(0, a, e.value, t, n, i, r);
  function c(f, d, h, g, p, m, y) {
    if (f >= d - 1) {
      var b = s[f];
      b.x0 = g, b.y0 = p, b.x1 = m, b.y1 = y;
      return;
    }
    for (var v = u[f], _ = h / 2 + v, x = f + 1, S = d - 1; x < S; ) {
      var E = x + S >>> 1;
      u[E] < _ ? x = E + 1 : S = E;
    }
    _ - u[x - 1] < u[x] - _ && f + 1 < x && --x;
    var C = u[x] - v, $ = h - C;
    if (m - g > y - p) {
      var N = h ? (g * $ + m * C) / h : m;
      c(f, x, C, g, p, N, y), c(x, d, $, N, p, m, y);
    } else {
      var O = h ? (p * $ + y * C) / h : y;
      c(f, x, C, g, p, m, O), c(x, d, $, g, O, m, y);
    }
  }
}
function _K(e, t, n, i, r) {
  (e.depth & 1 ? Im : wd)(e, t, n, i, r);
}
const EK = function e(t) {
  function n(i, r, s, o, a) {
    if ((l = i._squarify) && l.ratio === t)
      for (var l, u, c, f, d = -1, h, g = l.length, p = i.value; ++d < g; ) {
        for (u = l[d], c = u.children, f = u.value = 0, h = c.length; f < h; ++f)
          u.value += c[f].value;
        u.dice ? wd(u, r, s, o, p ? s += (a - s) * u.value / p : a) : Im(u, r, s, p ? r += (o - r) * u.value / p : o, a), p -= u.value;
      }
    else
      i._squarify = l = xR(t, i, r, s, o, a), l.ratio = t;
  }
  return n.ratio = function(i) {
    return e((i = +i) > 1 ? i : 1);
  }, n;
}(vR);
function jb(e, t, n) {
  const i = {};
  return e.each((r) => {
    const s = r.data;
    n(s) && (i[t(s)] = r);
  }), e.lookup = i, e;
}
function Vw(e) {
  I.call(this, null, e);
}
Vw.Definition = {
  type: "Nest",
  metadata: {
    treesource: !0,
    changes: !0
  },
  params: [{
    name: "keys",
    type: "field",
    array: !0
  }, {
    name: "generate",
    type: "boolean"
  }]
};
const SK = (e) => e.values;
Y(Vw, I, {
  transform(e, t) {
    t.source || j("Nest transform requires an upstream data source.");
    var n = e.generate, i = e.modified(), r = t.clone(), s = this.value;
    return (!s || i || t.changed()) && (s && s.each((o) => {
      o.children && Jp(o.data) && r.rem.push(o.data);
    }), this.value = s = Gw({
      values: ee(e.keys).reduce((o, a) => (o.key(a), o), kK()).entries(r.source)
    }, SK), n && s.each((o) => {
      o.children && (o = je(o.data), r.add.push(o), r.source.push(o));
    }), jb(s, le, le)), r.source.root = s, r;
  }
});
function kK() {
  const e = [], t = {
    entries: (r) => i(n(r, 0), 0),
    key: (r) => (e.push(r), t)
  };
  function n(r, s) {
    if (s >= e.length)
      return r;
    const o = r.length, a = e[s++], l = {}, u = {};
    let c = -1, f, d, h;
    for (; ++c < o; )
      f = a(d = r[c]) + "", (h = l[f]) ? h.push(d) : l[f] = [d];
    for (f in l)
      u[f] = n(l[f], s);
    return u;
  }
  function i(r, s) {
    if (++s > e.length)
      return r;
    const o = [];
    for (const a in r)
      o.push({
        key: a,
        values: i(r[a], s)
      });
    return o;
  }
  return t;
}
function Ts(e) {
  I.call(this, null, e);
}
const AK = (e, t) => e.parent === t.parent ? 1 : 2;
Y(Ts, I, {
  transform(e, t) {
    (!t.source || !t.source.root) && j(this.constructor.name + " transform requires a backing tree data source.");
    const n = this.layout(e.method), i = this.fields, r = t.source.root, s = e.as || i;
    e.field ? r.sum(e.field) : r.count(), e.sort && r.sort(el(e.sort, (o) => o.data)), CK(n, this.params, e), n.separation && n.separation(e.separation !== !1 ? AK : Nu);
    try {
      this.value = n(r);
    } catch (o) {
      j(o);
    }
    return r.each((o) => $K(o, i, s)), t.reflow(e.modified()).modifies(s).modifies("leaf");
  }
});
function CK(e, t, n) {
  for (let i, r = 0, s = t.length; r < s; ++r)
    i = t[r], i in n && e[i](n[i]);
}
function $K(e, t, n) {
  const i = e.data, r = t.length - 1;
  for (let s = 0; s < r; ++s)
    i[n[s]] = e[t[s]];
  i[n[r]] = e.children ? e.children.length : 0;
}
const Ub = ["x", "y", "r", "depth", "children"];
function Yw(e) {
  Ts.call(this, e);
}
Yw.Definition = {
  type: "Pack",
  metadata: {
    tree: !0,
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "padding",
    type: "number",
    default: 0
  }, {
    name: "radius",
    type: "field",
    default: null
  }, {
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: Ub.length,
    default: Ub
  }]
};
Y(Yw, Ts, {
  layout: lK,
  params: ["radius", "size", "padding"],
  fields: Ub
});
const qb = ["x0", "y0", "x1", "y1", "depth", "children"];
function Xw(e) {
  Ts.call(this, e);
}
Xw.Definition = {
  type: "Partition",
  metadata: {
    tree: !0,
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "padding",
    type: "number",
    default: 0
  }, {
    name: "round",
    type: "boolean",
    default: !1
  }, {
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: qb.length,
    default: qb
  }]
};
Y(Xw, Ts, {
  layout: uK,
  params: ["size", "round", "padding"],
  fields: qb
});
function Kw(e) {
  I.call(this, null, e);
}
Kw.Definition = {
  type: "Stratify",
  metadata: {
    treesource: !0
  },
  params: [{
    name: "key",
    type: "field",
    required: !0
  }, {
    name: "parentKey",
    type: "field",
    required: !0
  }]
};
Y(Kw, I, {
  transform(e, t) {
    t.source || j("Stratify transform requires an upstream data source.");
    let n = this.value;
    const i = e.modified(), r = t.fork(t.ALL).materialize(t.SOURCE), s = !n || i || t.changed(t.ADD_REM) || t.modified(e.key.fields) || t.modified(e.parentKey.fields);
    return r.source = r.source.slice(), s && (n = r.source.length ? jb(SC().id(e.key).parentId(e.parentKey)(r.source), e.key, Ei) : jb(SC()([{}]), e.key, e.key)), r.source.root = this.value = n, r;
  }
});
const AC = {
  tidy: vK,
  cluster: TX
}, Wb = ["x", "y", "depth", "children"];
function Jw(e) {
  Ts.call(this, e);
}
Jw.Definition = {
  type: "Tree",
  metadata: {
    tree: !0,
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "method",
    type: "enum",
    default: "tidy",
    values: ["tidy", "cluster"]
  }, {
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "nodeSize",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "separation",
    type: "boolean",
    default: !0
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: Wb.length,
    default: Wb
  }]
};
Y(Jw, Ts, {
  /**
   * Tree layout generator. Supports both 'tidy' and 'cluster' layouts.
   */
  layout(e) {
    const t = e || "tidy";
    if (ce(AC, t))
      return AC[t]();
    j("Unrecognized Tree layout method: " + t);
  },
  params: ["size", "nodeSize"],
  fields: Wb
});
function Qw(e) {
  I.call(this, [], e);
}
Qw.Definition = {
  type: "TreeLinks",
  metadata: {
    tree: !0,
    generates: !0,
    changes: !0
  },
  params: []
};
Y(Qw, I, {
  transform(e, t) {
    const n = this.value, i = t.source && t.source.root, r = t.fork(t.NO_SOURCE), s = {};
    return i || j("TreeLinks transform requires a tree data source."), t.changed(t.ADD_REM) ? (r.rem = n, t.visit(t.SOURCE, (o) => s[le(o)] = 1), i.each((o) => {
      const a = o.data, l = o.parent && o.parent.data;
      l && s[le(a)] && s[le(l)] && r.add.push(je({
        source: l,
        target: a
      }));
    }), this.value = r.add) : t.changed(t.MOD) && (t.visit(t.MOD, (o) => s[le(o)] = 1), n.forEach((o) => {
      (s[le(o.source)] || s[le(o.target)]) && r.mod.push(o);
    })), r;
  }
});
const CC = {
  binary: wK,
  dice: wd,
  slice: Im,
  slicedice: _K,
  squarify: wR,
  resquarify: EK
}, Hb = ["x0", "y0", "x1", "y1", "depth", "children"];
function Zw(e) {
  Ts.call(this, e);
}
Zw.Definition = {
  type: "Treemap",
  metadata: {
    tree: !0,
    modifies: !0
  },
  params: [{
    name: "field",
    type: "field"
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "method",
    type: "enum",
    default: "squarify",
    values: ["squarify", "resquarify", "binary", "dice", "slice", "slicedice"]
  }, {
    name: "padding",
    type: "number",
    default: 0
  }, {
    name: "paddingInner",
    type: "number",
    default: 0
  }, {
    name: "paddingOuter",
    type: "number",
    default: 0
  }, {
    name: "paddingTop",
    type: "number",
    default: 0
  }, {
    name: "paddingRight",
    type: "number",
    default: 0
  }, {
    name: "paddingBottom",
    type: "number",
    default: 0
  }, {
    name: "paddingLeft",
    type: "number",
    default: 0
  }, {
    name: "ratio",
    type: "number",
    default: 1.618033988749895
  }, {
    name: "round",
    type: "boolean",
    default: !1
  }, {
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: Hb.length,
    default: Hb
  }]
};
Y(Zw, Ts, {
  /**
   * Treemap layout generator. Adds 'method' and 'ratio' parameters
   * to configure the underlying tile method.
   */
  layout() {
    const e = xK();
    return e.ratio = (t) => {
      const n = e.tile();
      n.ratio && e.tile(n.ratio(t));
    }, e.method = (t) => {
      ce(CC, t) ? e.tile(CC[t]) : j("Unrecognized Treemap layout method: " + t);
    }, e;
  },
  params: ["method", "ratio", "size", "round", "padding", "paddingInner", "paddingOuter", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft"],
  fields: Hb
});
const MK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  nest: Vw,
  pack: Yw,
  partition: Xw,
  stratify: Kw,
  tree: Jw,
  treelinks: Qw,
  treemap: Zw
}, Symbol.toStringTag, { value: "Module" })), O1 = 4278190080;
function FK(e, t) {
  const n = e.bitmap();
  return (t || []).forEach((i) => n.set(e(i.boundary[0]), e(i.boundary[3]))), [n, void 0];
}
function TK(e, t, n, i, r) {
  const s = e.width, o = e.height, a = i || r, l = lo(s, o).getContext("2d"), u = lo(s, o).getContext("2d"), c = a && lo(s, o).getContext("2d");
  n.forEach((C) => Vh(l, C, !1)), Vh(u, t, !1), a && Vh(c, t, !0);
  const f = N1(l, s, o), d = N1(u, s, o), h = a && N1(c, s, o), g = e.bitmap(), p = a && e.bitmap();
  let m, y, b, v, _, x, S, E;
  for (y = 0; y < o; ++y)
    for (m = 0; m < s; ++m)
      _ = y * s + m, x = f[_] & O1, E = d[_] & O1, S = a && h[_] & O1, (x || S || E) && (b = e(m), v = e(y), !r && (x || E) && g.set(b, v), a && (x || S) && p.set(b, v));
  return [g, p];
}
function N1(e, t, n) {
  return new Uint32Array(e.getImageData(0, 0, t, n).data.buffer);
}
function Vh(e, t, n) {
  if (!t.length)
    return;
  const i = t[0].mark.marktype;
  i === "group" ? t.forEach((r) => {
    r.items.forEach((s) => Vh(e, s.items, n));
  }) : oi[i].draw(e, {
    items: n ? t.map(OK) : t
  });
}
function OK(e) {
  const t = Qp(e, {});
  return t.stroke && t.strokeOpacity !== 0 || t.fill && t.fillOpacity !== 0 ? {
    ...t,
    strokeOpacity: 1,
    stroke: "#000",
    fillOpacity: 0
  } : t;
}
const Qr = 5, un = 31, Pf = 32, Vs = new Uint32Array(Pf + 1), Bi = new Uint32Array(Pf + 1);
Bi[0] = 0;
Vs[0] = ~Bi[0];
for (let e = 1; e <= Pf; ++e)
  Bi[e] = Bi[e - 1] << 1 | 1, Vs[e] = ~Bi[e];
function NK(e, t) {
  const n = new Uint32Array(~~((e * t + Pf) / Pf));
  function i(s, o) {
    n[s] |= o;
  }
  function r(s, o) {
    n[s] &= o;
  }
  return {
    array: n,
    get: (s, o) => {
      const a = o * e + s;
      return n[a >>> Qr] & 1 << (a & un);
    },
    set: (s, o) => {
      const a = o * e + s;
      i(a >>> Qr, 1 << (a & un));
    },
    clear: (s, o) => {
      const a = o * e + s;
      r(a >>> Qr, ~(1 << (a & un)));
    },
    getRange: (s, o, a, l) => {
      let u = l, c, f, d, h;
      for (; u >= o; --u)
        if (c = u * e + s, f = u * e + a, d = c >>> Qr, h = f >>> Qr, d === h) {
          if (n[d] & Vs[c & un] & Bi[(f & un) + 1])
            return !0;
        } else {
          if (n[d] & Vs[c & un] || n[h] & Bi[(f & un) + 1])
            return !0;
          for (let g = d + 1; g < h; ++g)
            if (n[g])
              return !0;
        }
      return !1;
    },
    setRange: (s, o, a, l) => {
      let u, c, f, d, h;
      for (; o <= l; ++o)
        if (u = o * e + s, c = o * e + a, f = u >>> Qr, d = c >>> Qr, f === d)
          i(f, Vs[u & un] & Bi[(c & un) + 1]);
        else
          for (i(f, Vs[u & un]), i(d, Bi[(c & un) + 1]), h = f + 1; h < d; ++h)
            i(h, 4294967295);
    },
    clearRange: (s, o, a, l) => {
      let u, c, f, d, h;
      for (; o <= l; ++o)
        if (u = o * e + s, c = o * e + a, f = u >>> Qr, d = c >>> Qr, f === d)
          r(f, Bi[u & un] | Vs[(c & un) + 1]);
        else
          for (r(f, Bi[u & un]), r(d, Vs[(c & un) + 1]), h = f + 1; h < d; ++h)
            r(h, 0);
    },
    outOfBounds: (s, o, a, l) => s < 0 || o < 0 || l >= t || a >= e
  };
}
function DK(e, t, n) {
  const i = Math.max(1, Math.sqrt(e * t / 1e6)), r = ~~((e + 2 * n + i) / i), s = ~~((t + 2 * n + i) / i), o = (a) => ~~((a + n) / i);
  return o.invert = (a) => a * i - n, o.bitmap = () => NK(r, s), o.ratio = i, o.padding = n, o.width = e, o.height = t, o;
}
function RK(e, t, n, i) {
  const r = e.width, s = e.height;
  return function(o) {
    const a = o.datum.datum.items[i].items, l = a.length, u = o.datum.fontSize, c = ti.width(o.datum, o.datum.text);
    let f = 0, d, h, g, p, m, y, b;
    for (let v = 0; v < l; ++v)
      d = a[v].x, g = a[v].y, h = a[v].x2 === void 0 ? d : a[v].x2, p = a[v].y2 === void 0 ? g : a[v].y2, m = (d + h) / 2, y = (g + p) / 2, b = Math.abs(h - d + p - g), b >= f && (f = b, o.x = m, o.y = y);
    return m = c / 2, y = u / 2, d = o.x - m, h = o.x + m, g = o.y - y, p = o.y + y, o.align = "center", d < 0 && h <= r ? o.align = "left" : 0 <= d && r < h && (o.align = "right"), o.baseline = "middle", g < 0 && p <= s ? o.baseline = "top" : 0 <= g && s < p && (o.baseline = "bottom"), !0;
  };
}
function fp(e, t, n, i, r, s) {
  let o = n / 2;
  return e - o < 0 || e + o > r || t - (o = i / 2) < 0 || t + o > s;
}
function io(e, t, n, i, r, s, o, a) {
  const l = r * s / (i * 2), u = e(t - l), c = e(t + l), f = e(n - (s = s / 2)), d = e(n + s);
  return o.outOfBounds(u, f, c, d) || o.getRange(u, f, c, d) || a && a.getRange(u, f, c, d);
}
function LK(e, t, n, i) {
  const r = e.width, s = e.height, o = t[0], a = t[1];
  function l(u, c, f, d, h) {
    const g = e.invert(u), p = e.invert(c);
    let m = f, y = s, b;
    if (!fp(g, p, d, h, r, s) && !io(e, g, p, h, d, m, o, a) && !io(e, g, p, h, d, h, o, null)) {
      for (; y - m >= 1; )
        b = (m + y) / 2, io(e, g, p, h, d, b, o, a) ? y = b : m = b;
      if (m > f)
        return [g, p, m, !0];
    }
  }
  return function(u) {
    const c = u.datum.datum.items[i].items, f = c.length, d = u.datum.fontSize, h = ti.width(u.datum, u.datum.text);
    let g = n ? d : 0, p = !1, m = !1, y = 0, b, v, _, x, S, E, C, $, N, O, P, T, D, M, w, k, A;
    for (let F = 0; F < f; ++F) {
      for (b = c[F].x, _ = c[F].y, v = c[F].x2 === void 0 ? b : c[F].x2, x = c[F].y2 === void 0 ? _ : c[F].y2, b > v && (A = b, b = v, v = A), _ > x && (A = _, _ = x, x = A), N = e(b), P = e(v), O = ~~((N + P) / 2), T = e(_), M = e(x), D = ~~((T + M) / 2), C = O; C >= N; --C)
        for ($ = D; $ >= T; --$)
          k = l(C, $, g, h, d), k && ([u.x, u.y, g, p] = k);
      for (C = O; C <= P; ++C)
        for ($ = D; $ <= M; ++$)
          k = l(C, $, g, h, d), k && ([u.x, u.y, g, p] = k);
      !p && !n && (w = Math.abs(v - b + x - _), S = (b + v) / 2, E = (_ + x) / 2, w >= y && !fp(S, E, h, d, r, s) && !io(e, S, E, d, h, d, o, null) && (y = w, u.x = S, u.y = E, m = !0));
    }
    return p || m ? (S = h / 2, E = d / 2, o.setRange(e(u.x - S), e(u.y - E), e(u.x + S), e(u.y + E)), u.align = "center", u.baseline = "middle", !0) : !1;
  };
}
const PK = [-1, -1, 1, 1], IK = [-1, 1, -1, 1];
function zK(e, t, n, i) {
  const r = e.width, s = e.height, o = t[0], a = t[1], l = e.bitmap();
  return function(u) {
    const c = u.datum.datum.items[i].items, f = c.length, d = u.datum.fontSize, h = ti.width(u.datum, u.datum.text), g = [];
    let p = n ? d : 0, m = !1, y = !1, b = 0, v, _, x, S, E, C, $, N, O, P, T, D;
    for (let M = 0; M < f; ++M) {
      for (v = c[M].x, x = c[M].y, _ = c[M].x2 === void 0 ? v : c[M].x2, S = c[M].y2 === void 0 ? x : c[M].y2, g.push([e((v + _) / 2), e((x + S) / 2)]); g.length; )
        if ([$, N] = g.pop(), !(o.get($, N) || a.get($, N) || l.get($, N))) {
          l.set($, N);
          for (let w = 0; w < 4; ++w)
            E = $ + PK[w], C = N + IK[w], l.outOfBounds(E, C, E, C) || g.push([E, C]);
          if (E = e.invert($), C = e.invert(N), O = p, P = s, !fp(E, C, h, d, r, s) && !io(e, E, C, d, h, O, o, a) && !io(e, E, C, d, h, d, o, null)) {
            for (; P - O >= 1; )
              T = (O + P) / 2, io(e, E, C, d, h, T, o, a) ? P = T : O = T;
            O > p && (u.x = E, u.y = C, p = O, m = !0);
          }
        }
      !m && !n && (D = Math.abs(_ - v + S - x), E = (v + _) / 2, C = (x + S) / 2, D >= b && !fp(E, C, h, d, r, s) && !io(e, E, C, d, h, d, o, null) && (b = D, u.x = E, u.y = C, y = !0));
    }
    return m || y ? (E = h / 2, C = d / 2, o.setRange(e(u.x - E), e(u.y - C), e(u.x + E), e(u.y + C)), u.align = "center", u.baseline = "middle", !0) : !1;
  };
}
const BK = ["right", "center", "left"], jK = ["bottom", "middle", "top"];
function UK(e, t, n, i) {
  const r = e.width, s = e.height, o = t[0], a = t[1], l = i.length;
  return function(u) {
    const c = u.boundary, f = u.datum.fontSize;
    if (c[2] < 0 || c[5] < 0 || c[0] > r || c[3] > s)
      return !1;
    let d = u.textWidth ?? 0, h, g, p, m, y, b, v, _, x, S, E, C, $, N, O;
    for (let P = 0; P < l; ++P) {
      if (h = (n[P] & 3) - 1, g = (n[P] >>> 2 & 3) - 1, p = h === 0 && g === 0 || i[P] < 0, m = h && g ? Math.SQRT1_2 : 1, y = i[P] < 0 ? -1 : 1, b = c[1 + h] + i[P] * h * m, E = c[4 + g] + y * f * g / 2 + i[P] * g * m, _ = E - f / 2, x = E + f / 2, C = e(b), N = e(_), O = e(x), !d)
        if ($C(C, C, N, O, o, a, b, b, _, x, c, p))
          d = ti.width(u.datum, u.datum.text);
        else
          continue;
      if (S = b + y * d * h / 2, b = S - d / 2, v = S + d / 2, C = e(b), $ = e(v), $C(C, $, N, O, o, a, b, v, _, x, c, p))
        return u.x = h ? h * y < 0 ? v : b : S, u.y = g ? g * y < 0 ? x : _ : E, u.align = BK[h * y + 1], u.baseline = jK[g * y + 1], o.setRange(C, N, $, O), !0;
    }
    return !1;
  };
}
function $C(e, t, n, i, r, s, o, a, l, u, c, f) {
  return !(r.outOfBounds(e, n, t, i) || (f && s || r).getRange(e, n, t, i));
}
const D1 = 0, R1 = 4, L1 = 8, P1 = 0, I1 = 1, z1 = 2, qK = {
  "top-left": D1 + P1,
  top: D1 + I1,
  "top-right": D1 + z1,
  left: R1 + P1,
  middle: R1 + I1,
  right: R1 + z1,
  "bottom-left": L1 + P1,
  bottom: L1 + I1,
  "bottom-right": L1 + z1
}, WK = {
  naive: RK,
  "reduced-search": LK,
  floodfill: zK
};
function HK(e, t, n, i, r, s, o, a, l, u, c) {
  if (!e.length)
    return e;
  const f = Math.max(i.length, r.length), d = GK(i, f), h = VK(r, f), g = YK(e[0].datum), p = g === "group" && e[0].datum.items[l].marktype, m = p === "area", y = XK(g, p, a, l), b = u === null || u === 1 / 0, v = m && c === "naive";
  let _ = -1, x = -1;
  const S = e.map((N) => {
    const O = b ? ti.width(N, N.text) : void 0;
    return _ = Math.max(_, O), x = Math.max(x, N.fontSize), {
      datum: N,
      opacity: 0,
      x: void 0,
      y: void 0,
      align: void 0,
      baseline: void 0,
      boundary: y(N),
      textWidth: O
    };
  });
  u = u === null || u === 1 / 0 ? Math.max(_, x) + Math.max(...i) : u;
  const E = DK(t[0], t[1], u);
  let C;
  if (!v) {
    n && S.sort((P, T) => n(P.datum, T.datum));
    let N = !1;
    for (let P = 0; P < h.length && !N; ++P)
      N = h[P] === 5 || d[P] < 0;
    const O = (g && o || m) && e.map((P) => P.datum);
    C = s.length || O ? TK(E, O || [], s, N, m) : FK(E, o && S);
  }
  const $ = m ? WK[c](E, C, o, l) : UK(E, C, h, d);
  return S.forEach((N) => N.opacity = +$(N)), S;
}
function GK(e, t) {
  const n = new Float64Array(t), i = e.length;
  for (let r = 0; r < i; ++r)
    n[r] = e[r] || 0;
  for (let r = i; r < t; ++r)
    n[r] = n[i - 1];
  return n;
}
function VK(e, t) {
  const n = new Int8Array(t), i = e.length;
  for (let r = 0; r < i; ++r)
    n[r] |= qK[e[r]];
  for (let r = i; r < t; ++r)
    n[r] = n[i - 1];
  return n;
}
function YK(e) {
  return e && e.mark && e.mark.marktype;
}
function XK(e, t, n, i) {
  const r = (s) => [s.x, s.x, s.x, s.y, s.y, s.y];
  return e ? e === "line" || e === "area" ? (s) => r(s.datum) : t === "line" ? (s) => {
    const o = s.datum.items[i].items;
    return r(o.length ? o[n === "start" ? 0 : o.length - 1] : {
      x: NaN,
      y: NaN
    });
  } : (s) => {
    const o = s.datum.bounds;
    return [o.x1, (o.x1 + o.x2) / 2, o.x2, o.y1, (o.y1 + o.y2) / 2, o.y2];
  } : r;
}
const Gb = ["x", "y", "opacity", "align", "baseline"], _R = ["top-left", "left", "bottom-left", "top", "bottom", "top-right", "right", "bottom-right"];
function e_(e) {
  I.call(this, null, e);
}
e_.Definition = {
  type: "Label",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "size",
    type: "number",
    array: !0,
    length: 2,
    required: !0
  }, {
    name: "sort",
    type: "compare"
  }, {
    name: "anchor",
    type: "string",
    array: !0,
    default: _R
  }, {
    name: "offset",
    type: "number",
    array: !0,
    default: [1]
  }, {
    name: "padding",
    type: "number",
    default: 0,
    null: !0
  }, {
    name: "lineAnchor",
    type: "string",
    values: ["start", "end"],
    default: "end"
  }, {
    name: "markIndex",
    type: "number",
    default: 0
  }, {
    name: "avoidBaseMark",
    type: "boolean",
    default: !0
  }, {
    name: "avoidMarks",
    type: "data",
    array: !0
  }, {
    name: "method",
    type: "string",
    default: "naive"
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: Gb.length,
    default: Gb
  }]
};
Y(e_, I, {
  transform(e, t) {
    function n(s) {
      const o = e[s];
      return Ee(o) && t.modified(o.fields);
    }
    const i = e.modified();
    if (!(i || t.changed(t.ADD_REM) || n("sort")))
      return;
    (!e.size || e.size.length !== 2) && j("Size parameter should be specified as a [width, height] array.");
    const r = e.as || Gb;
    return HK(t.materialize(t.SOURCE).source || [], e.size, e.sort, ee(e.offset == null ? 1 : e.offset), ee(e.anchor || _R), e.avoidMarks || [], e.avoidBaseMark !== !1, e.lineAnchor || "end", e.markIndex || 0, e.padding === void 0 ? 0 : e.padding, e.method || "naive").forEach((s) => {
      const o = s.datum;
      o[r[0]] = s.x, o[r[1]] = s.y, o[r[2]] = s.opacity, o[r[3]] = s.align, o[r[4]] = s.baseline;
    }), t.reflow(i).modifies(r);
  }
});
const KK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  label: e_
}, Symbol.toStringTag, { value: "Module" }));
function ER(e, t) {
  var n = [], i = function(c) {
    return c(a);
  }, r, s, o, a, l, u;
  if (t == null)
    n.push(e);
  else
    for (r = {}, s = 0, o = e.length; s < o; ++s)
      a = e[s], l = t.map(i), u = r[l], u || (r[l] = u = [], u.dims = l, n.push(u)), u.push(a);
  return n;
}
function t_(e) {
  I.call(this, null, e);
}
t_.Definition = {
  type: "Loess",
  metadata: {
    generates: !0
  },
  params: [{
    name: "x",
    type: "field",
    required: !0
  }, {
    name: "y",
    type: "field",
    required: !0
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "bandwidth",
    type: "number",
    default: 0.3
  }, {
    name: "as",
    type: "string",
    array: !0
  }]
};
Y(t_, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE | t.NO_FIELDS);
    if (!this.value || t.changed() || e.modified()) {
      const i = t.materialize(t.SOURCE).source, r = ER(i, e.groupby), s = (e.groupby || []).map(ut), o = s.length, a = e.as || [ut(e.x), ut(e.y)], l = [];
      r.forEach((u) => {
        DT(u, e.x, e.y, e.bandwidth || 0.3).forEach((c) => {
          const f = {};
          for (let d = 0; d < o; ++d)
            f[s[d]] = u.dims[d];
          f[a[0]] = c[0], f[a[1]] = c[1], l.push(je(f));
        });
      }), this.value && (n.rem = this.value), this.value = n.add = n.source = l;
    }
    return n;
  }
});
const Vb = {
  constant: Nx,
  linear: Dx,
  log: FT,
  exp: TT,
  pow: OT,
  quad: Rx,
  poly: NT
}, JK = (e, t) => e === "poly" ? t : e === "quad" ? 2 : 1;
function n_(e) {
  I.call(this, null, e);
}
n_.Definition = {
  type: "Regression",
  metadata: {
    generates: !0
  },
  params: [{
    name: "x",
    type: "field",
    required: !0
  }, {
    name: "y",
    type: "field",
    required: !0
  }, {
    name: "groupby",
    type: "field",
    array: !0
  }, {
    name: "method",
    type: "string",
    default: "linear",
    values: Object.keys(Vb)
  }, {
    name: "order",
    type: "number",
    default: 3
  }, {
    name: "extent",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "params",
    type: "boolean",
    default: !1
  }, {
    name: "as",
    type: "string",
    array: !0
  }]
};
Y(n_, I, {
  transform(e, t) {
    const n = t.fork(t.NO_SOURCE | t.NO_FIELDS);
    if (!this.value || t.changed() || e.modified()) {
      const i = t.materialize(t.SOURCE).source, r = ER(i, e.groupby), s = (e.groupby || []).map(ut), o = e.method || "linear", a = e.order == null ? 3 : e.order, l = JK(o, a), u = e.as || [ut(e.x), ut(e.y)], c = Vb[o], f = [];
      let d = e.extent;
      ce(Vb, o) || j("Invalid regression method: " + o), d != null && o === "log" && d[0] <= 0 && (t.dataflow.warn("Ignoring extent with values <= 0 for log regression."), d = null), r.forEach((h) => {
        if (h.length <= l) {
          t.dataflow.warn("Skipping regression with more parameters than data points.");
          return;
        }
        const p = c(h, e.x, e.y, a);
        if (e.params) {
          f.push(je({
            keys: h.dims,
            coef: p.coef,
            rSquared: p.rSquared
          }));
          return;
        }
        const m = d || $r(h, e.x), y = (b) => {
          const v = {};
          for (let _ = 0; _ < s.length; ++_)
            v[s[_]] = h.dims[_];
          v[u[0]] = b[0], v[u[1]] = b[1], f.push(je(v));
        };
        o === "linear" || o === "constant" ? m.forEach((b) => y([b, p.predict(b)])) : sm(p.predict, m, 25, 200).forEach(y);
      }), this.value && (n.rem = this.value), this.value = n.add = n.source = f;
    }
    return n;
  }
});
const QK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  loess: t_,
  regression: n_
}, Symbol.toStringTag, { value: "Module" })), ps = 11102230246251565e-32, Yt = 134217729, ZK = (3 + 8 * ps) * ps;
function B1(e, t, n, i, r) {
  let s, o, a, l, u = t[0], c = i[0], f = 0, d = 0;
  c > u == c > -u ? (s = u, u = t[++f]) : (s = c, c = i[++d]);
  let h = 0;
  if (f < e && d < n)
    for (c > u == c > -u ? (o = u + s, a = s - (o - u), u = t[++f]) : (o = c + s, a = s - (o - c), c = i[++d]), s = o, a !== 0 && (r[h++] = a); f < e && d < n; )
      c > u == c > -u ? (o = s + u, l = o - s, a = s - (o - l) + (u - l), u = t[++f]) : (o = s + c, l = o - s, a = s - (o - l) + (c - l), c = i[++d]), s = o, a !== 0 && (r[h++] = a);
  for (; f < e; )
    o = s + u, l = o - s, a = s - (o - l) + (u - l), u = t[++f], s = o, a !== 0 && (r[h++] = a);
  for (; d < n; )
    o = s + c, l = o - s, a = s - (o - l) + (c - l), c = i[++d], s = o, a !== 0 && (r[h++] = a);
  return (s !== 0 || h === 0) && (r[h++] = s), h;
}
function eJ(e, t) {
  let n = t[0];
  for (let i = 1; i < e; i++)
    n += t[i];
  return n;
}
function _d(e) {
  return new Float64Array(e);
}
const tJ = (3 + 16 * ps) * ps, nJ = (2 + 12 * ps) * ps, iJ = (9 + 64 * ps) * ps * ps, _l = _d(4), MC = _d(8), FC = _d(12), TC = _d(16), cn = _d(4);
function rJ(e, t, n, i, r, s, o) {
  let a, l, u, c, f, d, h, g, p, m, y, b, v, _, x, S, E, C;
  const $ = e - r, N = n - r, O = t - s, P = i - s;
  _ = $ * P, d = Yt * $, h = d - (d - $), g = $ - h, d = Yt * P, p = d - (d - P), m = P - p, x = g * m - (_ - h * p - g * p - h * m), S = O * N, d = Yt * O, h = d - (d - O), g = O - h, d = Yt * N, p = d - (d - N), m = N - p, E = g * m - (S - h * p - g * p - h * m), y = x - E, f = x - y, _l[0] = x - (y + f) + (f - E), b = _ + y, f = b - _, v = _ - (b - f) + (y - f), y = v - S, f = v - y, _l[1] = v - (y + f) + (f - S), C = b + y, f = C - b, _l[2] = b - (C - f) + (y - f), _l[3] = C;
  let T = eJ(4, _l), D = nJ * o;
  if (T >= D || -T >= D || (f = e - $, a = e - ($ + f) + (f - r), f = n - N, u = n - (N + f) + (f - r), f = t - O, l = t - (O + f) + (f - s), f = i - P, c = i - (P + f) + (f - s), a === 0 && l === 0 && u === 0 && c === 0) || (D = iJ * o + ZK * Math.abs(T), T += $ * c + P * a - (O * u + N * l), T >= D || -T >= D))
    return T;
  _ = a * P, d = Yt * a, h = d - (d - a), g = a - h, d = Yt * P, p = d - (d - P), m = P - p, x = g * m - (_ - h * p - g * p - h * m), S = l * N, d = Yt * l, h = d - (d - l), g = l - h, d = Yt * N, p = d - (d - N), m = N - p, E = g * m - (S - h * p - g * p - h * m), y = x - E, f = x - y, cn[0] = x - (y + f) + (f - E), b = _ + y, f = b - _, v = _ - (b - f) + (y - f), y = v - S, f = v - y, cn[1] = v - (y + f) + (f - S), C = b + y, f = C - b, cn[2] = b - (C - f) + (y - f), cn[3] = C;
  const M = B1(4, _l, 4, cn, MC);
  _ = $ * c, d = Yt * $, h = d - (d - $), g = $ - h, d = Yt * c, p = d - (d - c), m = c - p, x = g * m - (_ - h * p - g * p - h * m), S = O * u, d = Yt * O, h = d - (d - O), g = O - h, d = Yt * u, p = d - (d - u), m = u - p, E = g * m - (S - h * p - g * p - h * m), y = x - E, f = x - y, cn[0] = x - (y + f) + (f - E), b = _ + y, f = b - _, v = _ - (b - f) + (y - f), y = v - S, f = v - y, cn[1] = v - (y + f) + (f - S), C = b + y, f = C - b, cn[2] = b - (C - f) + (y - f), cn[3] = C;
  const w = B1(M, MC, 4, cn, FC);
  _ = a * c, d = Yt * a, h = d - (d - a), g = a - h, d = Yt * c, p = d - (d - c), m = c - p, x = g * m - (_ - h * p - g * p - h * m), S = l * u, d = Yt * l, h = d - (d - l), g = l - h, d = Yt * u, p = d - (d - u), m = u - p, E = g * m - (S - h * p - g * p - h * m), y = x - E, f = x - y, cn[0] = x - (y + f) + (f - E), b = _ + y, f = b - _, v = _ - (b - f) + (y - f), y = v - S, f = v - y, cn[1] = v - (y + f) + (f - S), C = b + y, f = C - b, cn[2] = b - (C - f) + (y - f), cn[3] = C;
  const k = B1(w, FC, 4, cn, TC);
  return TC[k - 1];
}
function dh(e, t, n, i, r, s) {
  const o = (t - s) * (n - r), a = (e - r) * (i - s), l = o - a, u = Math.abs(o + a);
  return Math.abs(l) >= tJ * u ? l : -rJ(e, t, n, i, r, s, u);
}
const OC = Math.pow(2, -52), hh = new Uint32Array(512);
class dp {
  static from(t, n = uJ, i = cJ) {
    const r = t.length, s = new Float64Array(r * 2);
    for (let o = 0; o < r; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = i(a);
    }
    return new dp(s);
  }
  constructor(t) {
    const n = t.length >> 1;
    if (n > 0 && typeof t[0] != "number")
      throw new Error("Expected coords to contain numbers.");
    this.coords = t;
    const i = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(i * 3), this._halfedges = new Int32Array(i * 3), this._hashSize = Math.ceil(Math.sqrt(n)), this._hullPrev = new Uint32Array(n), this._hullNext = new Uint32Array(n), this._hullTri = new Uint32Array(n), this._hullHash = new Int32Array(this._hashSize), this._ids = new Uint32Array(n), this._dists = new Float64Array(n), this.update();
  }
  update() {
    const { coords: t, _hullPrev: n, _hullNext: i, _hullTri: r, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, l = 1 / 0, u = -1 / 0, c = -1 / 0;
    for (let $ = 0; $ < o; $++) {
      const N = t[2 * $], O = t[2 * $ + 1];
      N < a && (a = N), O < l && (l = O), N > u && (u = N), O > c && (c = O), this._ids[$] = $;
    }
    const f = (a + u) / 2, d = (l + c) / 2;
    let h, g, p;
    for (let $ = 0, N = 1 / 0; $ < o; $++) {
      const O = j1(f, d, t[2 * $], t[2 * $ + 1]);
      O < N && (h = $, N = O);
    }
    const m = t[2 * h], y = t[2 * h + 1];
    for (let $ = 0, N = 1 / 0; $ < o; $++) {
      if ($ === h)
        continue;
      const O = j1(m, y, t[2 * $], t[2 * $ + 1]);
      O < N && O > 0 && (g = $, N = O);
    }
    let b = t[2 * g], v = t[2 * g + 1], _ = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === h || $ === g)
        continue;
      const N = aJ(m, y, b, v, t[2 * $], t[2 * $ + 1]);
      N < _ && (p = $, _ = N);
    }
    let x = t[2 * p], S = t[2 * p + 1];
    if (_ === 1 / 0) {
      for (let O = 0; O < o; O++)
        this._dists[O] = t[2 * O] - t[0] || t[2 * O + 1] - t[1];
      Il(this._ids, this._dists, 0, o - 1);
      const $ = new Uint32Array(o);
      let N = 0;
      for (let O = 0, P = -1 / 0; O < o; O++) {
        const T = this._ids[O], D = this._dists[T];
        D > P && ($[N++] = T, P = D);
      }
      this.hull = $.subarray(0, N), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (dh(m, y, b, v, x, S) < 0) {
      const $ = g, N = b, O = v;
      g = p, b = x, v = S, p = $, x = N, S = O;
    }
    const E = lJ(m, y, b, v, x, S);
    this._cx = E.x, this._cy = E.y;
    for (let $ = 0; $ < o; $++)
      this._dists[$] = j1(t[2 * $], t[2 * $ + 1], E.x, E.y);
    Il(this._ids, this._dists, 0, o - 1), this._hullStart = h;
    let C = 3;
    i[h] = n[p] = g, i[g] = n[h] = p, i[p] = n[g] = h, r[h] = 0, r[g] = 1, r[p] = 2, s.fill(-1), s[this._hashKey(m, y)] = h, s[this._hashKey(b, v)] = g, s[this._hashKey(x, S)] = p, this.trianglesLen = 0, this._addTriangle(h, g, p, -1, -1, -1);
    for (let $ = 0, N, O; $ < this._ids.length; $++) {
      const P = this._ids[$], T = t[2 * P], D = t[2 * P + 1];
      if ($ > 0 && Math.abs(T - N) <= OC && Math.abs(D - O) <= OC || (N = T, O = D, P === h || P === g || P === p))
        continue;
      let M = 0;
      for (let R = 0, L = this._hashKey(T, D); R < this._hashSize && (M = s[(L + R) % this._hashSize], !(M !== -1 && M !== i[M])); R++)
        ;
      M = n[M];
      let w = M, k;
      for (; k = i[w], dh(T, D, t[2 * w], t[2 * w + 1], t[2 * k], t[2 * k + 1]) >= 0; )
        if (w = k, w === M) {
          w = -1;
          break;
        }
      if (w === -1)
        continue;
      let A = this._addTriangle(w, P, i[w], -1, -1, r[w]);
      r[P] = this._legalize(A + 2), r[w] = A, C++;
      let F = i[w];
      for (; k = i[F], dh(T, D, t[2 * F], t[2 * F + 1], t[2 * k], t[2 * k + 1]) < 0; )
        A = this._addTriangle(F, P, k, r[P], -1, r[F]), r[P] = this._legalize(A + 2), i[F] = F, C--, F = k;
      if (w === M)
        for (; k = n[w], dh(T, D, t[2 * k], t[2 * k + 1], t[2 * w], t[2 * w + 1]) < 0; )
          A = this._addTriangle(k, P, w, -1, r[w], r[k]), this._legalize(A + 2), r[k] = A, i[w] = w, C--, w = k;
      this._hullStart = n[P] = w, i[w] = n[F] = P, i[P] = F, s[this._hashKey(T, D)] = P, s[this._hashKey(t[2 * w], t[2 * w + 1])] = w;
    }
    this.hull = new Uint32Array(C);
    for (let $ = 0, N = this._hullStart; $ < C; $++)
      this.hull[$] = N, N = i[N];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(sJ(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: i, coords: r } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = i[t], l = t - t % 3;
      if (o = l + (t + 2) % 3, a === -1) {
        if (s === 0)
          break;
        t = hh[--s];
        continue;
      }
      const u = a - a % 3, c = l + (t + 1) % 3, f = u + (a + 2) % 3, d = n[o], h = n[t], g = n[c], p = n[f];
      if (oJ(
        r[2 * d],
        r[2 * d + 1],
        r[2 * h],
        r[2 * h + 1],
        r[2 * g],
        r[2 * g + 1],
        r[2 * p],
        r[2 * p + 1]
      )) {
        n[t] = p, n[a] = d;
        const y = i[f];
        if (y === -1) {
          let v = this._hullStart;
          do {
            if (this._hullTri[v] === f) {
              this._hullTri[v] = t;
              break;
            }
            v = this._hullPrev[v];
          } while (v !== this._hullStart);
        }
        this._link(t, y), this._link(a, i[o]), this._link(o, f);
        const b = u + (a + 1) % 3;
        s < hh.length && (hh[s++] = b);
      } else {
        if (s === 0)
          break;
        t = hh[--s];
      }
    }
    return o;
  }
  _link(t, n) {
    this._halfedges[t] = n, n !== -1 && (this._halfedges[n] = t);
  }
  // add a new triangle given vertex indices and adjacent half-edge ids
  _addTriangle(t, n, i, r, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = i, this._link(a, r), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function sJ(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function j1(e, t, n, i) {
  const r = e - n, s = t - i;
  return r * r + s * s;
}
function oJ(e, t, n, i, r, s, o, a) {
  const l = e - o, u = t - a, c = n - o, f = i - a, d = r - o, h = s - a, g = l * l + u * u, p = c * c + f * f, m = d * d + h * h;
  return l * (f * m - p * h) - u * (c * m - p * d) + g * (c * h - f * d) < 0;
}
function aJ(e, t, n, i, r, s) {
  const o = n - e, a = i - t, l = r - e, u = s - t, c = o * o + a * a, f = l * l + u * u, d = 0.5 / (o * u - a * l), h = (u * c - a * f) * d, g = (o * f - l * c) * d;
  return h * h + g * g;
}
function lJ(e, t, n, i, r, s) {
  const o = n - e, a = i - t, l = r - e, u = s - t, c = o * o + a * a, f = l * l + u * u, d = 0.5 / (o * u - a * l), h = e + (u * c - a * f) * d, g = t + (o * f - l * c) * d;
  return { x: h, y: g };
}
function Il(e, t, n, i) {
  if (i - n <= 20)
    for (let r = n + 1; r <= i; r++) {
      const s = e[r], o = t[s];
      let a = r - 1;
      for (; a >= n && t[e[a]] > o; )
        e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const r = n + i >> 1;
    let s = n + 1, o = i;
    yc(e, r, s), t[e[n]] > t[e[i]] && yc(e, n, i), t[e[s]] > t[e[i]] && yc(e, s, i), t[e[n]] > t[e[s]] && yc(e, n, s);
    const a = e[s], l = t[a];
    for (; ; ) {
      do
        s++;
      while (t[e[s]] < l);
      do
        o--;
      while (t[e[o]] > l);
      if (o < s)
        break;
      yc(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, i - s + 1 >= o - n ? (Il(e, t, s, i), Il(e, t, n, o - 1)) : (Il(e, t, n, o - 1), Il(e, t, s, i));
  }
}
function yc(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function uJ(e) {
  return e[0];
}
function cJ(e) {
  return e[1];
}
const NC = 1e-6;
class ma {
  constructor() {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "";
  }
  moveTo(t, n) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
  }
  lineTo(t, n) {
    this._ += `L${this._x1 = +t},${this._y1 = +n}`;
  }
  arc(t, n, i) {
    t = +t, n = +n, i = +i;
    const r = t + i, s = n;
    if (i < 0)
      throw new Error("negative radius");
    this._x1 === null ? this._ += `M${r},${s}` : (Math.abs(this._x1 - r) > NC || Math.abs(this._y1 - s) > NC) && (this._ += "L" + r + "," + s), i && (this._ += `A${i},${i},0,1,1,${t - i},${n}A${i},${i},0,1,1,${this._x1 = r},${this._y1 = s}`);
  }
  rect(t, n, i, r) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+i}v${+r}h${-i}Z`;
  }
  value() {
    return this._ || null;
  }
}
class Yb {
  constructor() {
    this._ = [];
  }
  moveTo(t, n) {
    this._.push([t, n]);
  }
  closePath() {
    this._.push(this._[0].slice());
  }
  lineTo(t, n) {
    this._.push([t, n]);
  }
  value() {
    return this._.length ? this._ : null;
  }
}
let fJ = class {
  constructor(t, [n, i, r, s] = [0, 0, 960, 500]) {
    if (!((r = +r) >= (n = +n)) || !((s = +s) >= (i = +i)))
      throw new Error("invalid bounds");
    this.delaunay = t, this._circumcenters = new Float64Array(t.points.length * 2), this.vectors = new Float64Array(t.points.length * 2), this.xmax = r, this.xmin = n, this.ymax = s, this.ymin = i, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: i }, vectors: r } = this;
    let s, o;
    const a = this.circumcenters = this._circumcenters.subarray(0, i.length / 3 * 2);
    for (let p = 0, m = 0, y = i.length, b, v; p < y; p += 3, m += 2) {
      const _ = i[p] * 2, x = i[p + 1] * 2, S = i[p + 2] * 2, E = t[_], C = t[_ + 1], $ = t[x], N = t[x + 1], O = t[S], P = t[S + 1], T = $ - E, D = N - C, M = O - E, w = P - C, k = (T * w - D * M) * 2;
      if (Math.abs(k) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const F of n)
            s += t[F * 2], o += t[F * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const A = 1e9 * Math.sign((s - E) * w - (o - C) * M);
        b = (E + O) / 2 - A * w, v = (C + P) / 2 + A * M;
      } else {
        const A = 1 / k, F = T * T + D * D, R = M * M + w * w;
        b = E + (w * F - D * R) * A, v = C + (T * R - M * F) * A;
      }
      a[m] = b, a[m + 1] = v;
    }
    let l = n[n.length - 1], u, c = l * 4, f, d = t[2 * l], h, g = t[2 * l + 1];
    r.fill(0);
    for (let p = 0; p < n.length; ++p)
      l = n[p], u = c, f = d, h = g, c = l * 4, d = t[2 * l], g = t[2 * l + 1], r[u + 2] = r[c] = h - g, r[u + 3] = r[c + 1] = d - f;
  }
  render(t) {
    const n = t == null ? t = new ma() : void 0, { delaunay: { halfedges: i, inedges: r, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let c = 0, f = i.length; c < f; ++c) {
      const d = i[c];
      if (d < c)
        continue;
      const h = Math.floor(c / 3) * 2, g = Math.floor(d / 3) * 2, p = o[h], m = o[h + 1], y = o[g], b = o[g + 1];
      this._renderSegment(p, m, y, b, t);
    }
    let l, u = s[s.length - 1];
    for (let c = 0; c < s.length; ++c) {
      l = u, u = s[c];
      const f = Math.floor(r[u] / 3) * 2, d = o[f], h = o[f + 1], g = l * 4, p = this._project(d, h, a[g + 2], a[g + 3]);
      p && this._renderSegment(d, h, p[0], p[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new ma() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const i = n == null ? n = new ma() : void 0, r = this._clip(t);
    if (r === null || !r.length)
      return;
    n.moveTo(r[0], r[1]);
    let s = r.length;
    for (; r[0] === r[s - 2] && r[1] === r[s - 1] && s > 1; )
      s -= 2;
    for (let o = 2; o < s; o += 2)
      (r[o] !== r[o - 2] || r[o + 1] !== r[o - 1]) && n.lineTo(r[o], r[o + 1]);
    return n.closePath(), i && i.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, i = t.length / 2; n < i; ++n) {
      const r = this.cellPolygon(n);
      r && (r.index = n, yield r);
    }
  }
  cellPolygon(t) {
    const n = new Yb();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, i, r, s) {
    let o;
    const a = this._regioncode(t, n), l = this._regioncode(i, r);
    a === 0 && l === 0 ? (s.moveTo(t, n), s.lineTo(i, r)) : (o = this._clipSegment(t, n, i, r, a, l)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, i) {
    return n = +n, n !== n || (i = +i, i !== i) ? !1 : this.delaunay._step(t, n, i) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n)
      for (const i of this.delaunay.neighbors(t)) {
        const r = this._clip(i);
        if (r) {
          e:
            for (let s = 0, o = n.length; s < o; s += 2)
              for (let a = 0, l = r.length; a < l; a += 2)
                if (n[s] === r[a] && n[s + 1] === r[a + 1] && n[(s + 2) % o] === r[(a + l - 2) % l] && n[(s + 3) % o] === r[(a + l - 1) % l]) {
                  yield i;
                  break e;
                }
        }
      }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: i, halfedges: r, triangles: s } } = this, o = i[t];
    if (o === -1)
      return null;
    const a = [];
    let l = o;
    do {
      const u = Math.floor(l / 3);
      if (a.push(n[u * 2], n[u * 2 + 1]), l = l % 3 === 2 ? l - 2 : l + 1, s[l] !== t)
        break;
      l = r[l];
    } while (l !== o && l !== -1);
    return a;
  }
  _clip(t) {
    if (t === 0 && this.delaunay.hull.length === 1)
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    const n = this._cell(t);
    if (n === null)
      return null;
    const { vectors: i } = this, r = t * 4;
    return this._simplify(i[r] || i[r + 1] ? this._clipInfinite(t, n, i[r], i[r + 1], i[r + 2], i[r + 3]) : this._clipFinite(t, n));
  }
  _clipFinite(t, n) {
    const i = n.length;
    let r = null, s, o, a = n[i - 2], l = n[i - 1], u, c = this._regioncode(a, l), f, d = 0;
    for (let h = 0; h < i; h += 2)
      if (s = a, o = l, a = n[h], l = n[h + 1], u = c, c = this._regioncode(a, l), u === 0 && c === 0)
        f = d, d = 0, r ? r.push(a, l) : r = [a, l];
      else {
        let g, p, m, y, b;
        if (u === 0) {
          if ((g = this._clipSegment(s, o, a, l, u, c)) === null)
            continue;
          [p, m, y, b] = g;
        } else {
          if ((g = this._clipSegment(a, l, s, o, c, u)) === null)
            continue;
          [y, b, p, m] = g, f = d, d = this._edgecode(p, m), f && d && this._edge(t, f, d, r, r.length), r ? r.push(p, m) : r = [p, m];
        }
        f = d, d = this._edgecode(y, b), f && d && this._edge(t, f, d, r, r.length), r ? r.push(y, b) : r = [y, b];
      }
    if (r)
      f = d, d = this._edgecode(r[0], r[1]), f && d && this._edge(t, f, d, r, r.length);
    else if (this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2))
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    return r;
  }
  _clipSegment(t, n, i, r, s, o) {
    const a = s < o;
    for (a && ([t, n, i, r, s, o] = [i, r, t, n, o, s]); ; ) {
      if (s === 0 && o === 0)
        return a ? [i, r, t, n] : [t, n, i, r];
      if (s & o)
        return null;
      let l, u, c = s || o;
      c & 8 ? (l = t + (i - t) * (this.ymax - n) / (r - n), u = this.ymax) : c & 4 ? (l = t + (i - t) * (this.ymin - n) / (r - n), u = this.ymin) : c & 2 ? (u = n + (r - n) * (this.xmax - t) / (i - t), l = this.xmax) : (u = n + (r - n) * (this.xmin - t) / (i - t), l = this.xmin), s ? (t = l, n = u, s = this._regioncode(t, n)) : (i = l, r = u, o = this._regioncode(i, r));
    }
  }
  _clipInfinite(t, n, i, r, s, o) {
    let a = Array.from(n), l;
    if ((l = this._project(a[0], a[1], i, r)) && a.unshift(l[0], l[1]), (l = this._project(a[a.length - 2], a[a.length - 1], s, o)) && a.push(l[0], l[1]), a = this._clipFinite(t, a))
      for (let u = 0, c = a.length, f, d = this._edgecode(a[c - 2], a[c - 1]); u < c; u += 2)
        f = d, d = this._edgecode(a[u], a[u + 1]), f && d && (u = this._edge(t, f, d, a, u), c = a.length);
    else
      this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2) && (a = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]);
    return a;
  }
  _edge(t, n, i, r, s) {
    for (; n !== i; ) {
      let o, a;
      switch (n) {
        case 5:
          n = 4;
          continue;
        case 4:
          n = 6, o = this.xmax, a = this.ymin;
          break;
        case 6:
          n = 2;
          continue;
        case 2:
          n = 10, o = this.xmax, a = this.ymax;
          break;
        case 10:
          n = 8;
          continue;
        case 8:
          n = 9, o = this.xmin, a = this.ymax;
          break;
        case 9:
          n = 1;
          continue;
        case 1:
          n = 5, o = this.xmin, a = this.ymin;
          break;
      }
      (r[s] !== o || r[s + 1] !== a) && this.contains(t, o, a) && (r.splice(s, 0, o, a), s += 2);
    }
    return s;
  }
  _project(t, n, i, r) {
    let s = 1 / 0, o, a, l;
    if (r < 0) {
      if (n <= this.ymin)
        return null;
      (o = (this.ymin - n) / r) < s && (l = this.ymin, a = t + (s = o) * i);
    } else if (r > 0) {
      if (n >= this.ymax)
        return null;
      (o = (this.ymax - n) / r) < s && (l = this.ymax, a = t + (s = o) * i);
    }
    if (i > 0) {
      if (t >= this.xmax)
        return null;
      (o = (this.xmax - t) / i) < s && (a = this.xmax, l = n + (s = o) * r);
    } else if (i < 0) {
      if (t <= this.xmin)
        return null;
      (o = (this.xmin - t) / i) < s && (a = this.xmin, l = n + (s = o) * r);
    }
    return [a, l];
  }
  _edgecode(t, n) {
    return (t === this.xmin ? 1 : t === this.xmax ? 2 : 0) | (n === this.ymin ? 4 : n === this.ymax ? 8 : 0);
  }
  _regioncode(t, n) {
    return (t < this.xmin ? 1 : t > this.xmax ? 2 : 0) | (n < this.ymin ? 4 : n > this.ymax ? 8 : 0);
  }
  _simplify(t) {
    if (t && t.length > 4) {
      for (let n = 0; n < t.length; n += 2) {
        const i = (n + 2) % t.length, r = (n + 4) % t.length;
        (t[n] === t[i] && t[i] === t[r] || t[n + 1] === t[i + 1] && t[i + 1] === t[r + 1]) && (t.splice(i, 2), n -= 2);
      }
      t.length || (t = null);
    }
    return t;
  }
};
const dJ = 2 * Math.PI, El = Math.pow;
function hJ(e) {
  return e[0];
}
function gJ(e) {
  return e[1];
}
function pJ(e) {
  const { triangles: t, coords: n } = e;
  for (let i = 0; i < t.length; i += 3) {
    const r = 2 * t[i], s = 2 * t[i + 1], o = 2 * t[i + 2];
    if ((n[o] - n[r]) * (n[s + 1] - n[r + 1]) - (n[s] - n[r]) * (n[o + 1] - n[r + 1]) > 1e-10)
      return !1;
  }
  return !0;
}
function mJ(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class i_ {
  static from(t, n = hJ, i = gJ, r) {
    return new i_("length" in t ? yJ(t, n, i, r) : Float64Array.from(bJ(t, n, i, r)));
  }
  constructor(t) {
    this._delaunator = new dp(t), this.inedges = new Int32Array(t.length / 2), this._hullIndex = new Int32Array(t.length / 2), this.points = this._delaunator.coords, this._init();
  }
  update() {
    return this._delaunator.update(), this._init(), this;
  }
  _init() {
    const t = this._delaunator, n = this.points;
    if (t.hull && t.hull.length > 2 && pJ(t)) {
      this.collinear = Int32Array.from({ length: n.length / 2 }, (d, h) => h).sort((d, h) => n[2 * d] - n[2 * h] || n[2 * d + 1] - n[2 * h + 1]);
      const l = this.collinear[0], u = this.collinear[this.collinear.length - 1], c = [n[2 * l], n[2 * l + 1], n[2 * u], n[2 * u + 1]], f = 1e-8 * Math.hypot(c[3] - c[1], c[2] - c[0]);
      for (let d = 0, h = n.length / 2; d < h; ++d) {
        const g = mJ(n[2 * d], n[2 * d + 1], f);
        n[2 * d] = g[0], n[2 * d + 1] = g[1];
      }
      this._delaunator = new dp(n);
    } else
      delete this.collinear;
    const i = this.halfedges = this._delaunator.halfedges, r = this.hull = this._delaunator.hull, s = this.triangles = this._delaunator.triangles, o = this.inedges.fill(-1), a = this._hullIndex.fill(-1);
    for (let l = 0, u = i.length; l < u; ++l) {
      const c = s[l % 3 === 2 ? l - 2 : l + 1];
      (i[l] === -1 || o[c] === -1) && (o[c] = l);
    }
    for (let l = 0, u = r.length; l < u; ++l)
      a[r[l]] = l;
    r.length <= 2 && r.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = r[0], o[r[0]] = 1, r.length === 2 && (o[r[1]] = 0, this.triangles[1] = r[1], this.triangles[2] = r[1]));
  }
  voronoi(t) {
    return new fJ(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: i, _hullIndex: r, halfedges: s, triangles: o, collinear: a } = this;
    if (a) {
      const f = a.indexOf(t);
      f > 0 && (yield a[f - 1]), f < a.length - 1 && (yield a[f + 1]);
      return;
    }
    const l = n[t];
    if (l === -1)
      return;
    let u = l, c = -1;
    do {
      if (yield c = o[u], u = u % 3 === 2 ? u - 2 : u + 1, o[u] !== t)
        return;
      if (u = s[u], u === -1) {
        const f = i[(r[t] + 1) % i.length];
        f !== c && (yield f);
        return;
      }
    } while (u !== l);
  }
  find(t, n, i = 0) {
    if (t = +t, t !== t || (n = +n, n !== n))
      return -1;
    const r = i;
    let s;
    for (; (s = this._step(i, t, n)) >= 0 && s !== i && s !== r; )
      i = s;
    return s;
  }
  _step(t, n, i) {
    const { inedges: r, hull: s, _hullIndex: o, halfedges: a, triangles: l, points: u } = this;
    if (r[t] === -1 || !u.length)
      return (t + 1) % (u.length >> 1);
    let c = t, f = El(n - u[t * 2], 2) + El(i - u[t * 2 + 1], 2);
    const d = r[t];
    let h = d;
    do {
      let g = l[h];
      const p = El(n - u[g * 2], 2) + El(i - u[g * 2 + 1], 2);
      if (p < f && (f = p, c = g), h = h % 3 === 2 ? h - 2 : h + 1, l[h] !== t)
        break;
      if (h = a[h], h === -1) {
        if (h = s[(o[t] + 1) % s.length], h !== g && El(n - u[h * 2], 2) + El(i - u[h * 2 + 1], 2) < f)
          return h;
        break;
      }
    } while (h !== d);
    return c;
  }
  render(t) {
    const n = t == null ? t = new ma() : void 0, { points: i, halfedges: r, triangles: s } = this;
    for (let o = 0, a = r.length; o < a; ++o) {
      const l = r[o];
      if (l < o)
        continue;
      const u = s[o] * 2, c = s[l] * 2;
      t.moveTo(i[u], i[u + 1]), t.lineTo(i[c], i[c + 1]);
    }
    return this.renderHull(t), n && n.value();
  }
  renderPoints(t, n) {
    n === void 0 && (!t || typeof t.moveTo != "function") && (n = t, t = null), n = n == null ? 2 : +n;
    const i = t == null ? t = new ma() : void 0, { points: r } = this;
    for (let s = 0, o = r.length; s < o; s += 2) {
      const a = r[s], l = r[s + 1];
      t.moveTo(a + n, l), t.arc(a, l, n, 0, dJ);
    }
    return i && i.value();
  }
  renderHull(t) {
    const n = t == null ? t = new ma() : void 0, { hull: i, points: r } = this, s = i[0] * 2, o = i.length;
    t.moveTo(r[s], r[s + 1]);
    for (let a = 1; a < o; ++a) {
      const l = 2 * i[a];
      t.lineTo(r[l], r[l + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new Yb();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const i = n == null ? n = new ma() : void 0, { points: r, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, l = s[t + 2] * 2;
    return n.moveTo(r[o], r[o + 1]), n.lineTo(r[a], r[a + 1]), n.lineTo(r[l], r[l + 1]), n.closePath(), i && i.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, i = t.length / 3; n < i; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new Yb();
    return this.renderTriangle(t, n), n.value();
  }
}
function yJ(e, t, n, i) {
  const r = e.length, s = new Float64Array(r * 2);
  for (let o = 0; o < r; ++o) {
    const a = e[o];
    s[o * 2] = t.call(i, a, o, e), s[o * 2 + 1] = n.call(i, a, o, e);
  }
  return s;
}
function* bJ(e, t, n, i) {
  let r = 0;
  for (const s of e)
    yield t.call(i, s, r, e), yield n.call(i, s, r, e), ++r;
}
function r_(e) {
  I.call(this, null, e);
}
r_.Definition = {
  type: "Voronoi",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "x",
    type: "field",
    required: !0
  }, {
    name: "y",
    type: "field",
    required: !0
  }, {
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "extent",
    type: "array",
    array: !0,
    length: 2,
    default: [[-1e5, -1e5], [1e5, 1e5]],
    content: {
      type: "number",
      array: !0,
      length: 2
    }
  }, {
    name: "as",
    type: "string",
    default: "path"
  }]
};
const vJ = [-1e5, -1e5, 1e5, 1e5];
Y(r_, I, {
  transform(e, t) {
    const n = e.as || "path", i = t.source;
    if (!i || !i.length)
      return t;
    let r = e.size;
    r = r ? [0, 0, r[0], r[1]] : (r = e.extent) ? [r[0][0], r[0][1], r[1][0], r[1][1]] : vJ;
    const s = this.value = i_.from(i, e.x, e.y).voronoi(r);
    for (let o = 0, a = i.length; o < a; ++o) {
      const l = s.cellPolygon(o);
      i[o][n] = l && !wJ(l) ? xJ(l) : null;
    }
    return t.reflow(e.modified()).modifies(n);
  }
});
function xJ(e) {
  const t = e[0][0], n = e[0][1];
  let i = e.length - 1;
  for (; e[i][0] === t && e[i][1] === n; --i)
    ;
  return "M" + e.slice(0, i + 1).join("L") + "Z";
}
function wJ(e) {
  return e.length === 2 && e[0][0] === e[1][0] && e[0][1] === e[1][1];
}
const _J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  voronoi: r_
}, Symbol.toStringTag, { value: "Module" }));
var U1 = Math.PI / 180, Xc = 64, Yh = 2048;
function EJ() {
  var e = [256, 256], t, n, i, r, s, o, a, l = SR, u = [], c = Math.random, f = {};
  f.layout = function() {
    for (var g = d(lo()), p = MJ((e[0] >> 5) * e[1]), m = null, y = u.length, b = -1, v = [], _ = u.map((S) => ({
      text: t(S),
      font: n(S),
      style: r(S),
      weight: s(S),
      rotate: o(S),
      size: ~~(i(S) + 1e-14),
      padding: a(S),
      xoff: 0,
      yoff: 0,
      x1: 0,
      y1: 0,
      x0: 0,
      y0: 0,
      hasText: !1,
      sprite: null,
      datum: S
    })).sort((S, E) => E.size - S.size); ++b < y; ) {
      var x = _[b];
      x.x = e[0] * (c() + 0.5) >> 1, x.y = e[1] * (c() + 0.5) >> 1, SJ(g, x, _, b), x.hasText && h(p, x, m) && (v.push(x), m ? AJ(m, x) : m = [{
        x: x.x + x.x0,
        y: x.y + x.y0
      }, {
        x: x.x + x.x1,
        y: x.y + x.y1
      }], x.x -= e[0] >> 1, x.y -= e[1] >> 1);
    }
    return v;
  };
  function d(g) {
    g.width = g.height = 1;
    var p = Math.sqrt(g.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2);
    g.width = (Xc << 5) / p, g.height = Yh / p;
    var m = g.getContext("2d");
    return m.fillStyle = m.strokeStyle = "red", m.textAlign = "center", {
      context: m,
      ratio: p
    };
  }
  function h(g, p, m) {
    for (var y = p.x, b = p.y, v = Math.sqrt(e[0] * e[0] + e[1] * e[1]), _ = l(e), x = c() < 0.5 ? 1 : -1, S = -x, E, C, $; (E = _(S += x)) && (C = ~~E[0], $ = ~~E[1], !(Math.min(Math.abs(C), Math.abs($)) >= v)); )
      if (p.x = y + C, p.y = b + $, !(p.x + p.x0 < 0 || p.y + p.y0 < 0 || p.x + p.x1 > e[0] || p.y + p.y1 > e[1]) && (!m || !kJ(p, g, e[0])) && (!m || CJ(p, m))) {
        for (var N = p.sprite, O = p.width >> 5, P = e[0] >> 5, T = p.x - (O << 4), D = T & 127, M = 32 - D, w = p.y1 - p.y0, k = (p.y + p.y0) * P + (T >> 5), A, F = 0; F < w; F++) {
          A = 0;
          for (var R = 0; R <= O; R++)
            g[k + R] |= A << M | (R < O ? (A = N[F * O + R]) >>> D : 0);
          k += P;
        }
        return p.sprite = null, !0;
      }
    return !1;
  }
  return f.words = function(g) {
    return arguments.length ? (u = g, f) : u;
  }, f.size = function(g) {
    return arguments.length ? (e = [+g[0], +g[1]], f) : e;
  }, f.font = function(g) {
    return arguments.length ? (n = Vo(g), f) : n;
  }, f.fontStyle = function(g) {
    return arguments.length ? (r = Vo(g), f) : r;
  }, f.fontWeight = function(g) {
    return arguments.length ? (s = Vo(g), f) : s;
  }, f.rotate = function(g) {
    return arguments.length ? (o = Vo(g), f) : o;
  }, f.text = function(g) {
    return arguments.length ? (t = Vo(g), f) : t;
  }, f.spiral = function(g) {
    return arguments.length ? (l = FJ[g] || g, f) : l;
  }, f.fontSize = function(g) {
    return arguments.length ? (i = Vo(g), f) : i;
  }, f.padding = function(g) {
    return arguments.length ? (a = Vo(g), f) : a;
  }, f.random = function(g) {
    return arguments.length ? (c = g, f) : c;
  }, f;
}
function SJ(e, t, n, i) {
  if (!t.sprite) {
    var r = e.context, s = e.ratio;
    r.clearRect(0, 0, (Xc << 5) / s, Yh / s);
    var o = 0, a = 0, l = 0, u = n.length, c, f, d, h, g;
    for (--i; ++i < u; ) {
      if (t = n[i], r.save(), r.font = t.style + " " + t.weight + " " + ~~((t.size + 1) / s) + "px " + t.font, c = r.measureText(t.text + "m").width * s, d = t.size << 1, t.rotate) {
        var p = Math.sin(t.rotate * U1), m = Math.cos(t.rotate * U1), y = c * m, b = c * p, v = d * m, _ = d * p;
        c = Math.max(Math.abs(y + _), Math.abs(y - _)) + 31 >> 5 << 5, d = ~~Math.max(Math.abs(b + v), Math.abs(b - v));
      } else
        c = c + 31 >> 5 << 5;
      if (d > l && (l = d), o + c >= Xc << 5 && (o = 0, a += l, l = 0), a + d >= Yh)
        break;
      r.translate((o + (c >> 1)) / s, (a + (d >> 1)) / s), t.rotate && r.rotate(t.rotate * U1), r.fillText(t.text, 0, 0), t.padding && (r.lineWidth = 2 * t.padding, r.strokeText(t.text, 0, 0)), r.restore(), t.width = c, t.height = d, t.xoff = o, t.yoff = a, t.x1 = c >> 1, t.y1 = d >> 1, t.x0 = -t.x1, t.y0 = -t.y1, t.hasText = !0, o += c;
    }
    for (var x = r.getImageData(0, 0, (Xc << 5) / s, Yh / s).data, S = []; --i >= 0; )
      if (t = n[i], !!t.hasText) {
        for (c = t.width, f = c >> 5, d = t.y1 - t.y0, h = 0; h < d * f; h++)
          S[h] = 0;
        if (o = t.xoff, o == null)
          return;
        a = t.yoff;
        var E = 0, C = -1;
        for (g = 0; g < d; g++) {
          for (h = 0; h < c; h++) {
            var $ = f * g + (h >> 5), N = x[(a + g) * (Xc << 5) + (o + h) << 2] ? 1 << 31 - h % 32 : 0;
            S[$] |= N, E |= N;
          }
          E ? C = g : (t.y0++, d--, g--, a++);
        }
        t.y1 = t.y0 + C, t.sprite = S.slice(0, (t.y1 - t.y0) * f);
      }
  }
}
function kJ(e, t, n) {
  n >>= 5;
  for (var i = e.sprite, r = e.width >> 5, s = e.x - (r << 4), o = s & 127, a = 32 - o, l = e.y1 - e.y0, u = (e.y + e.y0) * n + (s >> 5), c, f = 0; f < l; f++) {
    c = 0;
    for (var d = 0; d <= r; d++)
      if ((c << a | (d < r ? (c = i[f * r + d]) >>> o : 0)) & t[u + d])
        return !0;
    u += n;
  }
  return !1;
}
function AJ(e, t) {
  var n = e[0], i = e[1];
  t.x + t.x0 < n.x && (n.x = t.x + t.x0), t.y + t.y0 < n.y && (n.y = t.y + t.y0), t.x + t.x1 > i.x && (i.x = t.x + t.x1), t.y + t.y1 > i.y && (i.y = t.y + t.y1);
}
function CJ(e, t) {
  return e.x + e.x1 > t[0].x && e.x + e.x0 < t[1].x && e.y + e.y1 > t[0].y && e.y + e.y0 < t[1].y;
}
function SR(e) {
  var t = e[0] / e[1];
  return function(n) {
    return [t * (n *= 0.1) * Math.cos(n), n * Math.sin(n)];
  };
}
function $J(e) {
  var t = 4, n = t * e[0] / e[1], i = 0, r = 0;
  return function(s) {
    var o = s < 0 ? -1 : 1;
    switch (Math.sqrt(1 + 4 * o * s) - o & 3) {
      case 0:
        i += n;
        break;
      case 1:
        r += t;
        break;
      case 2:
        i -= n;
        break;
      default:
        r -= t;
        break;
    }
    return [i, r];
  };
}
function MJ(e) {
  for (var t = [], n = -1; ++n < e; )
    t[n] = 0;
  return t;
}
function Vo(e) {
  return typeof e == "function" ? e : function() {
    return e;
  };
}
var FJ = {
  archimedean: SR,
  rectangular: $J
};
const kR = ["x", "y", "font", "fontSize", "fontStyle", "fontWeight", "angle"], TJ = ["text", "font", "rotate", "fontSize", "fontStyle", "fontWeight"];
function s_(e) {
  I.call(this, EJ(), e);
}
s_.Definition = {
  type: "Wordcloud",
  metadata: {
    modifies: !0
  },
  params: [{
    name: "size",
    type: "number",
    array: !0,
    length: 2
  }, {
    name: "font",
    type: "string",
    expr: !0,
    default: "sans-serif"
  }, {
    name: "fontStyle",
    type: "string",
    expr: !0,
    default: "normal"
  }, {
    name: "fontWeight",
    type: "string",
    expr: !0,
    default: "normal"
  }, {
    name: "fontSize",
    type: "number",
    expr: !0,
    default: 14
  }, {
    name: "fontSizeRange",
    type: "number",
    array: "nullable",
    default: [10, 50]
  }, {
    name: "rotate",
    type: "number",
    expr: !0,
    default: 0
  }, {
    name: "text",
    type: "field"
  }, {
    name: "spiral",
    type: "string",
    values: ["archimedean", "rectangular"]
  }, {
    name: "padding",
    type: "number",
    expr: !0
  }, {
    name: "as",
    type: "string",
    array: !0,
    length: 7,
    default: kR
  }]
};
Y(s_, I, {
  transform(e, t) {
    e.size && !(e.size[0] && e.size[1]) && j("Wordcloud size dimensions must be non-zero.");
    function n(g) {
      const p = e[g];
      return Ee(p) && t.modified(p.fields);
    }
    const i = e.modified();
    if (!(i || t.changed(t.ADD_REM) || TJ.some(n)))
      return;
    const r = t.materialize(t.SOURCE).source, s = this.value, o = e.as || kR;
    let a = e.fontSize || 14, l;
    if (Ee(a) ? l = e.fontSizeRange : a = ln(a), l) {
      const g = a, p = ze("sqrt")().domain($r(r, g)).range(l);
      a = (m) => p(g(m));
    }
    r.forEach((g) => {
      g[o[0]] = NaN, g[o[1]] = NaN, g[o[3]] = 0;
    });
    const u = s.words(r).text(e.text).size(e.size || [500, 500]).padding(e.padding || 1).spiral(e.spiral || "archimedean").rotate(e.rotate || 0).font(e.font || "sans-serif").fontStyle(e.fontStyle || "normal").fontWeight(e.fontWeight || "normal").fontSize(a).random(ki).layout(), c = s.size(), f = c[0] >> 1, d = c[1] >> 1, h = u.length;
    for (let g = 0, p, m; g < h; ++g)
      p = u[g], m = p.datum, m[o[0]] = p.x + f, m[o[1]] = p.y + d, m[o[2]] = p.font, m[o[3]] = p.size, m[o[4]] = p.style, m[o[5]] = p.weight, m[o[6]] = p.rotate;
    return t.reflow(i).modifies(o);
  }
});
const OJ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  wordcloud: s_
}, Symbol.toStringTag, { value: "Module" })), NJ = (e) => new Uint8Array(e), DJ = (e) => new Uint16Array(e), cf = (e) => new Uint32Array(e);
function RJ() {
  let e = 8, t = [], n = cf(0), i = gh(0, e), r = gh(0, e);
  return {
    data: () => t,
    seen: () => n = LJ(n, t.length),
    add(s) {
      for (let o = 0, a = t.length, l = s.length, u; o < l; ++o)
        u = s[o], u._index = a++, t.push(u);
    },
    remove(s, o) {
      const a = t.length, l = Array(a - s), u = t;
      let c, f, d;
      for (f = 0; !o[f] && f < a; ++f)
        l[f] = t[f], u[f] = f;
      for (d = f; f < a; ++f)
        c = t[f], o[f] ? u[f] = -1 : (u[f] = d, i[d] = i[f], r[d] = r[f], l[d] = c, c._index = d++), i[f] = 0;
      return t = l, u;
    },
    size: () => t.length,
    curr: () => i,
    prev: () => r,
    reset: (s) => r[s] = i[s],
    all: () => e < 257 ? 255 : e < 65537 ? 65535 : 4294967295,
    set(s, o) {
      i[s] |= o;
    },
    clear(s, o) {
      i[s] &= ~o;
    },
    resize(s, o) {
      const a = i.length;
      (s > a || o > e) && (e = Math.max(o, e), i = gh(s, e, i), r = gh(s, e));
    }
  };
}
function LJ(e, t, n) {
  return e.length >= t ? e : (n = n || new e.constructor(t), n.set(e), n);
}
function gh(e, t, n) {
  const i = (t < 257 ? NJ : t < 65537 ? DJ : cf)(e);
  return n && i.set(n), i;
}
function DC(e, t, n) {
  const i = 1 << t;
  return {
    one: i,
    zero: ~i,
    range: n.slice(),
    bisect: e.bisect,
    index: e.index,
    size: e.size,
    onAdd(r, s) {
      const o = this, a = o.bisect(o.range, r.value), l = r.index, u = a[0], c = a[1], f = l.length;
      let d;
      for (d = 0; d < u; ++d)
        s[l[d]] |= i;
      for (d = c; d < f; ++d)
        s[l[d]] |= i;
      return o;
    }
  };
}
function RC() {
  let e = cf(0), t = [], n = 0;
  function i(a, l, u) {
    if (!l.length)
      return [];
    const c = n, f = l.length, d = cf(f);
    let h = Array(f), g, p, m;
    for (m = 0; m < f; ++m)
      h[m] = a(l[m]), d[m] = m;
    if (h = PJ(h, d), c)
      g = t, p = e, t = Array(c + f), e = cf(c + f), IJ(u, g, p, c, h, d, f, t, e);
    else {
      if (u > 0)
        for (m = 0; m < f; ++m)
          d[m] += u;
      t = h, e = d;
    }
    return n = c + f, {
      index: d,
      value: h
    };
  }
  function r(a, l) {
    const u = n;
    let c, f, d;
    for (f = 0; !l[e[f]] && f < u; ++f)
      ;
    for (d = f; f < u; ++f)
      l[c = e[f]] || (e[d] = c, t[d] = t[f], ++d);
    n = u - a;
  }
  function s(a) {
    for (let l = 0, u = n; l < u; ++l)
      e[l] = a[e[l]];
  }
  function o(a, l) {
    let u;
    return l ? u = l.length : (l = t, u = n), [QI(l, a[0], 0, u), fo(l, a[1], 0, u)];
  }
  return {
    insert: i,
    remove: r,
    bisect: o,
    reindex: s,
    index: () => e,
    size: () => n
  };
}
function PJ(e, t) {
  return e.sort.call(t, (n, i) => {
    const r = e[n], s = e[i];
    return r < s ? -1 : r > s ? 1 : 0;
  }), t9(e, t);
}
function IJ(e, t, n, i, r, s, o, a, l) {
  let u = 0, c = 0, f;
  for (f = 0; u < i && c < o; ++f)
    t[u] < r[c] ? (a[f] = t[u], l[f] = n[u++]) : (a[f] = r[c], l[f] = s[c++] + e);
  for (; u < i; ++u, ++f)
    a[f] = t[u], l[f] = n[u];
  for (; c < o; ++c, ++f)
    a[f] = r[c], l[f] = s[c] + e;
}
function o_(e) {
  I.call(this, RJ(), e), this._indices = null, this._dims = null;
}
o_.Definition = {
  type: "CrossFilter",
  metadata: {},
  params: [{
    name: "fields",
    type: "field",
    array: !0,
    required: !0
  }, {
    name: "query",
    type: "array",
    array: !0,
    required: !0,
    content: {
      type: "number",
      array: !0,
      length: 2
    }
  }]
};
Y(o_, I, {
  transform(e, t) {
    if (this._dims) {
      var n = e.modified("fields") || e.fields.some((i) => t.modified(i.fields));
      return n ? this.reinit(e, t) : this.eval(e, t);
    } else
      return this.init(e, t);
  },
  init(e, t) {
    const n = e.fields, i = e.query, r = this._indices = {}, s = this._dims = [], o = i.length;
    let a = 0, l, u;
    for (; a < o; ++a)
      l = n[a].fname, u = r[l] || (r[l] = RC()), s.push(DC(u, a, i[a]));
    return this.eval(e, t);
  },
  reinit(e, t) {
    const n = t.materialize().fork(), i = e.fields, r = e.query, s = this._indices, o = this._dims, a = this.value, l = a.curr(), u = a.prev(), c = a.all(), f = n.rem = n.add, d = n.mod, h = r.length, g = {};
    let p, m, y, b, v, _, x, S, E;
    if (u.set(l), t.rem.length && (v = this.remove(e, t, n)), t.add.length && a.add(t.add), t.mod.length)
      for (_ = {}, b = t.mod, x = 0, S = b.length; x < S; ++x)
        _[b[x]._index] = 1;
    for (x = 0; x < h; ++x)
      E = i[x], (!o[x] || e.modified("fields", x) || t.modified(E.fields)) && (y = E.fname, (p = g[y]) || (s[y] = m = RC(), g[y] = p = m.insert(E, t.source, 0)), o[x] = DC(m, x, r[x]).onAdd(p, l));
    for (x = 0, S = a.data().length; x < S; ++x)
      v[x] || (u[x] !== l[x] ? f.push(x) : _[x] && l[x] !== c && d.push(x));
    return a.mask = (1 << h) - 1, n;
  },
  eval(e, t) {
    const n = t.materialize().fork(), i = this._dims.length;
    let r = 0;
    return t.rem.length && (this.remove(e, t, n), r |= (1 << i) - 1), e.modified("query") && !e.modified("fields") && (r |= this.update(e, t, n)), t.add.length && (this.insert(e, t, n), r |= (1 << i) - 1), t.mod.length && (this.modify(t, n), r |= (1 << i) - 1), this.value.mask = r, n;
  },
  insert(e, t, n) {
    const i = t.add, r = this.value, s = this._dims, o = this._indices, a = e.fields, l = {}, u = n.add, c = r.size() + i.length, f = s.length;
    let d = r.size(), h, g, p;
    r.resize(c, f), r.add(i);
    const m = r.curr(), y = r.prev(), b = r.all();
    for (h = 0; h < f; ++h)
      g = a[h].fname, p = l[g] || (l[g] = o[g].insert(a[h], i, d)), s[h].onAdd(p, m);
    for (; d < c; ++d)
      y[d] = b, m[d] !== b && u.push(d);
  },
  modify(e, t) {
    const n = t.mod, i = this.value, r = i.curr(), s = i.all(), o = e.mod;
    let a, l, u;
    for (a = 0, l = o.length; a < l; ++a)
      u = o[a]._index, r[u] !== s && n.push(u);
  },
  remove(e, t, n) {
    const i = this._indices, r = this.value, s = r.curr(), o = r.prev(), a = r.all(), l = {}, u = n.rem, c = t.rem;
    let f, d, h, g;
    for (f = 0, d = c.length; f < d; ++f)
      h = c[f]._index, l[h] = 1, o[h] = g = s[h], s[h] = a, g !== a && u.push(h);
    for (h in i)
      i[h].remove(d, l);
    return this.reindex(t, d, l), l;
  },
  // reindex filters and indices after propagation completes
  reindex(e, t, n) {
    const i = this._indices, r = this.value;
    e.runAfter(() => {
      const s = r.remove(t, n);
      for (const o in i)
        i[o].reindex(s);
    });
  },
  update(e, t, n) {
    const i = this._dims, r = e.query, s = t.stamp, o = i.length;
    let a = 0, l, u;
    for (n.filters = 0, u = 0; u < o; ++u)
      e.modified("query", u) && (l = u, ++a);
    if (a === 1)
      a = i[l].one, this.incrementOne(i[l], r[l], n.add, n.rem);
    else
      for (u = 0, a = 0; u < o; ++u)
        e.modified("query", u) && (a |= i[u].one, this.incrementAll(i[u], r[u], s, n.add), n.rem = n.add);
    return a;
  },
  incrementAll(e, t, n, i) {
    const r = this.value, s = r.seen(), o = r.curr(), a = r.prev(), l = e.index(), u = e.bisect(e.range), c = e.bisect(t), f = c[0], d = c[1], h = u[0], g = u[1], p = e.one;
    let m, y, b;
    if (f < h)
      for (m = f, y = Math.min(h, d); m < y; ++m)
        b = l[m], s[b] !== n && (a[b] = o[b], s[b] = n, i.push(b)), o[b] ^= p;
    else if (f > h)
      for (m = h, y = Math.min(f, g); m < y; ++m)
        b = l[m], s[b] !== n && (a[b] = o[b], s[b] = n, i.push(b)), o[b] ^= p;
    if (d > g)
      for (m = Math.max(f, g), y = d; m < y; ++m)
        b = l[m], s[b] !== n && (a[b] = o[b], s[b] = n, i.push(b)), o[b] ^= p;
    else if (d < g)
      for (m = Math.max(h, d), y = g; m < y; ++m)
        b = l[m], s[b] !== n && (a[b] = o[b], s[b] = n, i.push(b)), o[b] ^= p;
    e.range = t.slice();
  },
  incrementOne(e, t, n, i) {
    const r = this.value, s = r.curr(), o = e.index(), a = e.bisect(e.range), l = e.bisect(t), u = l[0], c = l[1], f = a[0], d = a[1], h = e.one;
    let g, p, m;
    if (u < f)
      for (g = u, p = Math.min(f, c); g < p; ++g)
        m = o[g], s[m] ^= h, n.push(m);
    else if (u > f)
      for (g = f, p = Math.min(u, d); g < p; ++g)
        m = o[g], s[m] ^= h, i.push(m);
    if (c > d)
      for (g = Math.max(u, d), p = c; g < p; ++g)
        m = o[g], s[m] ^= h, n.push(m);
    else if (c < d)
      for (g = Math.max(f, c), p = d; g < p; ++g)
        m = o[g], s[m] ^= h, i.push(m);
    e.range = t.slice();
  }
});
function a_(e) {
  I.call(this, null, e);
}
a_.Definition = {
  type: "ResolveFilter",
  metadata: {},
  params: [{
    name: "ignore",
    type: "number",
    required: !0,
    description: "A bit mask indicating which filters to ignore."
  }, {
    name: "filter",
    type: "object",
    required: !0,
    description: "Per-tuple filter bitmaps from a CrossFilter transform."
  }]
};
Y(a_, I, {
  transform(e, t) {
    const n = ~(e.ignore || 0), i = e.filter, r = i.mask;
    if (!(r & n))
      return t.StopPropagation;
    const s = t.fork(t.ALL), o = i.data(), a = i.curr(), l = i.prev(), u = (c) => a[c] & n ? null : o[c];
    return s.filter(s.MOD, u), r & r - 1 ? (s.filter(s.ADD, (c) => {
      const f = a[c] & n;
      return !f && f ^ l[c] & n ? o[c] : null;
    }), s.filter(s.REM, (c) => {
      const f = a[c] & n;
      return f && !(f ^ (f ^ l[c] & n)) ? o[c] : null;
    })) : (s.filter(s.ADD, u), s.filter(s.REM, (c) => (a[c] & n) === r ? o[c] : null)), s.filter(s.SOURCE, (c) => u(c._index));
  }
});
const zJ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  crossfilter: o_,
  resolvefilter: a_
}, Symbol.toStringTag, { value: "Module" })), BJ = "RawCode", La = "Literal", jJ = "Property", UJ = "Identifier", qJ = "ArrayExpression", WJ = "BinaryExpression", AR = "CallExpression", HJ = "ConditionalExpression", GJ = "LogicalExpression", VJ = "MemberExpression", YJ = "ObjectExpression", XJ = "UnaryExpression";
function nr(e) {
  this.type = e;
}
nr.prototype.visit = function(e) {
  let t, n, i;
  if (e(this))
    return 1;
  for (t = KJ(this), n = 0, i = t.length; n < i; ++n)
    if (t[n].visit(e))
      return 1;
};
function KJ(e) {
  switch (e.type) {
    case qJ:
      return e.elements;
    case WJ:
    case GJ:
      return [e.left, e.right];
    case AR:
      return [e.callee].concat(e.arguments);
    case HJ:
      return [e.test, e.consequent, e.alternate];
    case VJ:
      return [e.object, e.property];
    case YJ:
      return e.properties;
    case jJ:
      return [e.key, e.value];
    case XJ:
      return [e.argument];
    case UJ:
    case La:
    case BJ:
    default:
      return [];
  }
}
var jr, se, B, sn, We, zm = 1, Ed = 2, Pa = 3, Lo = 4, Bm = 5, rl = 6, $n = 7, Sd = 8, JJ = 9;
jr = {};
jr[zm] = "Boolean";
jr[Ed] = "<end>";
jr[Pa] = "Identifier";
jr[Lo] = "Keyword";
jr[Bm] = "Null";
jr[rl] = "Numeric";
jr[$n] = "Punctuator";
jr[Sd] = "String";
jr[JJ] = "RegularExpression";
var QJ = "ArrayExpression", ZJ = "BinaryExpression", eQ = "CallExpression", tQ = "ConditionalExpression", CR = "Identifier", nQ = "Literal", iQ = "LogicalExpression", rQ = "MemberExpression", sQ = "ObjectExpression", oQ = "Property", aQ = "UnaryExpression", Tt = "Unexpected token %0", lQ = "Unexpected number", uQ = "Unexpected string", cQ = "Unexpected identifier", fQ = "Unexpected reserved word", dQ = "Unexpected end of input", Xb = "Invalid regular expression", q1 = "Invalid regular expression: missing /", $R = "Octal literals are not allowed in strict mode.", hQ = "Duplicate data property in object literal not allowed in strict mode", Ut = "ILLEGAL", If = "Disabled.", gQ = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), pQ = new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");
function jm(e, t) {
  if (!e)
    throw new Error("ASSERT: " + t);
}
function is(e) {
  return e >= 48 && e <= 57;
}
function l_(e) {
  return "0123456789abcdefABCDEF".indexOf(e) >= 0;
}
function ff(e) {
  return "01234567".indexOf(e) >= 0;
}
function mQ(e) {
  return e === 32 || e === 9 || e === 11 || e === 12 || e === 160 || e >= 5760 && [5760, 6158, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(e) >= 0;
}
function zf(e) {
  return e === 10 || e === 13 || e === 8232 || e === 8233;
}
function kd(e) {
  return e === 36 || e === 95 || // $ (dollar) and _ (underscore)
  e >= 65 && e <= 90 || // A..Z
  e >= 97 && e <= 122 || // a..z
  e === 92 || // \ (backslash)
  e >= 128 && gQ.test(String.fromCharCode(e));
}
function hp(e) {
  return e === 36 || e === 95 || // $ (dollar) and _ (underscore)
  e >= 65 && e <= 90 || // A..Z
  e >= 97 && e <= 122 || // a..z
  e >= 48 && e <= 57 || // 0..9
  e === 92 || // \ (backslash)
  e >= 128 && pQ.test(String.fromCharCode(e));
}
const yQ = {
  if: 1,
  in: 1,
  do: 1,
  var: 1,
  for: 1,
  new: 1,
  try: 1,
  let: 1,
  this: 1,
  else: 1,
  case: 1,
  void: 1,
  with: 1,
  enum: 1,
  while: 1,
  break: 1,
  catch: 1,
  throw: 1,
  const: 1,
  yield: 1,
  class: 1,
  super: 1,
  return: 1,
  typeof: 1,
  delete: 1,
  switch: 1,
  export: 1,
  import: 1,
  public: 1,
  static: 1,
  default: 1,
  finally: 1,
  extends: 1,
  package: 1,
  private: 1,
  function: 1,
  continue: 1,
  debugger: 1,
  interface: 1,
  protected: 1,
  instanceof: 1,
  implements: 1
};
function MR() {
  for (; B < sn; ) {
    const e = se.charCodeAt(B);
    if (mQ(e) || zf(e))
      ++B;
    else
      break;
  }
}
function Kb(e) {
  var t, n, i, r = 0;
  for (n = e === "u" ? 4 : 2, t = 0; t < n; ++t)
    B < sn && l_(se[B]) ? (i = se[B++], r = r * 16 + "0123456789abcdef".indexOf(i.toLowerCase())) : Pe({}, Tt, Ut);
  return String.fromCharCode(r);
}
function bQ() {
  var e, t, n, i;
  for (e = se[B], t = 0, e === "}" && Pe({}, Tt, Ut); B < sn && (e = se[B++], !!l_(e)); )
    t = t * 16 + "0123456789abcdef".indexOf(e.toLowerCase());
  return (t > 1114111 || e !== "}") && Pe({}, Tt, Ut), t <= 65535 ? String.fromCharCode(t) : (n = (t - 65536 >> 10) + 55296, i = (t - 65536 & 1023) + 56320, String.fromCharCode(n, i));
}
function FR() {
  var e, t;
  for (e = se.charCodeAt(B++), t = String.fromCharCode(e), e === 92 && (se.charCodeAt(B) !== 117 && Pe({}, Tt, Ut), ++B, e = Kb("u"), (!e || e === "\\" || !kd(e.charCodeAt(0))) && Pe({}, Tt, Ut), t = e); B < sn && (e = se.charCodeAt(B), !!hp(e)); )
    ++B, t += String.fromCharCode(e), e === 92 && (t = t.substr(0, t.length - 1), se.charCodeAt(B) !== 117 && Pe({}, Tt, Ut), ++B, e = Kb("u"), (!e || e === "\\" || !hp(e.charCodeAt(0))) && Pe({}, Tt, Ut), t += e);
  return t;
}
function vQ() {
  var e, t;
  for (e = B++; B < sn; ) {
    if (t = se.charCodeAt(B), t === 92)
      return B = e, FR();
    if (hp(t))
      ++B;
    else
      break;
  }
  return se.slice(e, B);
}
function xQ() {
  var e, t, n;
  return e = B, t = se.charCodeAt(B) === 92 ? FR() : vQ(), t.length === 1 ? n = Pa : yQ.hasOwnProperty(t) ? n = Lo : t === "null" ? n = Bm : t === "true" || t === "false" ? n = zm : n = Pa, {
    type: n,
    value: t,
    start: e,
    end: B
  };
}
function W1() {
  var e = B, t = se.charCodeAt(B), n, i = se[B], r, s, o;
  switch (t) {
    case 46:
    case 40:
    case 41:
    case 59:
    case 44:
    case 123:
    case 125:
    case 91:
    case 93:
    case 58:
    case 63:
    case 126:
      return ++B, {
        type: $n,
        value: String.fromCharCode(t),
        start: e,
        end: B
      };
    default:
      if (n = se.charCodeAt(B + 1), n === 61)
        switch (t) {
          case 43:
          case 45:
          case 47:
          case 60:
          case 62:
          case 94:
          case 124:
          case 37:
          case 38:
          case 42:
            return B += 2, {
              type: $n,
              value: String.fromCharCode(t) + String.fromCharCode(n),
              start: e,
              end: B
            };
          case 33:
          case 61:
            return B += 2, se.charCodeAt(B) === 61 && ++B, {
              type: $n,
              value: se.slice(e, B),
              start: e,
              end: B
            };
        }
  }
  if (o = se.substr(B, 4), o === ">>>=")
    return B += 4, {
      type: $n,
      value: o,
      start: e,
      end: B
    };
  if (s = o.substr(0, 3), s === ">>>" || s === "<<=" || s === ">>=")
    return B += 3, {
      type: $n,
      value: s,
      start: e,
      end: B
    };
  if (r = s.substr(0, 2), i === r[1] && "+-<>&|".indexOf(i) >= 0 || r === "=>")
    return B += 2, {
      type: $n,
      value: r,
      start: e,
      end: B
    };
  if (r === "//" && Pe({}, Tt, Ut), "<>=!+-*%&|^/".indexOf(i) >= 0)
    return ++B, {
      type: $n,
      value: i,
      start: e,
      end: B
    };
  Pe({}, Tt, Ut);
}
function wQ(e) {
  let t = "";
  for (; B < sn && l_(se[B]); )
    t += se[B++];
  return t.length === 0 && Pe({}, Tt, Ut), kd(se.charCodeAt(B)) && Pe({}, Tt, Ut), {
    type: rl,
    value: parseInt("0x" + t, 16),
    start: e,
    end: B
  };
}
function _Q(e) {
  let t = "0" + se[B++];
  for (; B < sn && ff(se[B]); )
    t += se[B++];
  return (kd(se.charCodeAt(B)) || is(se.charCodeAt(B))) && Pe({}, Tt, Ut), {
    type: rl,
    value: parseInt(t, 8),
    octal: !0,
    start: e,
    end: B
  };
}
function LC() {
  var e, t, n;
  if (n = se[B], jm(is(n.charCodeAt(0)) || n === ".", "Numeric literal must start with a decimal digit or a decimal point"), t = B, e = "", n !== ".") {
    if (e = se[B++], n = se[B], e === "0") {
      if (n === "x" || n === "X")
        return ++B, wQ(t);
      if (ff(n))
        return _Q(t);
      n && is(n.charCodeAt(0)) && Pe({}, Tt, Ut);
    }
    for (; is(se.charCodeAt(B)); )
      e += se[B++];
    n = se[B];
  }
  if (n === ".") {
    for (e += se[B++]; is(se.charCodeAt(B)); )
      e += se[B++];
    n = se[B];
  }
  if (n === "e" || n === "E")
    if (e += se[B++], n = se[B], (n === "+" || n === "-") && (e += se[B++]), is(se.charCodeAt(B)))
      for (; is(se.charCodeAt(B)); )
        e += se[B++];
    else
      Pe({}, Tt, Ut);
  return kd(se.charCodeAt(B)) && Pe({}, Tt, Ut), {
    type: rl,
    value: parseFloat(e),
    start: t,
    end: B
  };
}
function EQ() {
  var e = "", t, n, i, r, s = !1;
  for (t = se[B], jm(t === "'" || t === '"', "String literal must starts with a quote"), n = B, ++B; B < sn; )
    if (i = se[B++], i === t) {
      t = "";
      break;
    } else if (i === "\\")
      if (i = se[B++], !i || !zf(i.charCodeAt(0)))
        switch (i) {
          case "u":
          case "x":
            se[B] === "{" ? (++B, e += bQ()) : e += Kb(i);
            break;
          case "n":
            e += `
`;
            break;
          case "r":
            e += "\r";
            break;
          case "t":
            e += "	";
            break;
          case "b":
            e += "\b";
            break;
          case "f":
            e += "\f";
            break;
          case "v":
            e += "\v";
            break;
          default:
            ff(i) ? (r = "01234567".indexOf(i), r !== 0 && (s = !0), B < sn && ff(se[B]) && (s = !0, r = r * 8 + "01234567".indexOf(se[B++]), "0123".indexOf(i) >= 0 && B < sn && ff(se[B]) && (r = r * 8 + "01234567".indexOf(se[B++]))), e += String.fromCharCode(r)) : e += i;
            break;
        }
      else
        i === "\r" && se[B] === `
` && ++B;
    else {
      if (zf(i.charCodeAt(0)))
        break;
      e += i;
    }
  return t !== "" && Pe({}, Tt, Ut), {
    type: Sd,
    value: e,
    octal: s,
    start: n,
    end: B
  };
}
function SQ(e, t) {
  let n = e;
  t.indexOf("u") >= 0 && (n = n.replace(/\\u\{([0-9a-fA-F]+)\}/g, (i, r) => {
    if (parseInt(r, 16) <= 1114111)
      return "x";
    Pe({}, Xb);
  }).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "x"));
  try {
    new RegExp(n);
  } catch {
    Pe({}, Xb);
  }
  try {
    return new RegExp(e, t);
  } catch {
    return null;
  }
}
function kQ() {
  var e, t, n, i, r;
  for (e = se[B], jm(e === "/", "Regular expression literal must start with a slash"), t = se[B++], n = !1, i = !1; B < sn; )
    if (e = se[B++], t += e, e === "\\")
      e = se[B++], zf(e.charCodeAt(0)) && Pe({}, q1), t += e;
    else if (zf(e.charCodeAt(0)))
      Pe({}, q1);
    else if (n)
      e === "]" && (n = !1);
    else if (e === "/") {
      i = !0;
      break;
    } else
      e === "[" && (n = !0);
  return i || Pe({}, q1), r = t.substr(1, t.length - 2), {
    value: r,
    literal: t
  };
}
function AQ() {
  var e, t, n;
  for (t = "", n = ""; B < sn && (e = se[B], !!hp(e.charCodeAt(0))); )
    ++B, e === "\\" && B < sn ? Pe({}, Tt, Ut) : (n += e, t += e);
  return n.search(/[^gimuy]/g) >= 0 && Pe({}, Xb, n), {
    value: n,
    literal: t
  };
}
function CQ() {
  var e, t, n, i;
  return We = null, MR(), e = B, t = kQ(), n = AQ(), i = SQ(t.value, n.value), {
    literal: t.literal + n.literal,
    value: i,
    regex: {
      pattern: t.value,
      flags: n.value
    },
    start: e,
    end: B
  };
}
function $Q(e) {
  return e.type === Pa || e.type === Lo || e.type === zm || e.type === Bm;
}
function TR() {
  if (MR(), B >= sn)
    return {
      type: Ed,
      start: B,
      end: B
    };
  const e = se.charCodeAt(B);
  return kd(e) ? xQ() : e === 40 || e === 41 || e === 59 ? W1() : e === 39 || e === 34 ? EQ() : e === 46 ? is(se.charCodeAt(B + 1)) ? LC() : W1() : is(e) ? LC() : W1();
}
function Tn() {
  const e = We;
  return B = e.end, We = TR(), B = e.end, e;
}
function OR() {
  const e = B;
  We = TR(), B = e;
}
function MQ(e) {
  const t = new nr(QJ);
  return t.elements = e, t;
}
function PC(e, t, n) {
  const i = new nr(e === "||" || e === "&&" ? iQ : ZJ);
  return i.operator = e, i.left = t, i.right = n, i;
}
function FQ(e, t) {
  const n = new nr(eQ);
  return n.callee = e, n.arguments = t, n;
}
function TQ(e, t, n) {
  const i = new nr(tQ);
  return i.test = e, i.consequent = t, i.alternate = n, i;
}
function u_(e) {
  const t = new nr(CR);
  return t.name = e, t;
}
function Kc(e) {
  const t = new nr(nQ);
  return t.value = e.value, t.raw = se.slice(e.start, e.end), e.regex && (t.raw === "//" && (t.raw = "/(?:)/"), t.regex = e.regex), t;
}
function IC(e, t, n) {
  const i = new nr(rQ);
  return i.computed = e === "[", i.object = t, i.property = n, i.computed || (n.member = !0), i;
}
function OQ(e) {
  const t = new nr(sQ);
  return t.properties = e, t;
}
function zC(e, t, n) {
  const i = new nr(oQ);
  return i.key = t, i.value = n, i.kind = e, i;
}
function NQ(e, t) {
  const n = new nr(aQ);
  return n.operator = e, n.argument = t, n.prefix = !0, n;
}
function Pe(e, t) {
  var n, i = Array.prototype.slice.call(arguments, 2), r = t.replace(/%(\d)/g, (s, o) => (jm(o < i.length, "Message reference must be in range"), i[o]));
  throw n = new Error(r), n.index = B, n.description = r, n;
}
function Um(e) {
  e.type === Ed && Pe(e, dQ), e.type === rl && Pe(e, lQ), e.type === Sd && Pe(e, uQ), e.type === Pa && Pe(e, cQ), e.type === Lo && Pe(e, fQ), Pe(e, Tt, e.value);
}
function on(e) {
  const t = Tn();
  (t.type !== $n || t.value !== e) && Um(t);
}
function Qe(e) {
  return We.type === $n && We.value === e;
}
function H1(e) {
  return We.type === Lo && We.value === e;
}
function DQ() {
  const e = [];
  for (B = We.start, on("["); !Qe("]"); )
    Qe(",") ? (Tn(), e.push(null)) : (e.push(Ia()), Qe("]") || on(","));
  return Tn(), MQ(e);
}
function BC() {
  B = We.start;
  const e = Tn();
  return e.type === Sd || e.type === rl ? (e.octal && Pe(e, $R), Kc(e)) : u_(e.value);
}
function RQ() {
  var e, t, n, i;
  if (B = We.start, e = We, e.type === Pa)
    return n = BC(), on(":"), i = Ia(), zC("init", n, i);
  if (e.type === Ed || e.type === $n)
    Um(e);
  else
    return t = BC(), on(":"), i = Ia(), zC("init", t, i);
}
function LQ() {
  var e = [], t, n, i, r = {}, s = String;
  for (B = We.start, on("{"); !Qe("}"); )
    t = RQ(), t.key.type === CR ? n = t.key.name : n = s(t.key.value), i = "$" + n, Object.prototype.hasOwnProperty.call(r, i) ? Pe({}, hQ) : r[i] = !0, e.push(t), Qe("}") || on(",");
  return on("}"), OQ(e);
}
function PQ() {
  on("(");
  const e = c_();
  return on(")"), e;
}
const IQ = {
  if: 1
};
function zQ() {
  var e, t, n;
  if (Qe("("))
    return PQ();
  if (Qe("["))
    return DQ();
  if (Qe("{"))
    return LQ();
  if (e = We.type, B = We.start, e === Pa || IQ[We.value])
    n = u_(Tn().value);
  else if (e === Sd || e === rl)
    We.octal && Pe(We, $R), n = Kc(Tn());
  else {
    if (e === Lo)
      throw new Error(If);
    e === zm ? (t = Tn(), t.value = t.value === "true", n = Kc(t)) : e === Bm ? (t = Tn(), t.value = null, n = Kc(t)) : Qe("/") || Qe("/=") ? (n = Kc(CQ()), OR()) : Um(Tn());
  }
  return n;
}
function BQ() {
  const e = [];
  if (on("("), !Qe(")"))
    for (; B < sn && (e.push(Ia()), !Qe(")")); )
      on(",");
  return on(")"), e;
}
function jQ() {
  B = We.start;
  const e = Tn();
  return $Q(e) || Um(e), u_(e.value);
}
function UQ() {
  return on("."), jQ();
}
function qQ() {
  on("[");
  const e = c_();
  return on("]"), e;
}
function WQ() {
  var e, t, n;
  for (e = zQ(); ; )
    if (Qe("."))
      n = UQ(), e = IC(".", e, n);
    else if (Qe("("))
      t = BQ(), e = FQ(e, t);
    else if (Qe("["))
      n = qQ(), e = IC("[", e, n);
    else
      break;
  return e;
}
function jC() {
  const e = WQ();
  if (We.type === $n && (Qe("++") || Qe("--")))
    throw new Error(If);
  return e;
}
function Xh() {
  var e, t;
  if (We.type !== $n && We.type !== Lo)
    t = jC();
  else {
    if (Qe("++") || Qe("--"))
      throw new Error(If);
    if (Qe("+") || Qe("-") || Qe("~") || Qe("!"))
      e = Tn(), t = Xh(), t = NQ(e.value, t);
    else {
      if (H1("delete") || H1("void") || H1("typeof"))
        throw new Error(If);
      t = jC();
    }
  }
  return t;
}
function UC(e) {
  let t = 0;
  if (e.type !== $n && e.type !== Lo)
    return 0;
  switch (e.value) {
    case "||":
      t = 1;
      break;
    case "&&":
      t = 2;
      break;
    case "|":
      t = 3;
      break;
    case "^":
      t = 4;
      break;
    case "&":
      t = 5;
      break;
    case "==":
    case "!=":
    case "===":
    case "!==":
      t = 6;
      break;
    case "<":
    case ">":
    case "<=":
    case ">=":
    case "instanceof":
    case "in":
      t = 7;
      break;
    case "<<":
    case ">>":
    case ">>>":
      t = 8;
      break;
    case "+":
    case "-":
      t = 9;
      break;
    case "*":
    case "/":
    case "%":
      t = 11;
      break;
  }
  return t;
}
function HQ() {
  var e, t, n, i, r, s, o, a, l, u;
  if (e = We, l = Xh(), i = We, r = UC(i), r === 0)
    return l;
  for (i.prec = r, Tn(), t = [e, We], o = Xh(), s = [l, i, o]; (r = UC(We)) > 0; ) {
    for (; s.length > 2 && r <= s[s.length - 2].prec; )
      o = s.pop(), a = s.pop().value, l = s.pop(), t.pop(), n = PC(a, l, o), s.push(n);
    i = Tn(), i.prec = r, s.push(i), t.push(We), n = Xh(), s.push(n);
  }
  for (u = s.length - 1, n = s[u], t.pop(); u > 1; )
    t.pop(), n = PC(s[u - 1].value, s[u - 2], n), u -= 2;
  return n;
}
function Ia() {
  var e, t, n;
  return e = HQ(), Qe("?") && (Tn(), t = Ia(), on(":"), n = Ia(), e = TQ(e, t, n)), e;
}
function c_() {
  const e = Ia();
  if (Qe(","))
    throw new Error(If);
  return e;
}
function f_(e) {
  se = e, B = 0, sn = se.length, We = null, OR();
  const t = c_();
  if (We.type !== Ed)
    throw new Error("Unexpect token after expression.");
  return t;
}
var NR = {
  NaN: "NaN",
  E: "Math.E",
  LN2: "Math.LN2",
  LN10: "Math.LN10",
  LOG2E: "Math.LOG2E",
  LOG10E: "Math.LOG10E",
  PI: "Math.PI",
  SQRT1_2: "Math.SQRT1_2",
  SQRT2: "Math.SQRT2",
  MIN_VALUE: "Number.MIN_VALUE",
  MAX_VALUE: "Number.MAX_VALUE"
};
function DR(e) {
  function t(o, a, l, u) {
    let c = e(a[0]);
    return l && (c = l + "(" + c + ")", l.lastIndexOf("new ", 0) === 0 && (c = "(" + c + ")")), c + "." + o + (u < 0 ? "" : u === 0 ? "()" : "(" + a.slice(1).map(e).join(",") + ")");
  }
  function n(o, a, l) {
    return (u) => t(o, u, a, l);
  }
  const i = "new Date", r = "String", s = "RegExp";
  return {
    // MATH functions
    isNaN: "Number.isNaN",
    isFinite: "Number.isFinite",
    abs: "Math.abs",
    acos: "Math.acos",
    asin: "Math.asin",
    atan: "Math.atan",
    atan2: "Math.atan2",
    ceil: "Math.ceil",
    cos: "Math.cos",
    exp: "Math.exp",
    floor: "Math.floor",
    hypot: "Math.hypot",
    log: "Math.log",
    max: "Math.max",
    min: "Math.min",
    pow: "Math.pow",
    random: "Math.random",
    round: "Math.round",
    sin: "Math.sin",
    sqrt: "Math.sqrt",
    tan: "Math.tan",
    clamp: function(o) {
      o.length < 3 && j("Missing arguments to clamp function."), o.length > 3 && j("Too many arguments to clamp function.");
      const a = o.map(e);
      return "Math.max(" + a[1] + ", Math.min(" + a[2] + "," + a[0] + "))";
    },
    // DATE functions
    now: "Date.now",
    utc: "Date.UTC",
    datetime: i,
    date: n("getDate", i, 0),
    day: n("getDay", i, 0),
    year: n("getFullYear", i, 0),
    month: n("getMonth", i, 0),
    hours: n("getHours", i, 0),
    minutes: n("getMinutes", i, 0),
    seconds: n("getSeconds", i, 0),
    milliseconds: n("getMilliseconds", i, 0),
    time: n("getTime", i, 0),
    timezoneoffset: n("getTimezoneOffset", i, 0),
    utcdate: n("getUTCDate", i, 0),
    utcday: n("getUTCDay", i, 0),
    utcyear: n("getUTCFullYear", i, 0),
    utcmonth: n("getUTCMonth", i, 0),
    utchours: n("getUTCHours", i, 0),
    utcminutes: n("getUTCMinutes", i, 0),
    utcseconds: n("getUTCSeconds", i, 0),
    utcmilliseconds: n("getUTCMilliseconds", i, 0),
    // sequence functions
    length: n("length", null, -1),
    // STRING functions
    parseFloat: "parseFloat",
    parseInt: "parseInt",
    upper: n("toUpperCase", r, 0),
    lower: n("toLowerCase", r, 0),
    substring: n("substring", r),
    split: n("split", r),
    trim: n("trim", r, 0),
    // REGEXP functions
    regexp: s,
    test: n("test", s),
    // Control Flow functions
    if: function(o) {
      o.length < 3 && j("Missing arguments to if function."), o.length > 3 && j("Too many arguments to if function.");
      const a = o.map(e);
      return "(" + a[0] + "?" + a[1] + ":" + a[2] + ")";
    }
  };
}
function GQ(e) {
  const t = e && e.length - 1;
  return t && (e[0] === '"' && e[t] === '"' || e[0] === "'" && e[t] === "'") ? e.slice(1, -1) : e;
}
function RR(e) {
  e = e || {};
  const t = e.allowed ? Ji(e.allowed) : {}, n = e.forbidden ? Ji(e.forbidden) : {}, i = e.constants || NR, r = (e.functions || DR)(f), s = e.globalvar, o = e.fieldvar, a = Ee(s) ? s : (g) => `${s}["${g}"]`;
  let l = {}, u = {}, c = 0;
  function f(g) {
    if (te(g))
      return g;
    const p = d[g.type];
    return p == null && j("Unsupported type: " + g.type), p(g);
  }
  const d = {
    Literal: (g) => g.raw,
    Identifier: (g) => {
      const p = g.name;
      return c > 0 ? p : ce(n, p) ? j("Illegal identifier: " + p) : ce(i, p) ? i[p] : ce(t, p) ? p : (l[p] = 1, a(p));
    },
    MemberExpression: (g) => {
      const p = !g.computed, m = f(g.object);
      p && (c += 1);
      const y = f(g.property);
      return m === o && (u[GQ(y)] = 1), p && (c -= 1), m + (p ? "." + y : "[" + y + "]");
    },
    CallExpression: (g) => {
      g.callee.type !== "Identifier" && j("Illegal callee type: " + g.callee.type);
      const p = g.callee.name, m = g.arguments, y = ce(r, p) && r[p];
      return y || j("Unrecognized function: " + p), Ee(y) ? y(m) : y + "(" + m.map(f).join(",") + ")";
    },
    ArrayExpression: (g) => "[" + g.elements.map(f).join(",") + "]",
    BinaryExpression: (g) => "(" + f(g.left) + " " + g.operator + " " + f(g.right) + ")",
    UnaryExpression: (g) => "(" + g.operator + f(g.argument) + ")",
    ConditionalExpression: (g) => "(" + f(g.test) + "?" + f(g.consequent) + ":" + f(g.alternate) + ")",
    LogicalExpression: (g) => "(" + f(g.left) + g.operator + f(g.right) + ")",
    ObjectExpression: (g) => "{" + g.properties.map(f).join(",") + "}",
    Property: (g) => {
      c += 1;
      const p = f(g.key);
      return c -= 1, p + ":" + f(g.value);
    }
  };
  function h(g) {
    const p = {
      code: f(g),
      globals: Object.keys(l),
      fields: Object.keys(u)
    };
    return l = {}, u = {}, p;
  }
  return h.functions = r, h.constants = i, h;
}
const qC = Symbol("vega_selection_getter");
function LR(e) {
  return (!e.getter || !e.getter[qC]) && (e.getter = _i(e.field), e.getter[qC] = !0), e.getter;
}
const d_ = "intersect", WC = "union", VQ = "vlMulti", YQ = "vlPoint", HC = "or", XQ = "and", mr = "_vgsid_", Bf = _i(mr), KQ = "E", JQ = "R", QQ = "R-E", ZQ = "R-LE", eZ = "R-RE", gp = "index:unit";
function GC(e, t) {
  for (var n = t.fields, i = t.values, r = n.length, s = 0, o, a; s < r; ++s)
    if (a = n[s], o = LR(a)(e), so(o) && (o = Zt(o)), so(i[s]) && (i[s] = Zt(i[s])), U(i[s]) && so(i[s][0]) && (i[s] = i[s].map(Zt)), a.type === KQ) {
      if (U(i[s]) ? i[s].indexOf(o) < 0 : o !== i[s])
        return !1;
    } else if (a.type === JQ) {
      if (!Dl(o, i[s]))
        return !1;
    } else if (a.type === eZ) {
      if (!Dl(o, i[s], !0, !1))
        return !1;
    } else if (a.type === QQ) {
      if (!Dl(o, i[s], !1, !1))
        return !1;
    } else if (a.type === ZQ && !Dl(o, i[s], !1, !0))
      return !1;
  return !0;
}
function tZ(e, t, n) {
  for (var i = this.context.data[e], r = i ? i.values.value : [], s = i ? i[gp] && i[gp].value : void 0, o = n === d_, a = r.length, l = 0, u, c, f, d, h; l < a; ++l)
    if (u = r[l], s && o) {
      if (c = c || {}, f = c[d = u.unit] || 0, f === -1)
        continue;
      if (h = GC(t, u), c[d] = h ? -1 : ++f, h && s.size === 1)
        return !0;
      if (!h && f === s.get(d).count)
        return !1;
    } else if (h = GC(t, u), o ^ h)
      return h;
  return a && o;
}
const PR = Pu(Bf), nZ = PR.left, iZ = PR.right;
function rZ(e, t, n) {
  const i = this.context.data[e], r = i ? i.values.value : [], s = i ? i[gp] && i[gp].value : void 0, o = n === d_, a = Bf(t), l = nZ(r, a);
  if (l === r.length || Bf(r[l]) !== a)
    return !1;
  if (s && o) {
    if (s.size === 1)
      return !0;
    if (iZ(r, a) - l < s.size)
      return !1;
  }
  return !0;
}
function sZ(e, t) {
  return e.map((n) => we(t.fields ? {
    values: t.fields.map((i) => LR(i)(n.datum))
  } : {
    [mr]: Bf(n.datum)
  }, t));
}
function oZ(e, t, n, i) {
  for (var r = this.context.data[e], s = r ? r.values.value : [], o = {}, a = {}, l = {}, u, c, f, d, h, g, p, m, y, b, v = s.length, _ = 0, x, S; _ < v; ++_)
    if (u = s[_], d = u.unit, c = u.fields, f = u.values, c && f) {
      for (x = 0, S = c.length; x < S; ++x)
        h = c[x], p = o[h.field] || (o[h.field] = {}), m = p[d] || (p[d] = []), l[h.field] = y = h.type.charAt(0), b = G1[`${y}_union`], p[d] = b(m, ee(f[x]));
      n && (m = a[d] || (a[d] = []), m.push(ee(f).reduce((E, C, $) => (E[c[$].field] = C, E), {})));
    } else
      h = mr, g = Bf(u), p = o[h] || (o[h] = {}), m = p[d] || (p[d] = []), m.push(g), n && (m = a[d] || (a[d] = []), m.push({
        [mr]: g
      }));
  if (t = t || WC, o[mr] ? o[mr] = G1[`${mr}_${t}`](...Object.values(o[mr])) : Object.keys(o).forEach((E) => {
    o[E] = Object.keys(o[E]).map((C) => o[E][C]).reduce((C, $) => C === void 0 ? $ : G1[`${l[E]}_${t}`](C, $));
  }), s = Object.keys(a), n && s.length) {
    const E = i ? YQ : VQ;
    o[E] = t === WC ? {
      [HC]: s.reduce((C, $) => (C.push(...a[$]), C), [])
    } : {
      [XQ]: s.map((C) => ({
        [HC]: a[C]
      }))
    };
  }
  return o;
}
var G1 = {
  [`${mr}_union`]: c9,
  [`${mr}_intersect`]: l9,
  E_union: function(e, t) {
    if (!e.length)
      return t;
    for (var n = 0, i = t.length; n < i; ++n)
      e.indexOf(t[n]) < 0 && e.push(t[n]);
    return e;
  },
  E_intersect: function(e, t) {
    return e.length ? e.filter((n) => t.indexOf(n) >= 0) : t;
  },
  R_union: function(e, t) {
    var n = Zt(t[0]), i = Zt(t[1]);
    return n > i && (n = t[1], i = t[0]), e.length ? (e[0] > n && (e[0] = n), e[1] < i && (e[1] = i), e) : [n, i];
  },
  R_intersect: function(e, t) {
    var n = Zt(t[0]), i = Zt(t[1]);
    return n > i && (n = t[1], i = t[0]), e.length ? i < e[0] || e[1] < n ? [] : (e[0] < n && (e[0] = n), e[1] > i && (e[1] = i), e) : [n, i];
  }
};
const aZ = ":", lZ = "@";
function h_(e, t, n, i) {
  t[0].type !== La && j("First argument to selection functions must be a string literal.");
  const r = t[0].value, s = t.length >= 2 && Te(t).value, o = "unit", a = lZ + o, l = aZ + r;
  s === d_ && !ce(i, a) && (i[a] = n.getData(r).indataRef(n, o)), ce(i, l) || (i[l] = n.getData(r).tuplesRef());
}
function IR(e) {
  const t = this.context.data[e];
  return t ? t.values.value : [];
}
function uZ(e, t, n) {
  const i = this.context.data[e]["index:" + t], r = i ? i.value.get(n) : void 0;
  return r && r.count;
}
function cZ(e, t) {
  const n = this.context.dataflow, i = this.context.data[e], r = i.input;
  return n.pulse(r, n.changeset().remove(Ei).insert(t)), 1;
}
function fZ(e, t, n) {
  if (e) {
    const i = this.context.dataflow, r = e.mark.source;
    i.pulse(r, i.changeset().encode(e, t));
  }
  return n !== void 0 ? n : e;
}
const Ad = (e) => function(t, n) {
  return this.context.dataflow.locale()[e](n)(t);
}, dZ = Ad("format"), zR = Ad("timeFormat"), hZ = Ad("utcFormat"), gZ = Ad("timeParse"), pZ = Ad("utcParse"), ph = new Date(2e3, 0, 1);
function qm(e, t, n) {
  return !Number.isInteger(e) || !Number.isInteger(t) ? "" : (ph.setYear(2e3), ph.setMonth(e), ph.setDate(t), zR.call(this, ph, n));
}
function mZ(e) {
  return qm.call(this, e, 1, "%B");
}
function yZ(e) {
  return qm.call(this, e, 1, "%b");
}
function bZ(e) {
  return qm.call(this, 0, 2 + e, "%A");
}
function vZ(e) {
  return qm.call(this, 0, 2 + e, "%a");
}
const xZ = ":", wZ = "@", Jb = "%", BR = "$";
function g_(e, t, n, i) {
  t[0].type !== La && j("First argument to data functions must be a string literal.");
  const r = t[0].value, s = xZ + r;
  if (!ce(s, i))
    try {
      i[s] = n.getData(r).tuplesRef();
    } catch {
    }
}
function _Z(e, t, n, i) {
  t[0].type !== La && j("First argument to indata must be a string literal."), t[1].type !== La && j("Second argument to indata must be a string literal.");
  const r = t[0].value, s = t[1].value, o = wZ + s;
  ce(o, i) || (i[o] = n.getData(r).indataRef(n, s));
}
function vn(e, t, n, i) {
  if (t[0].type === La)
    VC(n, i, t[0].value);
  else
    for (e in n.scales)
      VC(n, i, e);
}
function VC(e, t, n) {
  const i = Jb + n;
  if (!ce(t, i))
    try {
      t[i] = e.scaleRef(n);
    } catch {
    }
}
function Ur(e, t) {
  if (Ee(e))
    return e;
  if (te(e)) {
    const n = t.scales[e];
    return n && NU(n.value) ? n.value : void 0;
  }
}
function EZ(e, t, n) {
  t.__bandwidth = (r) => r && r.bandwidth ? r.bandwidth() : 0, n._bandwidth = vn, n._range = vn, n._scale = vn;
  const i = (r) => "_[" + (r.type === La ? X(Jb + r.value) : X(Jb) + "+" + e(r)) + "]";
  return {
    _bandwidth: (r) => `this.__bandwidth(${i(r[0])})`,
    _range: (r) => `${i(r[0])}.range()`,
    _scale: (r) => `${i(r[0])}(${e(r[1])})`
  };
}
function p_(e, t) {
  return function(n, i, r) {
    if (n) {
      const s = Ur(n, (r || this).context);
      return s && s.path[e](i);
    } else
      return t(i);
  };
}
const SZ = p_("area", YG), kZ = p_("bounds", QG), AZ = p_("centroid", rV);
function CZ(e, t) {
  const n = Ur(e, (t || this).context);
  return n && n.scale();
}
function $Z(e) {
  const t = this.context.group;
  let n = !1;
  if (t)
    for (; e; ) {
      if (e === t) {
        n = !0;
        break;
      }
      e = e.mark.group;
    }
  return n;
}
function m_(e, t, n) {
  try {
    e[t].apply(e, ["EXPRESSION"].concat([].slice.call(n)));
  } catch (i) {
    e.warn(i);
  }
  return n[n.length - 1];
}
function MZ() {
  return m_(this.context.dataflow, "warn", arguments);
}
function FZ() {
  return m_(this.context.dataflow, "info", arguments);
}
function TZ() {
  return m_(this.context.dataflow, "debug", arguments);
}
function V1(e) {
  const t = e / 255;
  return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
}
function Qb(e) {
  const t = mo(e), n = V1(t.r), i = V1(t.g), r = V1(t.b);
  return 0.2126 * n + 0.7152 * i + 0.0722 * r;
}
function OZ(e, t) {
  const n = Qb(e), i = Qb(t), r = Math.max(n, i), s = Math.min(n, i);
  return (r + 0.05) / (s + 0.05);
}
function NZ() {
  const e = [].slice.call(arguments);
  return e.unshift({}), we(...e);
}
function jR(e, t) {
  return e === t || e !== e && t !== t ? !0 : U(e) ? U(t) && e.length === t.length ? DZ(e, t) : !1 : ne(e) && ne(t) ? UR(e, t) : !1;
}
function DZ(e, t) {
  for (let n = 0, i = e.length; n < i; ++n)
    if (!jR(e[n], t[n]))
      return !1;
  return !0;
}
function UR(e, t) {
  for (const n in e)
    if (!jR(e[n], t[n]))
      return !1;
  return !0;
}
function YC(e) {
  return (t) => UR(e, t);
}
function RZ(e, t, n, i, r, s) {
  const o = this.context.dataflow, a = this.context.data[e], l = a.input, u = o.stamp();
  let c = a.changes, f, d;
  if (o._trigger === !1 || !(l.value.length || t || i))
    return 0;
  if ((!c || c.stamp < u) && (a.changes = c = o.changeset(), c.stamp = u, o.runAfter(() => {
    a.modified = !0, o.pulse(l, c).run();
  }, !0, 1)), n && (f = n === !0 ? Ei : U(n) || Jp(n) ? n : YC(n), c.remove(f)), t && c.insert(t), i && (f = YC(i), l.value.some(f) ? c.remove(f) : c.insert(i)), r)
    for (d in s)
      c.modify(r, d, s[d]);
  return 1;
}
function LZ(e) {
  const t = e.touches, n = t[0].clientX - t[1].clientX, i = t[0].clientY - t[1].clientY;
  return Math.hypot(n, i);
}
function PZ(e) {
  const t = e.touches;
  return Math.atan2(t[0].clientY - t[1].clientY, t[0].clientX - t[1].clientX);
}
const XC = {};
function IZ(e, t) {
  const n = XC[t] || (XC[t] = _i(t));
  return U(e) ? e.map(n) : n(e);
}
function y_(e) {
  return U(e) || ArrayBuffer.isView(e) ? e : null;
}
function b_(e) {
  return y_(e) || (te(e) ? e : null);
}
function zZ(e) {
  for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
    n[i - 1] = arguments[i];
  return y_(e).join(...n);
}
function BZ(e) {
  for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
    n[i - 1] = arguments[i];
  return b_(e).indexOf(...n);
}
function jZ(e) {
  for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
    n[i - 1] = arguments[i];
  return b_(e).lastIndexOf(...n);
}
function UZ(e) {
  for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
    n[i - 1] = arguments[i];
  return b_(e).slice(...n);
}
function qZ(e, t, n) {
  return Ee(n) && j("Function argument passed to replace."), String(e).replace(t, n);
}
function WZ(e) {
  return y_(e).slice().reverse();
}
function HZ(e, t, n) {
  return C2(e || 0, t || 0, n || 0);
}
function GZ(e, t) {
  const n = Ur(e, (t || this).context);
  return n && n.bandwidth ? n.bandwidth() : 0;
}
function VZ(e, t) {
  const n = Ur(e, (t || this).context);
  return n ? n.copy() : void 0;
}
function YZ(e, t) {
  const n = Ur(e, (t || this).context);
  return n ? n.domain() : [];
}
function XZ(e, t, n) {
  const i = Ur(e, (n || this).context);
  return i ? U(t) ? (i.invertRange || i.invert)(t) : (i.invert || i.invertExtent)(t) : void 0;
}
function KZ(e, t) {
  const n = Ur(e, (t || this).context);
  return n && n.range ? n.range() : [];
}
function JZ(e, t, n) {
  const i = Ur(e, (n || this).context);
  return i ? i(t) : void 0;
}
function QZ(e, t, n, i, r) {
  e = Ur(e, (r || this).context);
  const s = LO(t, n);
  let o = e.domain(), a = o[0], l = Te(o), u = an;
  return l - a ? u = SO(e, a, l) : e = (e.interpolator ? ze("sequential")().interpolator(e.interpolator()) : ze("linear")().interpolate(e.interpolate()).range(e.range())).domain([a = 0, l = 1]), e.ticks && (o = e.ticks(+i || 15), a !== o[0] && o.unshift(a), l !== Te(o) && o.push(l)), o.forEach((c) => s.stop(u(c), e(c))), s;
}
function ZZ(e, t, n) {
  const i = Ur(e, (n || this).context);
  return function(r) {
    return i ? i.path.context(r)(t) : "";
  };
}
function eee(e) {
  let t = null;
  return function(n) {
    return n ? $f(n, t = t || cu(e)) : e;
  };
}
const qR = (e) => e.data;
function WR(e, t) {
  const n = IR.call(t, e);
  return n.root && n.root.lookup || {};
}
function tee(e, t, n) {
  const i = WR(e, this), r = i[t], s = i[n];
  return r && s ? r.path(s).map(qR) : void 0;
}
function nee(e, t) {
  const n = WR(e, this)[t];
  return n ? n.ancestors().map(qR) : void 0;
}
const HR = () => typeof window < "u" && window || null;
function iee() {
  const e = HR();
  return e ? e.screen : {};
}
function ree() {
  const e = HR();
  return e ? [e.innerWidth, e.innerHeight] : [void 0, void 0];
}
function see() {
  const e = this.context.dataflow, t = e.container && e.container();
  return t ? [t.clientWidth, t.clientHeight] : [void 0, void 0];
}
function GR(e, t, n) {
  if (!e)
    return [];
  const [i, r] = e, s = new pt().set(i[0], i[1], r[0], r[1]), o = n || this.context.dataflow.scenegraph().root;
  return MN(o, s, oee(t));
}
function oee(e) {
  let t = null;
  if (e) {
    const n = ee(e.marktype), i = ee(e.markname);
    t = (r) => (!n.length || n.some((s) => r.marktype === s)) && (!i.length || i.some((s) => r.name === s));
  }
  return t;
}
function aee(e, t, n) {
  let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 5;
  e = ee(e);
  const r = e[e.length - 1];
  return r === void 0 || Math.hypot(r[0] - t, r[1] - n) > i ? [...e, [t, n]] : e;
}
function lee(e) {
  return ee(e).reduce((t, n, i) => {
    let [r, s] = n;
    return t += i == 0 ? `M ${r},${s} ` : i === e.length - 1 ? " Z" : `L ${r},${s} `;
  }, "");
}
function uee(e, t, n) {
  const {
    x: i,
    y: r,
    mark: s
  } = n, o = new pt().set(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER);
  for (const [l, u] of t)
    l < o.x1 && (o.x1 = l), l > o.x2 && (o.x2 = l), u < o.y1 && (o.y1 = u), u > o.y2 && (o.y2 = u);
  return o.translate(i, r), GR([[o.x1, o.y1], [o.x2, o.y2]], e, s).filter((l) => cee(l.x, l.y, t));
}
function cee(e, t, n) {
  let i = 0;
  for (let r = 0, s = n.length - 1; r < n.length; s = r++) {
    const [o, a] = n[s], [l, u] = n[r];
    u > t != a > t && e < (o - l) * (t - u) / (a - u) + l && i++;
  }
  return i & 1;
}
const jf = {
  random() {
    return ki();
  },
  // override default
  cumulativeNormal: nm,
  cumulativeLogNormal: Cx,
  cumulativeUniform: Tx,
  densityNormal: _x,
  densityLogNormal: Ax,
  densityUniform: Fx,
  quantileNormal: im,
  quantileLogNormal: $x,
  quantileUniform: Ox,
  sampleNormal: tm,
  sampleLogNormal: kx,
  sampleUniform: Mx,
  isArray: U,
  isBoolean: To,
  isDate: so,
  isDefined(e) {
    return e !== void 0;
  },
  isNumber: Re,
  isObject: ne,
  isRegExp: iF,
  isString: te,
  isTuple: Jp,
  isValid(e) {
    return e != null && e === e;
  },
  toBoolean: tx,
  toDate(e) {
    return nx(e);
  },
  // suppress extra arguments
  toNumber: Zt,
  toString: ix,
  indexof: BZ,
  join: zZ,
  lastindexof: jZ,
  replace: qZ,
  reverse: WZ,
  slice: UZ,
  flush: tF,
  lerp: rF,
  merge: NZ,
  pad: aF,
  peek: Te,
  pluck: IZ,
  span: td,
  inrange: Dl,
  truncate: lF,
  rgb: mo,
  lab: wg,
  hcl: _g,
  hsl: vg,
  luminance: Qb,
  contrast: OZ,
  sequence: Jn,
  format: dZ,
  utcFormat: hZ,
  utcParse: pZ,
  utcOffset: jF,
  utcSequence: WF,
  timeFormat: zR,
  timeParse: gZ,
  timeOffset: BF,
  timeSequence: qF,
  timeUnitSpecifier: MF,
  monthFormat: mZ,
  monthAbbrevFormat: yZ,
  dayFormat: bZ,
  dayAbbrevFormat: vZ,
  quarter: J3,
  utcquarter: Q3,
  week: TF,
  utcweek: DF,
  dayofyear: FF,
  utcdayofyear: NF,
  warn: MZ,
  info: FZ,
  debug: TZ,
  extent(e) {
    return $r(e);
  },
  // suppress extra arguments
  inScope: $Z,
  intersect: GR,
  clampRange: Z3,
  pinchDistance: LZ,
  pinchAngle: PZ,
  screen: iee,
  containerSize: see,
  windowSize: ree,
  bandspace: HZ,
  setdata: cZ,
  pathShape: eee,
  panLinear: V3,
  panLog: Y3,
  panPow: X3,
  panSymlog: K3,
  zoomLinear: Xv,
  zoomLog: Kv,
  zoomPow: og,
  zoomSymlog: Jv,
  encode: fZ,
  modify: RZ,
  lassoAppend: aee,
  lassoPath: lee,
  intersectLasso: uee
}, fee = ["view", "item", "group", "xy", "x", "y"], dee = "event.vega.", VR = "this.", v_ = {}, YR = {
  forbidden: ["_"],
  allowed: ["datum", "event", "item"],
  fieldvar: "datum",
  globalvar: (e) => `_[${X(BR + e)}]`,
  functions: hee,
  constants: NR,
  visitors: v_
}, Zb = RR(YR);
function hee(e) {
  const t = DR(e);
  fee.forEach((n) => t[n] = dee + n);
  for (const n in jf)
    t[n] = VR + n;
  return we(t, EZ(e, jf, v_)), t;
}
function gt(e, t, n) {
  return arguments.length === 1 ? jf[e] : (jf[e] = t, n && (v_[e] = n), Zb && (Zb.functions[e] = VR + e), this);
}
gt("bandwidth", GZ, vn);
gt("copy", VZ, vn);
gt("domain", YZ, vn);
gt("range", KZ, vn);
gt("invert", XZ, vn);
gt("scale", JZ, vn);
gt("gradient", QZ, vn);
gt("geoArea", SZ, vn);
gt("geoBounds", kZ, vn);
gt("geoCentroid", AZ, vn);
gt("geoShape", ZZ, vn);
gt("geoScale", CZ, vn);
gt("indata", uZ, _Z);
gt("data", IR, g_);
gt("treePath", tee, g_);
gt("treeAncestors", nee, g_);
gt("vlSelectionTest", tZ, h_);
gt("vlSelectionIdTest", rZ, h_);
gt("vlSelectionResolve", oZ, h_);
gt("vlSelectionTuples", sZ);
function Nr(e, t) {
  const n = {};
  let i;
  try {
    e = te(e) ? e : X(e) + "", i = f_(e);
  } catch {
    j("Expression parse error: " + e);
  }
  i.visit((s) => {
    if (s.type !== AR)
      return;
    const o = s.callee.name, a = YR.visitors[o];
    a && a(o, s.arguments, t, n);
  });
  const r = Zb(i);
  return r.globals.forEach((s) => {
    const o = BR + s;
    !ce(n, o) && t.getSignal(s) && (n[o] = t.signalRef(s));
  }), {
    $expr: we({
      code: r.code
    }, t.options.ast ? {
      ast: i
    } : null),
    $fields: r.fields,
    $params: n
  };
}
function gee(e) {
  const t = this, n = e.operators || [];
  return e.background && (t.background = e.background), e.eventConfig && (t.eventConfig = e.eventConfig), e.locale && (t.locale = e.locale), n.forEach((i) => t.parseOperator(i)), n.forEach((i) => t.parseOperatorParameters(i)), (e.streams || []).forEach((i) => t.parseStream(i)), (e.updates || []).forEach((i) => t.parseUpdate(i)), t.resolve();
}
const pee = Ji(["rule"]), KC = Ji(["group", "image", "rect"]);
function mee(e, t) {
  let n = "";
  return pee[t] || (e.x2 && (e.x ? (KC[t] && (n += "if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"), n += "o.width=o.x2-o.x;") : n += "o.x=o.x2-(o.width||0);"), e.xc && (n += "o.x=o.xc-(o.width||0)/2;"), e.y2 && (e.y ? (KC[t] && (n += "if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"), n += "o.height=o.y2-o.y;") : n += "o.y=o.y2-(o.height||0);"), e.yc && (n += "o.y=o.yc-(o.height||0)/2;")), n;
}
function x_(e) {
  return (e + "").toLowerCase();
}
function yee(e) {
  return x_(e) === "operator";
}
function bee(e) {
  return x_(e) === "collect";
}
function bc(e, t, n) {
  n.endsWith(";") || (n = "return(" + n + ");");
  const i = Function(...t.concat(n));
  return e && e.functions ? i.bind(e.functions) : i;
}
function vee(e, t, n, i) {
  return `((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n}
  : (u > v || v == null) && u != null ? ${i}
  : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n}
  : v !== v && u === u ? ${i} : `;
}
var xee = {
  /**
   * Parse an expression used to update an operator value.
   */
  operator: (e, t) => bc(e, ["_"], t.code),
  /**
   * Parse an expression provided as an operator parameter value.
   */
  parameter: (e, t) => bc(e, ["datum", "_"], t.code),
  /**
   * Parse an expression applied to an event stream.
   */
  event: (e, t) => bc(e, ["event"], t.code),
  /**
   * Parse an expression used to handle an event-driven operator update.
   */
  handler: (e, t) => {
    const n = `var datum=event.item&&event.item.datum;return ${t.code};`;
    return bc(e, ["_", "event"], n);
  },
  /**
   * Parse an expression that performs visual encoding.
   */
  encode: (e, t) => {
    const {
      marktype: n,
      channels: i
    } = t;
    let r = "var o=item,datum=o.datum,m=0,$;";
    for (const s in i) {
      const o = "o[" + X(s) + "]";
      r += `$=${i[s].code};if(${o}!==$)${o}=$,m=1;`;
    }
    return r += mee(i, n), r += "return m;", bc(e, ["item", "_"], r);
  },
  /**
   * Optimized code generators for access and comparison.
   */
  codegen: {
    get(e) {
      const t = `[${e.map(X).join("][")}]`, n = Function("_", `return _${t};`);
      return n.path = t, n;
    },
    comparator(e, t) {
      let n;
      const i = (s, o) => {
        const a = t[o];
        let l, u;
        return s.path ? (l = `a${s.path}`, u = `b${s.path}`) : ((n = n || {})["f" + o] = s, l = `this.f${o}(a)`, u = `this.f${o}(b)`), vee(l, u, -a, a);
      }, r = Function("a", "b", "var u, v; return " + e.map(i).join("") + "0;");
      return n ? r.bind(n) : r;
    }
  }
};
function wee(e) {
  const t = this;
  yee(e.type) || !e.type ? t.operator(e, e.update ? t.operatorExpression(e.update) : null) : t.transform(e, e.type);
}
function _ee(e) {
  const t = this;
  if (e.params) {
    const n = t.get(e.id);
    n || j("Invalid operator id: " + e.id), t.dataflow.connect(n, n.parameters(t.parseParameters(e.params), e.react, e.initonly));
  }
}
function Eee(e, t) {
  t = t || {};
  const n = this;
  for (const i in e) {
    const r = e[i];
    t[i] = U(r) ? r.map((s) => JC(s, n, t)) : JC(r, n, t);
  }
  return t;
}
function JC(e, t, n) {
  if (!e || !ne(e))
    return e;
  for (let i = 0, r = QC.length, s; i < r; ++i)
    if (s = QC[i], ce(e, s.key))
      return s.parse(e, t, n);
  return e;
}
var QC = [{
  key: "$ref",
  parse: See
}, {
  key: "$key",
  parse: Aee
}, {
  key: "$expr",
  parse: kee
}, {
  key: "$field",
  parse: Cee
}, {
  key: "$encode",
  parse: Mee
}, {
  key: "$compare",
  parse: $ee
}, {
  key: "$context",
  parse: Fee
}, {
  key: "$subflow",
  parse: Tee
}, {
  key: "$tupleid",
  parse: Oee
}];
function See(e, t) {
  return t.get(e.$ref) || j("Operator not defined: " + e.$ref);
}
function kee(e, t, n) {
  e.$params && t.parseParameters(e.$params, n);
  const i = "e:" + e.$expr.code;
  return t.fn[i] || (t.fn[i] = Wn(t.parameterExpression(e.$expr), e.$fields));
}
function Aee(e, t) {
  const n = "k:" + e.$key + "_" + !!e.$flat;
  return t.fn[n] || (t.fn[n] = ex(e.$key, e.$flat, t.expr.codegen));
}
function Cee(e, t) {
  if (!e.$field)
    return null;
  const n = "f:" + e.$field + "_" + e.$name;
  return t.fn[n] || (t.fn[n] = _i(e.$field, e.$name, t.expr.codegen));
}
function $ee(e, t) {
  const n = "c:" + e.$compare + "_" + e.$order, i = ee(e.$compare).map((r) => r && r.$tupleid ? le : r);
  return t.fn[n] || (t.fn[n] = Qv(i, e.$order, t.expr.codegen));
}
function Mee(e, t) {
  const n = e.$encode, i = {};
  for (const r in n) {
    const s = n[r];
    i[r] = Wn(t.encodeExpression(s.$expr), s.$fields), i[r].output = s.$output;
  }
  return i;
}
function Fee(e, t) {
  return t;
}
function Tee(e, t) {
  const n = e.$subflow;
  return function(i, r, s) {
    const o = t.fork().parse(n), a = o.get(n.operators[0].id), l = o.signals.parent;
    return l && l.set(s), a.detachSubflow = () => t.detach(o), a;
  };
}
function Oee() {
  return le;
}
function Nee(e) {
  var t = this, n = e.filter != null ? t.eventExpression(e.filter) : void 0, i = e.stream != null ? t.get(e.stream) : void 0, r;
  e.source ? i = t.events(e.source, e.type, n) : e.merge && (r = e.merge.map((s) => t.get(s)), i = r[0].merge.apply(r[0], r.slice(1))), e.between && (r = e.between.map((s) => t.get(s)), i = i.between(r[0], r[1])), e.filter && (i = i.filter(n)), e.throttle != null && (i = i.throttle(+e.throttle)), e.debounce != null && (i = i.debounce(+e.debounce)), i == null && j("Invalid stream definition: " + JSON.stringify(e)), e.consume && i.consume(!0), t.stream(e, i);
}
function Dee(e) {
  var t = this, n = ne(n = e.source) ? n.$ref : n, i = t.get(n), r = null, s = e.update, o = void 0;
  i || j("Source not defined: " + e.source), r = e.target && e.target.$expr ? t.eventExpression(e.target.$expr) : t.get(e.target), s && s.$expr && (s.$params && (o = t.parseParameters(s.$params)), s = t.handlerExpression(s.$expr)), t.update(e, i, r, s, o);
}
const Ree = {
  skip: !0
};
function Lee(e) {
  var t = this, n = {};
  if (e.signals) {
    var i = n.signals = {};
    Object.keys(t.signals).forEach((s) => {
      const o = t.signals[s];
      e.signals(s, o) && (i[s] = o.value);
    });
  }
  if (e.data) {
    var r = n.data = {};
    Object.keys(t.data).forEach((s) => {
      const o = t.data[s];
      e.data(s, o) && (r[s] = o.input.value);
    });
  }
  return t.subcontext && e.recurse !== !1 && (n.subcontext = t.subcontext.map((s) => s.getState(e))), n;
}
function Pee(e) {
  var t = this, n = t.dataflow, i = e.data, r = e.signals;
  Object.keys(r || {}).forEach((s) => {
    n.update(t.signals[s], r[s], Ree);
  }), Object.keys(i || {}).forEach((s) => {
    n.pulse(t.data[s].input, n.changeset().remove(Ei).insert(i[s]));
  }), (e.subcontext || []).forEach((s, o) => {
    const a = t.subcontext[o];
    a && a.setState(s);
  });
}
function XR(e, t, n, i) {
  return new KR(e, t, n, i);
}
function KR(e, t, n, i) {
  this.dataflow = e, this.transforms = t, this.events = e.events.bind(e), this.expr = i || xee, this.signals = {}, this.scales = {}, this.nodes = {}, this.data = {}, this.fn = {}, n && (this.functions = Object.create(n), this.functions.context = this);
}
function ZC(e) {
  this.dataflow = e.dataflow, this.transforms = e.transforms, this.events = e.events, this.expr = e.expr, this.signals = Object.create(e.signals), this.scales = Object.create(e.scales), this.nodes = Object.create(e.nodes), this.data = Object.create(e.data), this.fn = Object.create(e.fn), e.functions && (this.functions = Object.create(e.functions), this.functions.context = this);
}
KR.prototype = ZC.prototype = {
  fork() {
    const e = new ZC(this);
    return (this.subcontext || (this.subcontext = [])).push(e), e;
  },
  detach(e) {
    this.subcontext = this.subcontext.filter((n) => n !== e);
    const t = Object.keys(e.nodes);
    for (const n of t)
      e.nodes[n]._targets = null;
    for (const n of t)
      e.nodes[n].detach();
    e.nodes = null;
  },
  get(e) {
    return this.nodes[e];
  },
  set(e, t) {
    return this.nodes[e] = t;
  },
  add(e, t) {
    const n = this, i = n.dataflow, r = e.value;
    if (n.set(e.id, t), bee(e.type) && r && (r.$ingest ? i.ingest(t, r.$ingest, r.$format) : r.$request ? i.preload(t, r.$request, r.$format) : i.pulse(t, i.changeset().insert(r))), e.root && (n.root = t), e.parent) {
      let s = n.get(e.parent.$ref);
      s ? (i.connect(s, [t]), t.targets().add(s)) : (n.unresolved = n.unresolved || []).push(() => {
        s = n.get(e.parent.$ref), i.connect(s, [t]), t.targets().add(s);
      });
    }
    if (e.signal && (n.signals[e.signal] = t), e.scale && (n.scales[e.scale] = t), e.data)
      for (const s in e.data) {
        const o = n.data[s] || (n.data[s] = {});
        e.data[s].forEach((a) => o[a] = t);
      }
  },
  resolve() {
    return (this.unresolved || []).forEach((e) => e()), delete this.unresolved, this;
  },
  operator(e, t) {
    this.add(e, this.dataflow.add(e.value, t));
  },
  transform(e, t) {
    this.add(e, this.dataflow.add(this.transforms[x_(t)]));
  },
  stream(e, t) {
    this.set(e.id, t);
  },
  update(e, t, n, i, r) {
    this.dataflow.on(t, n, i, r, e.options);
  },
  // expression parsing
  operatorExpression(e) {
    return this.expr.operator(this, e);
  },
  parameterExpression(e) {
    return this.expr.parameter(this, e);
  },
  eventExpression(e) {
    return this.expr.event(this, e);
  },
  handlerExpression(e) {
    return this.expr.handler(this, e);
  },
  encodeExpression(e) {
    return this.expr.encode(this, e);
  },
  // parse methods
  parse: gee,
  parseOperator: wee,
  parseOperatorParameters: _ee,
  parseParameters: Eee,
  parseStream: Nee,
  parseUpdate: Dee,
  // state methods
  getState: Lee,
  setState: Pee
};
function Iee(e) {
  const t = e.container();
  t && (t.setAttribute("role", "graphics-document"), t.setAttribute("aria-roleDescription", "visualization"), JR(t, e.description()));
}
function JR(e, t) {
  e && (t == null ? e.removeAttribute("aria-label") : e.setAttribute("aria-label", t));
}
function zee(e) {
  e.add(null, (t) => (e._background = t.bg, e._resize = 1, t.bg), {
    bg: e._signals.background
  });
}
const Y1 = "default";
function Bee(e) {
  const t = e._signals.cursor || (e._signals.cursor = e.add({
    user: Y1,
    item: null
  }));
  e.on(e.events("view", "pointermove"), t, (n, i) => {
    const r = t.value, s = r ? te(r) ? r : r.user : Y1, o = i.item && i.item.cursor || null;
    return r && s === r.user && o == r.item ? r : {
      user: s,
      item: o
    };
  }), e.add(null, function(n) {
    let i = n.cursor, r = this.value;
    return te(i) || (r = i.item, i = i.user), ev(e, i && i !== Y1 ? i : r || i), r;
  }, {
    cursor: t
  });
}
function ev(e, t) {
  const n = e.globalCursor() ? typeof document < "u" && document.body : e.container();
  if (n)
    return t == null ? n.style.removeProperty("cursor") : n.style.cursor = t;
}
function pp(e, t) {
  var n = e._runtime.data;
  return ce(n, t) || j("Unrecognized data set: " + t), n[t];
}
function jee(e, t) {
  return arguments.length < 2 ? pp(this, e).values.value : Wm.call(this, e, tl().remove(Ei).insert(t));
}
function Wm(e, t) {
  yT(t) || j("Second argument to changes must be a changeset.");
  const n = pp(this, e);
  return n.modified = !0, this.pulse(n.input, t);
}
function Uee(e, t) {
  return Wm.call(this, e, tl().insert(t));
}
function qee(e, t) {
  return Wm.call(this, e, tl().remove(t));
}
function QR(e) {
  var t = e.padding();
  return Math.max(0, e._viewWidth + t.left + t.right);
}
function ZR(e) {
  var t = e.padding();
  return Math.max(0, e._viewHeight + t.top + t.bottom);
}
function Hm(e) {
  var t = e.padding(), n = e._origin;
  return [t.left + n[0], t.top + n[1]];
}
function Wee(e) {
  var t = Hm(e), n = QR(e), i = ZR(e);
  e._renderer.background(e.background()), e._renderer.resize(n, i, t), e._handler.origin(t), e._resizeListeners.forEach((r) => {
    try {
      r(n, i);
    } catch (s) {
      e.error(s);
    }
  });
}
function Hee(e, t, n) {
  var i = e._renderer, r = i && i.canvas(), s, o, a;
  return r && (a = Hm(e), o = t.changedTouches ? t.changedTouches[0] : t, s = Fm(o, r), s[0] -= a[0], s[1] -= a[1]), t.dataflow = e, t.item = n, t.vega = Gee(e, n, s), t;
}
function Gee(e, t, n) {
  const i = t ? t.mark.marktype === "group" ? t : t.mark.group : null;
  function r(o) {
    var a = i, l;
    if (o) {
      for (l = t; l; l = l.mark.group)
        if (l.mark.name === o) {
          a = l;
          break;
        }
    }
    return a && a.mark && a.mark.interactive ? a : {};
  }
  function s(o) {
    if (!o)
      return n;
    te(o) && (o = r(o));
    const a = n.slice();
    for (; o; )
      a[0] -= o.x || 0, a[1] -= o.y || 0, o = o.mark && o.mark.group;
    return a;
  }
  return {
    view: ln(e),
    item: ln(t || {}),
    group: r,
    xy: s,
    x: (o) => s(o)[0],
    y: (o) => s(o)[1]
  };
}
const e$ = "view", Vee = "timer", Yee = "window", Xee = {
  trap: !1
};
function Kee(e) {
  const t = we({
    defaults: {}
  }, e), n = (i, r) => {
    r.forEach((s) => {
      U(i[s]) && (i[s] = Ji(i[s]));
    });
  };
  return n(t.defaults, ["prevent", "allow"]), n(t, ["view", "window", "selector"]), t;
}
function e6(e, t, n, i) {
  e._eventListeners.push({
    type: n,
    sources: ee(t),
    handler: i
  });
}
function Jee(e, t) {
  var n = e._eventConfig.defaults, i = n.prevent, r = n.allow;
  return i === !1 || r === !0 ? !1 : i === !0 || r === !1 ? !0 : i ? i[t] : r ? !r[t] : e.preventDefault();
}
function mh(e, t, n) {
  const i = e._eventConfig && e._eventConfig[t];
  return i === !1 || ne(i) && !i[n] ? (e.warn(`Blocked ${t} ${n} event listener.`), !1) : !0;
}
function Qee(e, t, n) {
  var i = this, r = new em(n), s = function(u, c) {
    i.runAsync(null, () => {
      e === e$ && Jee(i, t) && u.preventDefault(), r.receive(Hee(i, u, c));
    });
  }, o;
  if (e === Vee)
    mh(i, "timer", t) && i.timer(s, t);
  else if (e === e$)
    mh(i, "view", t) && i.addEventListener(t, s, Xee);
  else if (e === Yee ? mh(i, "window", t) && typeof window < "u" && (o = [window]) : typeof document < "u" && mh(i, "selector", t) && (o = Array.from(document.querySelectorAll(e))), !o)
    i.warn("Can not resolve event source: " + e);
  else {
    for (var a = 0, l = o.length; a < l; ++a)
      o[a].addEventListener(t, s);
    e6(i, o, t, s);
  }
  return r;
}
function t$(e) {
  return e.item;
}
function n$(e) {
  return e.item.mark.source;
}
function i$(e) {
  return function(t, n) {
    return n.vega.view().changeset().encode(n.item, e);
  };
}
function Zee(e, t) {
  return e = [e || "hover"], t = [t || "update", e[0]], this.on(this.events("view", "pointerover", t$), n$, i$(e)), this.on(this.events("view", "pointerout", t$), n$, i$(t)), this;
}
function ete() {
  var e = this._tooltip, t = this._timers, n = this._eventListeners, i, r, s;
  for (i = t.length; --i >= 0; )
    t[i].stop();
  for (i = n.length; --i >= 0; )
    for (s = n[i], r = s.sources.length; --r >= 0; )
      s.sources[r].removeEventListener(s.type, s.handler);
  return e && e.call(this, this._handler, null, null, null), this;
}
function ni(e, t, n) {
  const i = document.createElement(e);
  for (const r in t)
    i.setAttribute(r, t[r]);
  return n != null && (i.textContent = n), i;
}
const tte = "vega-bind", nte = "vega-bind-name", ite = "vega-bind-radio";
function rte(e, t, n) {
  if (!t)
    return;
  const i = n.param;
  let r = n.state;
  return r || (r = n.state = {
    elements: null,
    active: !1,
    set: null,
    update: (o) => {
      o != e.signal(i.signal) && e.runAsync(null, () => {
        r.source = !0, e.signal(i.signal, o);
      });
    }
  }, i.debounce && (r.update = Zv(i.debounce, r.update))), (i.input == null && i.element ? ste : ate)(r, t, i, e), r.active || (e.on(e._signals[i.signal], null, () => {
    r.source ? r.source = !1 : r.set(e.signal(i.signal));
  }), r.active = !0), r;
}
function ste(e, t, n, i) {
  const r = n.event || "input", s = () => e.update(t.value);
  i.signal(n.signal, t.value), t.addEventListener(r, s), e6(i, t, r, s), e.set = (o) => {
    t.value = o, t.dispatchEvent(ote(r));
  };
}
function ote(e) {
  return typeof Event < "u" ? new Event(e) : {
    type: e
  };
}
function ate(e, t, n, i) {
  const r = i.signal(n.signal), s = ni("div", {
    class: tte
  }), o = n.input === "radio" ? s : s.appendChild(ni("label"));
  o.appendChild(ni("span", {
    class: nte
  }, n.name || n.signal)), t.appendChild(s);
  let a = lte;
  switch (n.input) {
    case "checkbox":
      a = ute;
      break;
    case "select":
      a = cte;
      break;
    case "radio":
      a = fte;
      break;
    case "range":
      a = dte;
      break;
  }
  a(e, o, n, r);
}
function lte(e, t, n, i) {
  const r = ni("input");
  for (const s in n)
    s !== "signal" && s !== "element" && r.setAttribute(s === "input" ? "type" : s, n[s]);
  r.setAttribute("name", n.signal), r.value = i, t.appendChild(r), r.addEventListener("input", () => e.update(r.value)), e.elements = [r], e.set = (s) => r.value = s;
}
function ute(e, t, n, i) {
  const r = {
    type: "checkbox",
    name: n.signal
  };
  i && (r.checked = !0);
  const s = ni("input", r);
  t.appendChild(s), s.addEventListener("change", () => e.update(s.checked)), e.elements = [s], e.set = (o) => s.checked = !!o || null;
}
function cte(e, t, n, i) {
  const r = ni("select", {
    name: n.signal
  }), s = n.labels || [];
  n.options.forEach((o, a) => {
    const l = {
      value: o
    };
    mp(o, i) && (l.selected = !0), r.appendChild(ni("option", l, (s[a] || o) + ""));
  }), t.appendChild(r), r.addEventListener("change", () => {
    e.update(n.options[r.selectedIndex]);
  }), e.elements = [r], e.set = (o) => {
    for (let a = 0, l = n.options.length; a < l; ++a)
      if (mp(n.options[a], o)) {
        r.selectedIndex = a;
        return;
      }
  };
}
function fte(e, t, n, i) {
  const r = ni("span", {
    class: ite
  }), s = n.labels || [];
  t.appendChild(r), e.elements = n.options.map((o, a) => {
    const l = {
      type: "radio",
      name: n.signal,
      value: o
    };
    mp(o, i) && (l.checked = !0);
    const u = ni("input", l);
    u.addEventListener("change", () => e.update(o));
    const c = ni("label", {}, (s[a] || o) + "");
    return c.prepend(u), r.appendChild(c), u;
  }), e.set = (o) => {
    const a = e.elements, l = a.length;
    for (let u = 0; u < l; ++u)
      mp(a[u].value, o) && (a[u].checked = !0);
  };
}
function dte(e, t, n, i) {
  i = i !== void 0 ? i : (+n.max + +n.min) / 2;
  const r = n.max != null ? n.max : Math.max(100, +i) || 100, s = n.min || Math.min(0, r, +i) || 0, o = n.step || ho(s, r, 100), a = ni("input", {
    type: "range",
    name: n.signal,
    min: s,
    max: r,
    step: o
  });
  a.value = i;
  const l = ni("span", {}, +i);
  t.appendChild(a), t.appendChild(l);
  const u = () => {
    l.textContent = a.value, e.update(+a.value);
  };
  a.addEventListener("input", u), a.addEventListener("change", u), e.elements = [a], e.set = (c) => {
    a.value = c, l.textContent = c;
  };
}
function mp(e, t) {
  return e === t || e + "" == t + "";
}
function t6(e, t, n, i, r, s) {
  return t = t || new i(e.loader()), t.initialize(n, QR(e), ZR(e), Hm(e), r, s).background(e.background());
}
function w_(e, t) {
  return t ? function() {
    try {
      t.apply(this, arguments);
    } catch (n) {
      e.error(n);
    }
  } : null;
}
function hte(e, t, n, i) {
  const r = new i(e.loader(), w_(e, e.tooltip())).scene(e.scenegraph().root).initialize(n, Hm(e), e);
  return t && t.handlers().forEach((s) => {
    r.on(s.type, s.handler);
  }), r;
}
function gte(e, t) {
  const n = this, i = n._renderType, r = n._eventConfig.bind, s = Om(i);
  e = n._el = e ? X1(n, e, !0) : null, Iee(n), s || n.error("Unrecognized renderer type: " + i);
  const o = s.handler || wo, a = e ? s.renderer : s.headless;
  return n._renderer = a ? t6(n, n._renderer, e, a) : null, n._handler = hte(n, n._handler, e, o), n._redraw = !0, e && r !== "none" && (t = t ? n._elBind = X1(n, t, !0) : e.appendChild(ni("form", {
    class: "vega-bindings"
  })), n._bind.forEach((l) => {
    l.param.element && r !== "container" && (l.element = X1(n, l.param.element, !!l.param.input));
  }), n._bind.forEach((l) => {
    rte(n, l.element || t, l);
  })), n;
}
function X1(e, t, n) {
  if (typeof t == "string")
    if (typeof document < "u") {
      if (t = document.querySelector(t), !t)
        return e.error("Signal bind element not found: " + t), null;
    } else
      return e.error("DOM document instance not found."), null;
  if (t && n)
    try {
      t.textContent = "";
    } catch (i) {
      t = null, e.error(i);
    }
  return t;
}
const vc = (e) => +e || 0, pte = (e) => ({
  top: e,
  bottom: e,
  left: e,
  right: e
});
function r$(e) {
  return ne(e) ? {
    top: vc(e.top),
    bottom: vc(e.bottom),
    left: vc(e.left),
    right: vc(e.right)
  } : pte(vc(e));
}
async function __(e, t, n, i) {
  const r = Om(t), s = r && r.headless;
  return s || j("Unrecognized renderer type: " + t), await e.runAsync(), t6(e, null, null, s, n, i).renderAsync(e._scenegraph.root);
}
async function mte(e, t) {
  e !== Zs.Canvas && e !== Zs.SVG && e !== Zs.PNG && j("Unrecognized image type: " + e);
  const n = await __(this, e, t);
  return e === Zs.SVG ? yte(n.svg(), "image/svg+xml") : n.canvas().toDataURL("image/png");
}
function yte(e, t) {
  const n = new Blob([e], {
    type: t
  });
  return window.URL.createObjectURL(n);
}
async function bte(e, t) {
  return (await __(this, Zs.Canvas, e, t)).canvas();
}
async function vte(e) {
  return (await __(this, Zs.SVG, e)).svg();
}
function xte(e, t, n) {
  return XR(e, ru, jf, n).parse(t);
}
function wte(e) {
  var t = this._runtime.scales;
  return ce(t, e) || j("Unrecognized scale or projection: " + e), t[e].value;
}
var n6 = "width", i6 = "height", E_ = "padding", s$ = {
  skip: !0
};
function r6(e, t) {
  var n = e.autosize(), i = e.padding();
  return t - (n && n.contains === E_ ? i.left + i.right : 0);
}
function s6(e, t) {
  var n = e.autosize(), i = e.padding();
  return t - (n && n.contains === E_ ? i.top + i.bottom : 0);
}
function _te(e) {
  var t = e._signals, n = t[n6], i = t[i6], r = t[E_];
  function s() {
    e._autosize = e._resize = 1;
  }
  e._resizeWidth = e.add(null, (a) => {
    e._width = a.size, e._viewWidth = r6(e, a.size), s();
  }, {
    size: n
  }), e._resizeHeight = e.add(null, (a) => {
    e._height = a.size, e._viewHeight = s6(e, a.size), s();
  }, {
    size: i
  });
  const o = e.add(null, s, {
    pad: r
  });
  e._resizeWidth.rank = n.rank + 1, e._resizeHeight.rank = i.rank + 1, o.rank = r.rank + 1;
}
function Ete(e, t, n, i, r, s) {
  this.runAfter((o) => {
    let a = 0;
    o._autosize = 0, o.width() !== n && (a = 1, o.signal(n6, n, s$), o._resizeWidth.skip(!0)), o.height() !== i && (a = 1, o.signal(i6, i, s$), o._resizeHeight.skip(!0)), o._viewWidth !== e && (o._resize = 1, o._viewWidth = e), o._viewHeight !== t && (o._resize = 1, o._viewHeight = t), (o._origin[0] !== r[0] || o._origin[1] !== r[1]) && (o._resize = 1, o._origin = r), a && o.run("enter"), s && o.runAfter((l) => l.resize());
  }, !1, 1);
}
function Ste(e) {
  return this._runtime.getState(e || {
    data: kte,
    signals: Ate,
    recurse: !0
  });
}
function kte(e, t) {
  return t.modified && U(t.input.value) && !e.startsWith("_:vega:_");
}
function Ate(e, t) {
  return !(e === "parent" || t instanceof ru.proxy);
}
function Cte(e) {
  return this.runAsync(null, (t) => {
    t._trigger = !1, t._runtime.setState(e);
  }, (t) => {
    t._trigger = !0;
  }), this;
}
function $te(e, t) {
  function n(i) {
    e({
      timestamp: Date.now(),
      elapsed: i
    });
  }
  this._timers.push(sX(n, t));
}
function Mte(e, t, n, i) {
  const r = e.element();
  r && r.setAttribute("title", Fte(i));
}
function Fte(e) {
  return e == null ? "" : U(e) ? o6(e) : ne(e) && !so(e) ? Tte(e) : e + "";
}
function Tte(e) {
  return Object.keys(e).map((t) => {
    const n = e[t];
    return t + ": " + (U(n) ? o6(n) : a6(n));
  }).join(`
`);
}
function o6(e) {
  return "[" + e.map(a6).join(", ") + "]";
}
function a6(e) {
  return U(e) ? "[…]" : ne(e) && !so(e) ? "{…}" : e;
}
function Ote() {
  if (this.renderer() === "canvas" && this._renderer._canvas) {
    let e = null;
    const t = () => {
      e != null && e();
      const n = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
      n.addEventListener("change", t), e = () => {
        n.removeEventListener("change", t);
      }, this._renderer._canvas.getContext("2d").pixelRatio = window.devicePixelRatio || 1, this._redraw = !0, this._resize = 1, this.resize().runAsync();
    };
    t();
  }
}
function l6(e, t) {
  const n = this;
  if (t = t || {}, jl.call(n), t.loader && n.loader(t.loader), t.logger && n.logger(t.logger), t.logLevel != null && n.logLevel(t.logLevel), t.locale || e.locale) {
    const s = we({}, e.locale, t.locale);
    n.locale(aT(s.number, s.time));
  }
  n._el = null, n._elBind = null, n._renderType = t.renderer || Zs.Canvas, n._scenegraph = new iw();
  const i = n._scenegraph.root;
  n._renderer = null, n._tooltip = t.tooltip || Mte, n._redraw = !0, n._handler = new wo().scene(i), n._globalCursor = !1, n._preventDefault = !1, n._timers = [], n._eventListeners = [], n._resizeListeners = [], n._eventConfig = Kee(e.eventConfig), n.globalCursor(n._eventConfig.globalCursor);
  const r = xte(n, e, t.expr);
  n._runtime = r, n._signals = r.signals, n._bind = (e.bindings || []).map((s) => ({
    state: null,
    param: we({}, s)
  })), r.root && r.root.set(i), i.source = r.data.root.input, n.pulse(r.data.root.input, n.changeset().insert(i.items)), n._width = n.width(), n._height = n.height(), n._viewWidth = r6(n, n._width), n._viewHeight = s6(n, n._height), n._origin = [0, 0], n._resize = 0, n._autosize = 1, _te(n), zee(n), Bee(n), n.description(e.description), t.hover && n.hover(), t.container && n.initialize(t.container, t.bind), t.watchPixelRatio && n._watchPixelRatio();
}
function yh(e, t) {
  return ce(e._signals, t) ? e._signals[t] : j("Unrecognized signal name: " + X(t));
}
function u6(e, t) {
  const n = (e._targets || []).filter((i) => i._update && i._update.handler === t);
  return n.length ? n[0] : null;
}
function o$(e, t, n, i) {
  let r = u6(n, i);
  return r || (r = w_(e, () => i(t, n.value)), r.handler = i, e.on(n, null, r)), e;
}
function a$(e, t, n) {
  const i = u6(t, n);
  return i && t._targets.remove(i), e;
}
Y(l6, jl, {
  // -- DATAFLOW / RENDERING ----
  async evaluate(e, t, n) {
    if (await jl.prototype.evaluate.call(this, e, t), this._redraw || this._resize)
      try {
        this._renderer && (this._resize && (this._resize = 0, Wee(this)), await this._renderer.renderAsync(this._scenegraph.root)), this._redraw = !1;
      } catch (i) {
        this.error(i);
      }
    return n && Nh(this, n), this;
  },
  dirty(e) {
    this._redraw = !0, this._renderer && this._renderer.dirty(e);
  },
  // -- GET / SET ----
  description(e) {
    if (arguments.length) {
      const t = e != null ? e + "" : null;
      return t !== this._desc && JR(this._el, this._desc = t), this;
    }
    return this._desc;
  },
  container() {
    return this._el;
  },
  scenegraph() {
    return this._scenegraph;
  },
  origin() {
    return this._origin.slice();
  },
  signal(e, t, n) {
    const i = yh(this, e);
    return arguments.length === 1 ? i.value : this.update(i, t, n);
  },
  width(e) {
    return arguments.length ? this.signal("width", e) : this.signal("width");
  },
  height(e) {
    return arguments.length ? this.signal("height", e) : this.signal("height");
  },
  padding(e) {
    return arguments.length ? this.signal("padding", r$(e)) : r$(this.signal("padding"));
  },
  autosize(e) {
    return arguments.length ? this.signal("autosize", e) : this.signal("autosize");
  },
  background(e) {
    return arguments.length ? this.signal("background", e) : this.signal("background");
  },
  renderer(e) {
    return arguments.length ? (Om(e) || j("Unrecognized renderer type: " + e), e !== this._renderType && (this._renderType = e, this._resetRenderer()), this) : this._renderType;
  },
  tooltip(e) {
    return arguments.length ? (e !== this._tooltip && (this._tooltip = e, this._resetRenderer()), this) : this._tooltip;
  },
  loader(e) {
    return arguments.length ? (e !== this._loader && (jl.prototype.loader.call(this, e), this._resetRenderer()), this) : this._loader;
  },
  resize() {
    return this._autosize = 1, this.touch(yh(this, "autosize"));
  },
  _resetRenderer() {
    this._renderer && (this._renderer = null, this.initialize(this._el, this._elBind));
  },
  // -- SIZING ----
  _resizeView: Ete,
  // -- EVENT HANDLING ----
  addEventListener(e, t, n) {
    let i = t;
    return n && n.trap === !1 || (i = w_(this, t), i.raw = t), this._handler.on(e, i), this;
  },
  removeEventListener(e, t) {
    for (var n = this._handler.handlers(e), i = n.length, r, s; --i >= 0; )
      if (s = n[i].type, r = n[i].handler, e === s && (t === r || t === r.raw)) {
        this._handler.off(s, r);
        break;
      }
    return this;
  },
  addResizeListener(e) {
    const t = this._resizeListeners;
    return t.includes(e) || t.push(e), this;
  },
  removeResizeListener(e) {
    var t = this._resizeListeners, n = t.indexOf(e);
    return n >= 0 && t.splice(n, 1), this;
  },
  addSignalListener(e, t) {
    return o$(this, e, yh(this, e), t);
  },
  removeSignalListener(e, t) {
    return a$(this, yh(this, e), t);
  },
  addDataListener(e, t) {
    return o$(this, e, pp(this, e).values, t);
  },
  removeDataListener(e, t) {
    return a$(this, pp(this, e).values, t);
  },
  globalCursor(e) {
    if (arguments.length) {
      if (this._globalCursor !== !!e) {
        const t = ev(this, null);
        this._globalCursor = !!e, t && ev(this, t);
      }
      return this;
    } else
      return this._globalCursor;
  },
  preventDefault(e) {
    return arguments.length ? (this._preventDefault = e, this) : this._preventDefault;
  },
  timer: $te,
  events: Qee,
  finalize: ete,
  hover: Zee,
  // -- DATA ----
  data: jee,
  change: Wm,
  insert: Uee,
  remove: qee,
  // -- SCALES --
  scale: wte,
  // -- INITIALIZATION ----
  initialize: gte,
  // -- HEADLESS RENDERING ----
  toImageURL: mte,
  toCanvas: bte,
  toSVG: vte,
  // -- SAVE / RESTORE STATE ----
  getState: Ste,
  setState: Cte,
  // RE-RENDER ON ZOOM
  _watchPixelRatio: Ote
});
const Nte = "view", yp = "[", bp = "]", c6 = "{", f6 = "}", Dte = ":", d6 = ",", Rte = "@", Lte = ">", Pte = /[[\]{}]/, Ite = {
  "*": 1,
  arc: 1,
  area: 1,
  group: 1,
  image: 1,
  line: 1,
  path: 1,
  rect: 1,
  rule: 1,
  shape: 1,
  symbol: 1,
  text: 1,
  trail: 1
};
let h6, g6;
function Po(e, t, n) {
  return h6 = t || Nte, g6 = n || Ite, p6(e.trim()).map(tv);
}
function zte(e) {
  return g6[e];
}
function df(e, t, n, i, r) {
  const s = e.length;
  let o = 0, a;
  for (; t < s; ++t) {
    if (a = e[t], !o && a === n)
      return t;
    r && r.indexOf(a) >= 0 ? --o : i && i.indexOf(a) >= 0 && ++o;
  }
  return t;
}
function p6(e) {
  const t = [], n = e.length;
  let i = 0, r = 0;
  for (; r < n; )
    r = df(e, r, d6, yp + c6, bp + f6), t.push(e.substring(i, r).trim()), i = ++r;
  if (t.length === 0)
    throw "Empty event selector: " + e;
  return t;
}
function tv(e) {
  return e[0] === "[" ? Bte(e) : jte(e);
}
function Bte(e) {
  const t = e.length;
  let n = 1, i;
  if (n = df(e, n, bp, yp, bp), n === t)
    throw "Empty between selector: " + e;
  if (i = p6(e.substring(1, n)), i.length !== 2)
    throw "Between selector must have two elements: " + e;
  if (e = e.slice(n + 1).trim(), e[0] !== Lte)
    throw "Expected '>' after between selector: " + e;
  i = i.map(tv);
  const r = tv(e.slice(1).trim());
  return r.between ? {
    between: i,
    stream: r
  } : (r.between = i, r);
}
function jte(e) {
  const t = {
    source: h6
  }, n = [];
  let i = [0, 0], r = 0, s = 0, o = e.length, a = 0, l, u;
  if (e[o - 1] === f6) {
    if (a = e.lastIndexOf(c6), a >= 0) {
      try {
        i = Ute(e.substring(a + 1, o - 1));
      } catch {
        throw "Invalid throttle specification: " + e;
      }
      e = e.slice(0, a).trim(), o = e.length;
    } else
      throw "Unmatched right brace: " + e;
    a = 0;
  }
  if (!o)
    throw e;
  if (e[0] === Rte && (r = ++a), l = df(e, a, Dte), l < o && (n.push(e.substring(s, l).trim()), s = a = ++l), a = df(e, a, yp), a === o)
    n.push(e.substring(s, o).trim());
  else if (n.push(e.substring(s, a).trim()), u = [], s = ++a, s === o)
    throw "Unmatched left bracket: " + e;
  for (; a < o; ) {
    if (a = df(e, a, bp), a === o)
      throw "Unmatched left bracket: " + e;
    if (u.push(e.substring(s, a).trim()), a < o - 1 && e[++a] !== yp)
      throw "Expected left bracket: " + e;
    s = ++a;
  }
  if (!(o = n.length) || Pte.test(n[o - 1]))
    throw "Invalid event selector: " + e;
  return o > 1 ? (t.type = n[1], r ? t.markname = n[0].slice(1) : zte(n[0]) ? t.marktype = n[0] : t.source = n[0]) : t.type = n[0], t.type.slice(-1) === "!" && (t.consume = !0, t.type = t.type.slice(0, -1)), u != null && (t.filter = u), i[0] && (t.throttle = i[0]), i[1] && (t.debounce = i[1]), t;
}
function Ute(e) {
  const t = e.split(d6);
  if (!e.length || t.length > 2)
    throw e;
  return t.map((n) => {
    const i = +n;
    if (i !== i)
      throw e;
    return i;
  });
}
function qte(e) {
  return ne(e) ? e : {
    type: e || "pad"
  };
}
const xc = (e) => +e || 0, Wte = (e) => ({
  top: e,
  bottom: e,
  left: e,
  right: e
});
function Hte(e) {
  return ne(e) ? e.signal ? e : {
    top: xc(e.top),
    bottom: xc(e.bottom),
    left: xc(e.left),
    right: xc(e.right)
  } : Wte(xc(e));
}
const Ot = (e) => ne(e) && !U(e) ? we({}, e) : {
  value: e
};
function l$(e, t, n, i) {
  return n != null ? (ne(n) && !U(n) || U(n) && n.length && ne(n[0]) ? e.update[t] = n : e[i || "enter"][t] = {
    value: n
  }, 1) : 0;
}
function Ht(e, t, n) {
  for (const i in t)
    l$(e, i, t[i]);
  for (const i in n)
    l$(e, i, n[i], "update");
}
function Vu(e, t, n) {
  for (const i in t)
    n && ce(n, i) || (e[i] = we(e[i] || {}, t[i]));
  return e;
}
function Ol(e, t) {
  return t && (t.enter && t.enter[e] || t.update && t.update[e]);
}
const S_ = "mark", k_ = "frame", A_ = "scope", Gte = "axis", Vte = "axis-domain", Yte = "axis-grid", Xte = "axis-label", Kte = "axis-tick", Jte = "axis-title", Qte = "legend", Zte = "legend-band", ene = "legend-entry", tne = "legend-gradient", m6 = "legend-label", nne = "legend-symbol", ine = "legend-title", rne = "title", sne = "title-text", one = "title-subtitle";
function ane(e, t, n, i, r) {
  const s = {}, o = {};
  let a, l, u, c;
  l = "lineBreak", t === "text" && r[l] != null && !Ol(l, e) && K1(s, l, r[l]), (n == "legend" || String(n).startsWith("axis")) && (n = null), c = n === k_ ? r.group : n === S_ ? we({}, r.mark, r[t]) : null;
  for (l in c)
    u = Ol(l, e) || (l === "fill" || l === "stroke") && (Ol("fill", e) || Ol("stroke", e)), u || K1(s, l, c[l]);
  ee(i).forEach((f) => {
    const d = r.style && r.style[f];
    for (const h in d)
      Ol(h, e) || K1(s, h, d[h]);
  }), e = we({}, e);
  for (l in s)
    c = s[l], c.signal ? (a = a || {})[l] = c : o[l] = c;
  return e.enter = we(o, e.enter), a && (e.update = we(a, e.update)), e;
}
function K1(e, t, n) {
  e[t] = n && n.signal ? {
    signal: n.signal
  } : {
    value: n
  };
}
const y6 = (e) => te(e) ? X(e) : e.signal ? `(${e.signal})` : b6(e);
function Gm(e) {
  if (e.gradient != null)
    return une(e);
  let t = e.signal ? `(${e.signal})` : e.color ? lne(e.color) : e.field != null ? b6(e.field) : e.value !== void 0 ? X(e.value) : void 0;
  return e.scale != null && (t = cne(e, t)), t === void 0 && (t = null), e.exponent != null && (t = `pow(${t},${Kh(e.exponent)})`), e.mult != null && (t += `*${Kh(e.mult)}`), e.offset != null && (t += `+${Kh(e.offset)}`), e.round && (t = `round(${t})`), t;
}
const bh = (e, t, n, i) => `(${e}(${[t, n, i].map(Gm).join(",")})+'')`;
function lne(e) {
  return e.c ? bh("hcl", e.h, e.c, e.l) : e.h || e.s ? bh("hsl", e.h, e.s, e.l) : e.l || e.a ? bh("lab", e.l, e.a, e.b) : e.r || e.g || e.b ? bh("rgb", e.r, e.g, e.b) : null;
}
function une(e) {
  const t = [e.start, e.stop, e.count].map((n) => n == null ? null : X(n));
  for (; t.length && Te(t) == null; )
    t.pop();
  return t.unshift(y6(e.gradient)), `gradient(${t.join(",")})`;
}
function Kh(e) {
  return ne(e) ? "(" + Gm(e) + ")" : e;
}
function b6(e) {
  return v6(ne(e) ? e : {
    datum: e
  });
}
function v6(e) {
  let t, n, i;
  if (e.signal)
    t = "datum", i = e.signal;
  else if (e.group || e.parent) {
    for (n = Math.max(1, e.level || 1), t = "item"; n-- > 0; )
      t += ".mark.group";
    e.parent ? (i = e.parent, t += ".datum") : i = e.group;
  } else
    e.datum ? (t = "datum", i = e.datum) : j("Invalid field reference: " + X(e));
  return e.signal || (i = te(i) ? Pr(i).map(X).join("][") : v6(i)), t + "[" + i + "]";
}
function cne(e, t) {
  const n = y6(e.scale);
  return e.range != null ? t = `lerp(_range(${n}), ${+e.range})` : (t !== void 0 && (t = `_scale(${n}, ${t})`), e.band && (t = (t ? t + "+" : "") + `_bandwidth(${n})` + (+e.band == 1 ? "" : "*" + Kh(e.band)), e.extra && (t = `(datum.extra ? _scale(${n}, datum.extra.value) : ${t})`)), t == null && (t = "0")), t;
}
function fne(e) {
  let t = "";
  return e.forEach((n) => {
    const i = Gm(n);
    t += n.test ? `(${n.test})?${i}:` : i;
  }), Te(t) === ":" && (t += "null"), t;
}
function x6(e, t, n, i, r, s) {
  const o = {};
  s = s || {}, s.encoders = {
    $encode: o
  }, e = ane(e, t, n, i, r.config);
  for (const a in e)
    o[a] = dne(e[a], t, s, r);
  return s;
}
function dne(e, t, n, i) {
  const r = {}, s = {};
  for (const o in e)
    e[o] != null && (r[o] = gne(hne(e[o]), i, n, s));
  return {
    $expr: {
      marktype: t,
      channels: r
    },
    $fields: Object.keys(s),
    $output: Object.keys(e)
  };
}
function hne(e) {
  return U(e) ? fne(e) : Gm(e);
}
function gne(e, t, n, i) {
  const r = Nr(e, t);
  return r.$fields.forEach((s) => i[s] = 1), we(n, r.$params), r.$expr;
}
const pne = "outer", mne = ["value", "update", "init", "react", "bind"];
function u$(e, t) {
  j(e + ' for "outer" push: ' + X(t));
}
function w6(e, t) {
  const n = e.name;
  if (e.push === pne)
    t.signals[n] || u$("No prior signal definition", n), mne.forEach((i) => {
      e[i] !== void 0 && u$("Invalid property ", i);
    });
  else {
    const i = t.addSignal(n, e.value);
    e.react === !1 && (i.react = !1), e.bind && t.addBinding(n, e.bind);
  }
}
function nv(e, t, n, i) {
  this.id = -1, this.type = e, this.value = t, this.params = n, i && (this.parent = i);
}
function Vm(e, t, n, i) {
  return new nv(e, t, n, i);
}
function vp(e, t) {
  return Vm("operator", e, t);
}
function ae(e) {
  const t = {
    $ref: e.id
  };
  return e.id < 0 && (e.refs = e.refs || []).push(t), t;
}
function Uf(e, t) {
  return t ? {
    $field: e,
    $name: t
  } : {
    $field: e
  };
}
const iv = Uf("key");
function c$(e, t) {
  return {
    $compare: e,
    $order: t
  };
}
function yne(e, t) {
  const n = {
    $key: e
  };
  return t && (n.$flat = !0), n;
}
const bne = "ascending", vne = "descending";
function xne(e) {
  return ne(e) ? (e.order === vne ? "-" : "+") + Ym(e.op, e.field) : "";
}
function Ym(e, t) {
  return (e && e.signal ? "$" + e.signal : e || "") + (e && t ? "_" : "") + (t && t.signal ? "$" + t.signal : t || "");
}
const C_ = "scope", rv = "view";
function _t(e) {
  return e && e.signal;
}
function wne(e) {
  return e && e.expr;
}
function Jh(e) {
  if (_t(e))
    return !0;
  if (ne(e)) {
    for (const t in e)
      if (Jh(e[t]))
        return !0;
  }
  return !1;
}
function Ii(e, t) {
  return e ?? t;
}
function Ea(e) {
  return e && e.signal || e;
}
const f$ = "timer";
function qf(e, t) {
  return (e.merge ? Ene : e.stream ? Sne : e.type ? kne : j("Invalid stream specification: " + X(e)))(e, t);
}
function _ne(e) {
  return e === C_ ? rv : e || rv;
}
function Ene(e, t) {
  const n = e.merge.map((r) => qf(r, t)), i = $_({
    merge: n
  }, e, t);
  return t.addStream(i).id;
}
function Sne(e, t) {
  const n = qf(e.stream, t), i = $_({
    stream: n
  }, e, t);
  return t.addStream(i).id;
}
function kne(e, t) {
  let n;
  e.type === f$ ? (n = t.event(f$, e.throttle), e = {
    between: e.between,
    filter: e.filter
  }) : n = t.event(_ne(e.source), e.type);
  const i = $_({
    stream: n
  }, e, t);
  return Object.keys(i).length === 1 ? n : t.addStream(i).id;
}
function $_(e, t, n) {
  let i = t.between;
  return i && (i.length !== 2 && j('Stream "between" parameter must have 2 entries: ' + X(t)), e.between = [qf(i[0], n), qf(i[1], n)]), i = t.filter ? [].concat(t.filter) : [], (t.marktype || t.markname || t.markrole) && i.push(Ane(t.marktype, t.markname, t.markrole)), t.source === C_ && i.push("inScope(event.item)"), i.length && (e.filter = Nr("(" + i.join(")&&(") + ")", n).$expr), (i = t.throttle) != null && (e.throttle = +i), (i = t.debounce) != null && (e.debounce = +i), t.consume && (e.consume = !0), e;
}
function Ane(e, t, n) {
  const i = "event.item";
  return i + (e && e !== "*" ? "&&" + i + ".mark.marktype==='" + e + "'" : "") + (n ? "&&" + i + ".mark.role==='" + n + "'" : "") + (t ? "&&" + i + ".mark.name==='" + t + "'" : "");
}
const Cne = {
  code: "_.$value",
  ast: {
    type: "Identifier",
    value: "value"
  }
};
function $ne(e, t, n) {
  const i = e.encode, r = {
    target: n
  };
  let s = e.events, o = e.update, a = [];
  s || j("Signal update missing events specification."), te(s) && (s = Po(s, t.isSubscope() ? C_ : rv)), s = ee(s).filter((l) => l.signal || l.scale ? (a.push(l), 0) : 1), a.length > 1 && (a = [Fne(a)]), s.length && a.push(s.length > 1 ? {
    merge: s
  } : s[0]), i != null && (o && j("Signal encode and update are mutually exclusive."), o = "encode(item()," + X(i) + ")"), r.update = te(o) ? Nr(o, t) : o.expr != null ? Nr(o.expr, t) : o.value != null ? o.value : o.signal != null ? {
    $expr: Cne,
    $params: {
      $value: t.signalRef(o.signal)
    }
  } : j("Invalid signal update specification."), e.force && (r.options = {
    force: !0
  }), a.forEach((l) => t.addUpdate(we(Mne(l, t), r)));
}
function Mne(e, t) {
  return {
    source: e.signal ? t.signalRef(e.signal) : e.scale ? t.scaleRef(e.scale) : qf(e, t)
  };
}
function Fne(e) {
  return {
    signal: "[" + e.map((t) => t.scale ? 'scale("' + t.scale + '")' : t.signal) + "]"
  };
}
function Tne(e, t) {
  const n = t.getSignal(e.name);
  let i = e.update;
  e.init && (i ? j("Signals can not include both init and update expressions.") : (i = e.init, n.initonly = !0)), i && (i = Nr(i, t), n.update = i.$expr, n.params = i.$params), e.on && e.on.forEach((r) => $ne(r, t, n.id));
}
const Ye = (e) => (t, n, i) => Vm(e, n, t || void 0, i), _6 = Ye("aggregate"), One = Ye("axisticks"), E6 = Ye("bound"), ir = Ye("collect"), d$ = Ye("compare"), Nne = Ye("datajoin"), S6 = Ye("encode"), Dne = Ye("expression"), Rne = Ye("facet"), Lne = Ye("field"), Pne = Ye("key"), Ine = Ye("legendentries"), zne = Ye("load"), Bne = Ye("mark"), jne = Ye("multiextent"), Une = Ye("multivalues"), qne = Ye("overlap"), Wne = Ye("params"), k6 = Ye("prefacet"), Hne = Ye("projection"), Gne = Ye("proxy"), Vne = Ye("relay"), A6 = Ye("render"), Yne = Ye("scale"), sl = Ye("sieve"), Xne = Ye("sortitems"), C6 = Ye("viewlayout"), Kne = Ye("values");
let Jne = 0;
const $6 = {
  min: "min",
  max: "max",
  count: "sum"
};
function Qne(e, t) {
  const n = e.type || "linear";
  bO(n) || j("Unrecognized scale type: " + X(n)), t.addScale(e.name, {
    type: n,
    domain: void 0
  });
}
function Zne(e, t) {
  const n = t.getScale(e.name).params;
  let i;
  n.domain = M6(e.domain, e, t), e.range != null && (n.range = T6(e, t, n)), e.interpolate != null && uie(e.interpolate, n), e.nice != null && (n.nice = lie(e.nice)), e.bins != null && (n.bins = aie(e.bins, t));
  for (i in e)
    ce(n, i) || i === "name" || (n[i] = mi(e[i], t));
}
function mi(e, t) {
  return ne(e) ? e.signal ? t.signalRef(e.signal) : j("Unsupported object: " + X(e)) : e;
}
function Qh(e, t) {
  return e.signal ? t.signalRef(e.signal) : e.map((n) => mi(n, t));
}
function Xm(e) {
  j("Can not find data set: " + X(e));
}
function M6(e, t, n) {
  if (!e) {
    (t.domainMin != null || t.domainMax != null) && j("No scale domain defined for domainMin/domainMax to override.");
    return;
  }
  return e.signal ? n.signalRef(e.signal) : (U(e) ? eie : e.fields ? nie : tie)(e, t, n);
}
function eie(e, t, n) {
  return e.map((i) => mi(i, n));
}
function tie(e, t, n) {
  const i = n.getData(e.data);
  return i || Xm(e.data), uu(t.type) ? i.valuesRef(n, e.field, F6(e.sort, !1)) : wO(t.type) ? i.domainRef(n, e.field) : i.extentRef(n, e.field);
}
function nie(e, t, n) {
  const i = e.data, r = e.fields.reduce((s, o) => (o = te(o) ? {
    data: i,
    field: o
  } : U(o) || o.signal ? iie(o, n) : o, s.push(o), s), []);
  return (uu(t.type) ? rie : wO(t.type) ? sie : oie)(e, n, r);
}
function iie(e, t) {
  const n = "_:vega:_" + Jne++, i = ir({});
  if (U(e))
    i.value = {
      $ingest: e
    };
  else if (e.signal) {
    const r = "setdata(" + X(n) + "," + e.signal + ")";
    i.params.input = t.signalRef(r);
  }
  return t.addDataPipeline(n, [i, sl({})]), {
    data: n,
    field: "data"
  };
}
function rie(e, t, n) {
  const i = F6(e.sort, !0);
  let r, s;
  const o = n.map((u) => {
    const c = t.getData(u.data);
    return c || Xm(u.data), c.countsRef(t, u.field, i);
  }), a = {
    groupby: iv,
    pulse: o
  };
  i && (r = i.op || "count", s = i.field ? Ym(r, i.field) : "count", a.ops = [$6[r]], a.fields = [t.fieldRef(s)], a.as = [s]), r = t.add(_6(a));
  const l = t.add(ir({
    pulse: ae(r)
  }));
  return s = t.add(Kne({
    field: iv,
    sort: t.sortRef(i),
    pulse: ae(l)
  })), ae(s);
}
function F6(e, t) {
  return e && (!e.field && !e.op ? ne(e) ? e.field = "key" : e = {
    field: "key"
  } : !e.field && e.op !== "count" ? j("No field provided for sort aggregate op: " + e.op) : t && e.field && e.op && !$6[e.op] && j("Multiple domain scales can not be sorted using " + e.op)), e;
}
function sie(e, t, n) {
  const i = n.map((r) => {
    const s = t.getData(r.data);
    return s || Xm(r.data), s.domainRef(t, r.field);
  });
  return ae(t.add(Une({
    values: i
  })));
}
function oie(e, t, n) {
  const i = n.map((r) => {
    const s = t.getData(r.data);
    return s || Xm(r.data), s.extentRef(t, r.field);
  });
  return ae(t.add(jne({
    extents: i
  })));
}
function aie(e, t) {
  return e.signal || U(e) ? Qh(e, t) : t.objectProperty(e);
}
function lie(e) {
  return ne(e) ? {
    interval: mi(e.interval),
    step: mi(e.step)
  } : mi(e);
}
function uie(e, t) {
  t.interpolate = mi(e.type || e), e.gamma != null && (t.interpolateGamma = mi(e.gamma));
}
function T6(e, t, n) {
  const i = t.config.range;
  let r = e.range;
  if (r.signal)
    return t.signalRef(r.signal);
  if (te(r)) {
    if (i && ce(i, r))
      return e = we({}, e, {
        range: i[r]
      }), T6(e, t, n);
    r === "width" ? r = [0, {
      signal: "width"
    }] : r === "height" ? r = uu(e.type) ? [0, {
      signal: "height"
    }] : [{
      signal: "height"
    }, 0] : j("Unrecognized scale range value: " + X(r));
  } else if (r.scheme) {
    n.scheme = U(r.scheme) ? Qh(r.scheme, t) : mi(r.scheme, t), r.extent && (n.schemeExtent = Qh(r.extent, t)), r.count && (n.schemeCount = mi(r.count, t));
    return;
  } else if (r.step) {
    n.rangeStep = mi(r.step, t);
    return;
  } else {
    if (uu(e.type) && !U(r))
      return M6(r, e, t);
    U(r) || j("Unsupported range type: " + X(r));
  }
  return r.map((s) => (U(s) ? Qh : mi)(s, t));
}
function cie(e, t) {
  const n = t.config.projection || {}, i = {};
  for (const r in e)
    r !== "name" && (i[r] = sv(e[r], r, t));
  for (const r in n)
    i[r] == null && (i[r] = sv(n[r], r, t));
  t.addProjection(e.name, i);
}
function sv(e, t, n) {
  return U(e) ? e.map((i) => sv(i, t, n)) : ne(e) ? e.signal ? n.signalRef(e.signal) : t === "fit" ? e : j("Unsupported parameter object: " + X(e)) : e;
}
const rr = "top", Yu = "left", Xu = "right", Eo = "bottom", O6 = "center", fie = "vertical", die = "start", hie = "middle", gie = "end", ov = "index", M_ = "label", pie = "offset", bu = "perc", mie = "perc2", xi = "value", Cd = "guide-label", F_ = "guide-title", yie = "group-title", bie = "group-subtitle", h$ = "symbol", Zh = "gradient", av = "discrete", lv = "size", vie = "shape", xie = "fill", wie = "stroke", _ie = "strokeWidth", Eie = "strokeDash", Sie = "opacity", T_ = [lv, vie, xie, wie, _ie, Eie, Sie], $d = {
  name: 1,
  style: 1,
  interactive: 1
}, Ne = {
  value: 0
}, wi = {
  value: 1
}, Km = "group", N6 = "rect", O_ = "rule", kie = "symbol", ol = "text";
function Wf(e) {
  return e.type = Km, e.interactive = e.interactive || !1, e;
}
function Hn(e, t) {
  const n = (i, r) => Ii(e[i], Ii(t[i], r));
  return n.isVertical = (i) => fie === Ii(e.direction, t.direction || (i ? t.symbolDirection : t.gradientDirection)), n.gradientLength = () => Ii(e.gradientLength, t.gradientLength || t.gradientWidth), n.gradientThickness = () => Ii(e.gradientThickness, t.gradientThickness || t.gradientHeight), n.entryColumns = () => Ii(e.columns, Ii(t.columns, +n.isVertical(!0))), n;
}
function D6(e, t) {
  const n = t && (t.update && t.update[e] || t.enter && t.enter[e]);
  return n && n.signal ? n : n ? n.value : null;
}
function Aie(e, t, n) {
  const i = t.config.style[n];
  return i && i[e];
}
function Jm(e, t, n) {
  return `item.anchor === '${die}' ? ${e} : item.anchor === '${gie}' ? ${t} : ${n}`;
}
const N_ = Jm(X(Yu), X(Xu), X(O6));
function Cie(e) {
  const t = e("tickBand");
  let n = e("tickOffset"), i, r;
  return t ? t.signal ? (i = {
    signal: `(${t.signal}) === 'extent' ? 1 : 0.5`
  }, r = {
    signal: `(${t.signal}) === 'extent'`
  }, ne(n) || (n = {
    signal: `(${t.signal}) === 'extent' ? 0 : ${n}`
  })) : t === "extent" ? (i = 1, r = !0, n = 0) : (i = 0.5, r = !1) : (i = e("bandPosition"), r = e("tickExtra")), {
    extra: r,
    band: i,
    offset: n
  };
}
function R6(e, t) {
  return t ? e ? ne(e) ? Object.assign({}, e, {
    offset: R6(e.offset, t)
  }) : {
    value: e,
    offset: t
  } : t : e;
}
function ai(e, t) {
  return t ? (e.name = t.name, e.style = t.style || e.style, e.interactive = !!t.interactive, e.encode = Vu(e.encode, t, $d)) : e.interactive = !1, e;
}
function $ie(e, t, n, i) {
  const r = Hn(e, n), s = r.isVertical(), o = r.gradientThickness(), a = r.gradientLength();
  let l, u, c, f, d;
  s ? (u = [0, 1], c = [0, 0], f = o, d = a) : (u = [0, 0], c = [1, 0], f = a, d = o);
  const h = {
    enter: l = {
      opacity: Ne,
      x: Ne,
      y: Ne,
      width: Ot(f),
      height: Ot(d)
    },
    update: we({}, l, {
      opacity: wi,
      fill: {
        gradient: t,
        start: u,
        stop: c
      }
    }),
    exit: {
      opacity: Ne
    }
  };
  return Ht(h, {
    stroke: r("gradientStrokeColor"),
    strokeWidth: r("gradientStrokeWidth")
  }, {
    // update
    opacity: r("gradientOpacity")
  }), ai({
    type: N6,
    role: tne,
    encode: h
  }, i);
}
function Mie(e, t, n, i, r) {
  const s = Hn(e, n), o = s.isVertical(), a = s.gradientThickness(), l = s.gradientLength();
  let u, c, f, d, h = "";
  o ? (u = "y", f = "y2", c = "x", d = "width", h = "1-") : (u = "x", f = "x2", c = "y", d = "height");
  const g = {
    opacity: Ne,
    fill: {
      scale: t,
      field: xi
    }
  };
  g[u] = {
    signal: h + "datum." + bu,
    mult: l
  }, g[c] = Ne, g[f] = {
    signal: h + "datum." + mie,
    mult: l
  }, g[d] = Ot(a);
  const p = {
    enter: g,
    update: we({}, g, {
      opacity: wi
    }),
    exit: {
      opacity: Ne
    }
  };
  return Ht(p, {
    stroke: s("gradientStrokeColor"),
    strokeWidth: s("gradientStrokeWidth")
  }, {
    // update
    opacity: s("gradientOpacity")
  }), ai({
    type: N6,
    role: Zte,
    key: xi,
    from: r,
    encode: p
  }, i);
}
const Fie = `datum.${bu}<=0?"${Yu}":datum.${bu}>=1?"${Xu}":"${O6}"`, Tie = `datum.${bu}<=0?"${Eo}":datum.${bu}>=1?"${rr}":"${hie}"`;
function g$(e, t, n, i) {
  const r = Hn(e, t), s = r.isVertical(), o = Ot(r.gradientThickness()), a = r.gradientLength();
  let l = r("labelOverlap"), u, c, f, d, h = "";
  const g = {
    enter: u = {
      opacity: Ne
    },
    update: c = {
      opacity: wi,
      text: {
        field: M_
      }
    },
    exit: {
      opacity: Ne
    }
  };
  return Ht(g, {
    fill: r("labelColor"),
    fillOpacity: r("labelOpacity"),
    font: r("labelFont"),
    fontSize: r("labelFontSize"),
    fontStyle: r("labelFontStyle"),
    fontWeight: r("labelFontWeight"),
    limit: Ii(e.labelLimit, t.gradientLabelLimit)
  }), s ? (u.align = {
    value: "left"
  }, u.baseline = c.baseline = {
    signal: Tie
  }, f = "y", d = "x", h = "1-") : (u.align = c.align = {
    signal: Fie
  }, u.baseline = {
    value: "top"
  }, f = "x", d = "y"), u[f] = c[f] = {
    signal: h + "datum." + bu,
    mult: a
  }, u[d] = c[d] = o, o.offset = Ii(e.labelOffset, t.gradientLabelOffset) || 0, l = l ? {
    separation: r("labelSeparation"),
    method: l,
    order: "datum." + ov
  } : void 0, ai({
    type: ol,
    role: m6,
    style: Cd,
    key: xi,
    from: i,
    encode: g,
    overlap: l
  }, n);
}
function Oie(e, t, n, i, r) {
  const s = Hn(e, t), o = n.entries, a = !!(o && o.interactive), l = o ? o.name : void 0, u = s("clipHeight"), c = s("symbolOffset"), f = {
    data: "value"
  }, d = `(${r}) ? datum.${pie} : datum.${lv}`, h = u ? Ot(u) : {
    field: lv
  }, g = `datum.${ov}`, p = `max(1, ${r})`;
  let m, y, b, v, _;
  h.mult = 0.5, m = {
    enter: y = {
      opacity: Ne,
      x: {
        signal: d,
        mult: 0.5,
        offset: c
      },
      y: h
    },
    update: b = {
      opacity: wi,
      x: y.x,
      y: y.y
    },
    exit: {
      opacity: Ne
    }
  };
  let x = null, S = null;
  e.fill || (x = t.symbolBaseFillColor, S = t.symbolBaseStrokeColor), Ht(m, {
    fill: s("symbolFillColor", x),
    shape: s("symbolType"),
    size: s("symbolSize"),
    stroke: s("symbolStrokeColor", S),
    strokeDash: s("symbolDash"),
    strokeDashOffset: s("symbolDashOffset"),
    strokeWidth: s("symbolStrokeWidth")
  }, {
    // update
    opacity: s("symbolOpacity")
  }), T_.forEach((N) => {
    e[N] && (b[N] = y[N] = {
      scale: e[N],
      field: xi
    });
  });
  const E = ai({
    type: kie,
    role: nne,
    key: xi,
    from: f,
    clip: u ? !0 : void 0,
    encode: m
  }, n.symbols), C = Ot(c);
  C.offset = s("labelOffset"), m = {
    enter: y = {
      opacity: Ne,
      x: {
        signal: d,
        offset: C
      },
      y: h
    },
    update: b = {
      opacity: wi,
      text: {
        field: M_
      },
      x: y.x,
      y: y.y
    },
    exit: {
      opacity: Ne
    }
  }, Ht(m, {
    align: s("labelAlign"),
    baseline: s("labelBaseline"),
    fill: s("labelColor"),
    fillOpacity: s("labelOpacity"),
    font: s("labelFont"),
    fontSize: s("labelFontSize"),
    fontStyle: s("labelFontStyle"),
    fontWeight: s("labelFontWeight"),
    limit: s("labelLimit")
  });
  const $ = ai({
    type: ol,
    role: m6,
    style: Cd,
    key: xi,
    from: f,
    encode: m
  }, n.labels);
  return m = {
    enter: {
      noBound: {
        value: !u
      },
      // ignore width/height in bounds calc
      width: Ne,
      height: u ? Ot(u) : Ne,
      opacity: Ne
    },
    exit: {
      opacity: Ne
    },
    update: b = {
      opacity: wi,
      row: {
        signal: null
      },
      column: {
        signal: null
      }
    }
  }, s.isVertical(!0) ? (v = `ceil(item.mark.items.length / ${p})`, b.row.signal = `${g}%${v}`, b.column.signal = `floor(${g} / ${v})`, _ = {
    field: ["row", g]
  }) : (b.row.signal = `floor(${g} / ${p})`, b.column.signal = `${g} % ${p}`, _ = {
    field: g
  }), b.column.signal = `(${r})?${b.column.signal}:${g}`, i = {
    facet: {
      data: i,
      name: "value",
      groupby: ov
    }
  }, Wf({
    role: A_,
    from: i,
    encode: Vu(m, o, $d),
    marks: [E, $],
    name: l,
    interactive: a,
    sort: _
  });
}
function Nie(e, t) {
  const n = Hn(e, t);
  return {
    align: n("gridAlign"),
    columns: n.entryColumns(),
    center: {
      row: !0,
      column: !1
    },
    padding: {
      row: n("rowPadding"),
      column: n("columnPadding")
    }
  };
}
const D_ = 'item.orient === "left"', R_ = 'item.orient === "right"', Qm = `(${D_} || ${R_})`, Die = `datum.vgrad && ${Qm}`, Rie = Jm('"top"', '"bottom"', '"middle"'), Lie = Jm('"right"', '"left"', '"center"'), Pie = `datum.vgrad && ${R_} ? (${Lie}) : (${Qm} && !(datum.vgrad && ${D_})) ? "left" : ${N_}`, Iie = `item._anchor || (${Qm} ? "middle" : "start")`, zie = `${Die} ? (${D_} ? -90 : 90) : 0`, Bie = `${Qm} ? (datum.vgrad ? (${R_} ? "bottom" : "top") : ${Rie}) : "top"`;
function jie(e, t, n, i) {
  const r = Hn(e, t), s = {
    enter: {
      opacity: Ne
    },
    update: {
      opacity: wi,
      x: {
        field: {
          group: "padding"
        }
      },
      y: {
        field: {
          group: "padding"
        }
      }
    },
    exit: {
      opacity: Ne
    }
  };
  return Ht(s, {
    orient: r("titleOrient"),
    _anchor: r("titleAnchor"),
    anchor: {
      signal: Iie
    },
    angle: {
      signal: zie
    },
    align: {
      signal: Pie
    },
    baseline: {
      signal: Bie
    },
    text: e.title,
    fill: r("titleColor"),
    fillOpacity: r("titleOpacity"),
    font: r("titleFont"),
    fontSize: r("titleFontSize"),
    fontStyle: r("titleFontStyle"),
    fontWeight: r("titleFontWeight"),
    limit: r("titleLimit"),
    lineHeight: r("titleLineHeight")
  }, {
    // require update
    align: r("titleAlign"),
    baseline: r("titleBaseline")
  }), ai({
    type: ol,
    role: ine,
    style: F_,
    from: i,
    encode: s
  }, n);
}
function Uie(e, t) {
  let n;
  return ne(e) && (e.signal ? n = e.signal : e.path ? n = "pathShape(" + p$(e.path) + ")" : e.sphere && (n = "geoShape(" + p$(e.sphere) + ', {type: "Sphere"})')), n ? t.signalRef(n) : !!e;
}
function p$(e) {
  return ne(e) && e.signal ? e.signal : X(e);
}
function L6(e) {
  const t = e.role || "";
  return !t.indexOf("axis") || !t.indexOf("legend") || !t.indexOf("title") ? t : e.type === Km ? A_ : t || S_;
}
function qie(e) {
  return {
    marktype: e.type,
    name: e.name || void 0,
    role: e.role || L6(e),
    zindex: +e.zindex || void 0,
    aria: e.aria,
    description: e.description
  };
}
function Wie(e, t) {
  return e && e.signal ? t.signalRef(e.signal) : e !== !1;
}
function L_(e, t) {
  const n = xT(e.type);
  n || j("Unrecognized transform type: " + X(e.type));
  const i = Vm(n.type.toLowerCase(), null, P6(n, e, t));
  return e.signal && t.addSignal(e.signal, t.proxy(i)), i.metadata = n.metadata || {}, i;
}
function P6(e, t, n) {
  const i = {}, r = e.params.length;
  for (let s = 0; s < r; ++s) {
    const o = e.params[s];
    i[o.name] = Hie(o, t, n);
  }
  return i;
}
function Hie(e, t, n) {
  const i = e.type, r = t[e.name];
  if (i === "index")
    return Gie(e, t, n);
  if (r === void 0) {
    e.required && j("Missing required " + X(t.type) + " parameter: " + X(e.name));
    return;
  } else {
    if (i === "param")
      return Vie(e, t, n);
    if (i === "projection")
      return n.projectionRef(t[e.name]);
  }
  return e.array && !_t(r) ? r.map((s) => m$(e, s, n)) : m$(e, r, n);
}
function m$(e, t, n) {
  const i = e.type;
  if (_t(t))
    return b$(i) ? j("Expression references can not be signals.") : J1(i) ? n.fieldRef(t) : v$(i) ? n.compareRef(t) : n.signalRef(t.signal);
  {
    const r = e.expr || J1(i);
    return r && Yie(t) ? n.exprRef(t.expr, t.as) : r && Xie(t) ? Uf(t.field, t.as) : b$(i) ? Nr(t, n) : Kie(i) ? ae(n.getData(t).values) : J1(i) ? Uf(t) : v$(i) ? n.compareRef(t) : t;
  }
}
function Gie(e, t, n) {
  return te(t.from) || j('Lookup "from" parameter must be a string literal.'), n.getData(t.from).lookupRef(n, t.key);
}
function Vie(e, t, n) {
  const i = t[e.name];
  return e.array ? (U(i) || j("Expected an array of sub-parameters. Instead: " + X(i)), i.map((r) => y$(e, r, n))) : y$(e, i, n);
}
function y$(e, t, n) {
  const i = e.params.length;
  let r;
  for (let o = 0; o < i; ++o) {
    r = e.params[o];
    for (const a in r.key)
      if (r.key[a] !== t[a]) {
        r = null;
        break;
      }
    if (r)
      break;
  }
  r || j("Unsupported parameter: " + X(t));
  const s = we(P6(r, t, n), r.key);
  return ae(n.add(Wne(s)));
}
const Yie = (e) => e && e.expr, Xie = (e) => e && e.field, Kie = (e) => e === "data", b$ = (e) => e === "expr", J1 = (e) => e === "field", v$ = (e) => e === "compare";
function Jie(e, t, n) {
  let i, r, s, o, a;
  return e ? (i = e.facet) && (t || j("Only group marks can be faceted."), i.field != null ? o = a = eg(i, n) : (e.data ? a = ae(n.getData(e.data).aggregate) : (s = L_(we({
    type: "aggregate",
    groupby: ee(i.groupby)
  }, i.aggregate), n), s.params.key = n.keyRef(i.groupby), s.params.pulse = eg(i, n), o = a = ae(n.add(s))), r = n.keyRef(i.groupby, !0))) : o = ae(n.add(ir(null, [{}]))), o || (o = eg(e, n)), {
    key: r,
    pulse: o,
    parent: a
  };
}
function eg(e, t) {
  return e.$ref ? e : e.data && e.data.$ref ? e.data : ae(t.getData(e.data).output);
}
function za(e, t, n, i, r) {
  this.scope = e, this.input = t, this.output = n, this.values = i, this.aggregate = r, this.index = {};
}
za.fromEntries = function(e, t) {
  const n = t.length, i = t[n - 1], r = t[n - 2];
  let s = t[0], o = null, a = 1;
  for (s && s.type === "load" && (s = t[1]), e.add(t[0]); a < n; ++a)
    t[a].params.pulse = ae(t[a - 1]), e.add(t[a]), t[a].type === "aggregate" && (o = t[a]);
  return new za(e, s, r, i, o);
};
function I6(e) {
  return te(e) ? e : null;
}
function x$(e, t, n) {
  const i = Ym(n.op, n.field);
  let r;
  if (t.ops) {
    for (let s = 0, o = t.as.length; s < o; ++s)
      if (t.as[s] === i)
        return;
  } else
    t.ops = ["count"], t.fields = [null], t.as = ["count"];
  n.op && (t.ops.push((r = n.op.signal) ? e.signalRef(r) : n.op), t.fields.push(e.fieldRef(n.field)), t.as.push(i));
}
function wc(e, t, n, i, r, s, o) {
  const a = t[n] || (t[n] = {}), l = xne(s);
  let u = I6(r), c, f;
  if (u != null && (e = t.scope, u = u + (l ? "|" + l : ""), c = a[u]), !c) {
    const d = s ? {
      field: iv,
      pulse: t.countsRef(e, r, s)
    } : {
      field: e.fieldRef(r),
      pulse: ae(t.output)
    };
    l && (d.sort = e.sortRef(s)), f = e.add(Vm(i, void 0, d)), o && (t.index[r] = f), c = ae(f), u != null && (a[u] = c);
  }
  return c;
}
za.prototype = {
  countsRef(e, t, n) {
    const i = this, r = i.counts || (i.counts = {}), s = I6(t);
    let o, a, l;
    return s != null && (e = i.scope, o = r[s]), o ? n && n.field && x$(e, o.agg.params, n) : (l = {
      groupby: e.fieldRef(t, "key"),
      pulse: ae(i.output)
    }, n && n.field && x$(e, l, n), a = e.add(_6(l)), o = e.add(ir({
      pulse: ae(a)
    })), o = {
      agg: a,
      ref: ae(o)
    }, s != null && (r[s] = o)), o.ref;
  },
  tuplesRef() {
    return ae(this.values);
  },
  extentRef(e, t) {
    return wc(e, this, "extent", "extent", t, !1);
  },
  domainRef(e, t) {
    return wc(e, this, "domain", "values", t, !1);
  },
  valuesRef(e, t, n) {
    return wc(e, this, "vals", "values", t, n || !0);
  },
  lookupRef(e, t) {
    return wc(e, this, "lookup", "tupleindex", t, !1);
  },
  indataRef(e, t) {
    return wc(e, this, "indata", "tupleindex", t, !0, !0);
  }
};
function Qie(e, t, n) {
  const i = e.from.facet, r = i.name, s = eg(i, t);
  let o;
  i.name || j("Facet must have a name: " + X(i)), i.data || j("Facet must reference a data set: " + X(i)), i.field ? o = t.add(k6({
    field: t.fieldRef(i.field),
    pulse: s
  })) : i.groupby ? o = t.add(Rne({
    key: t.keyRef(i.groupby),
    group: ae(t.proxy(n.parent)),
    pulse: s
  })) : j("Facet must specify groupby or field: " + X(i));
  const a = t.fork(), l = a.add(ir()), u = a.add(sl({
    pulse: ae(l)
  }));
  a.addData(r, new za(a, l, l, u)), a.addSignal("parent", null), o.params.subflow = {
    $subflow: a.parse(e).toRuntime()
  };
}
function Zie(e, t, n) {
  const i = t.add(k6({
    pulse: n.pulse
  })), r = t.fork();
  r.add(sl()), r.addSignal("parent", null), i.params.subflow = {
    $subflow: r.parse(e).toRuntime()
  };
}
function z6(e, t, n) {
  const i = e.remove, r = e.insert, s = e.toggle, o = e.modify, a = e.values, l = t.add(vp()), u = "if(" + e.trigger + ',modify("' + n + '",' + [r, i, s, o, a].map((f) => f ?? "null").join(",") + "),0)", c = Nr(u, t);
  l.update = c.$expr, l.params = c.$params;
}
function Zm(e, t) {
  const n = L6(e), i = e.type === Km, r = e.from && e.from.facet, s = e.overlap;
  let o = e.layout || n === A_ || n === k_, a, l, u, c, f, d, h;
  const g = n === S_ || o || r, p = Jie(e.from, i, t);
  l = t.add(Nne({
    key: p.key || (e.key ? Uf(e.key) : void 0),
    pulse: p.pulse,
    clean: !i
  }));
  const m = ae(l);
  l = u = t.add(ir({
    pulse: m
  })), l = t.add(Bne({
    markdef: qie(e),
    interactive: Wie(e.interactive, t),
    clip: Uie(e.clip, t),
    context: {
      $context: !0
    },
    groups: t.lookup(),
    parent: t.signals.parent ? t.signalRef("parent") : null,
    index: t.markpath(),
    pulse: ae(l)
  }));
  const y = ae(l);
  l = c = t.add(S6(x6(e.encode, e.type, n, e.style, t, {
    mod: !1,
    pulse: y
  }))), l.params.parent = t.encode(), e.transform && e.transform.forEach((S) => {
    const E = L_(S, t), C = E.metadata;
    (C.generates || C.changes) && j("Mark transforms should not generate new data."), C.nomod || (c.params.mod = !0), E.params.pulse = ae(l), t.add(l = E);
  }), e.sort && (l = t.add(Xne({
    sort: t.compareRef(e.sort),
    pulse: ae(l)
  })));
  const b = ae(l);
  (r || o) && (o = t.add(C6({
    layout: t.objectProperty(e.layout),
    legends: t.legends,
    mark: y,
    pulse: b
  })), d = ae(o));
  const v = t.add(E6({
    mark: y,
    pulse: d || b
  }));
  h = ae(v), i && (g && (a = t.operators, a.pop(), o && a.pop()), t.pushState(b, d || h, m), r ? Qie(e, t, p) : g ? Zie(e, t, p) : t.parse(e), t.popState(), g && (o && a.push(o), a.push(v))), s && (h = ere(s, h, t));
  const _ = t.add(A6({
    pulse: h
  })), x = t.add(sl({
    pulse: ae(_)
  }, void 0, t.parent()));
  e.name != null && (f = e.name, t.addData(f, new za(t, u, _, x)), e.on && e.on.forEach((S) => {
    (S.insert || S.remove || S.toggle) && j("Marks only support modify triggers."), z6(S, t, f);
  }));
}
function ere(e, t, n) {
  const i = e.method, r = e.bound, s = e.separation, o = {
    separation: _t(s) ? n.signalRef(s.signal) : s,
    method: _t(i) ? n.signalRef(i.signal) : i,
    pulse: t
  };
  if (e.order && (o.sort = n.compareRef({
    field: e.order
  })), r) {
    const a = r.tolerance;
    o.boundTolerance = _t(a) ? n.signalRef(a.signal) : +a, o.boundScale = n.scaleRef(r.scale), o.boundOrient = r.orient;
  }
  return ae(n.add(qne(o)));
}
function tre(e, t) {
  const n = t.config.legend, i = e.encode || {}, r = Hn(e, n), s = i.legend || {}, o = s.name || void 0, a = s.interactive, l = s.style, u = {};
  let c = 0, f, d, h;
  T_.forEach((v) => e[v] ? (u[v] = e[v], c = c || e[v]) : 0), c || j("Missing valid scale for legend.");
  const g = nre(e, t.scaleType(c)), p = {
    title: e.title != null,
    scales: u,
    type: g,
    vgrad: g !== "symbol" && r.isVertical()
  }, m = ae(t.add(ir(null, [p]))), y = {
    enter: {
      x: {
        value: 0
      },
      y: {
        value: 0
      }
    }
  }, b = ae(t.add(Ine(d = {
    type: g,
    scale: t.scaleRef(c),
    count: t.objectProperty(r("tickCount")),
    limit: t.property(r("symbolLimit")),
    values: t.objectProperty(e.values),
    minstep: t.property(e.tickMinStep),
    formatType: t.property(e.formatType),
    formatSpecifier: t.property(e.format)
  })));
  return g === Zh ? (h = [$ie(e, c, n, i.gradient), g$(e, n, i.labels, b)], d.count = d.count || t.signalRef(`max(2,2*floor((${Ea(r.gradientLength())})/100))`)) : g === av ? h = [Mie(e, c, n, i.gradient, b), g$(e, n, i.labels, b)] : (f = Nie(e, n), h = [Oie(e, n, i, b, Ea(f.columns))], d.size = sre(e, t, h[0].marks)), h = [Wf({
    role: ene,
    from: m,
    encode: y,
    marks: h,
    layout: f,
    interactive: a
  })], p.title && h.push(jie(e, n, i.title, m)), Zm(Wf({
    role: Qte,
    from: m,
    encode: Vu(rre(r, e, n), s, $d),
    marks: h,
    aria: r("aria"),
    description: r("description"),
    zindex: r("zindex"),
    name: o,
    interactive: a,
    style: l
  }), t);
}
function nre(e, t) {
  let n = e.type || h$;
  return !e.type && ire(e) === 1 && (e.fill || e.stroke) && (n = O2(t) ? Zh : Qy(t) ? av : h$), n !== Zh ? n : Qy(t) ? av : Zh;
}
function ire(e) {
  return T_.reduce((t, n) => t + (e[n] ? 1 : 0), 0);
}
function rre(e, t, n) {
  const i = {
    enter: {},
    update: {}
  };
  return Ht(i, {
    orient: e("orient"),
    offset: e("offset"),
    padding: e("padding"),
    titlePadding: e("titlePadding"),
    cornerRadius: e("cornerRadius"),
    fill: e("fillColor"),
    stroke: e("strokeColor"),
    strokeWidth: n.strokeWidth,
    strokeDash: n.strokeDash,
    x: e("legendX"),
    y: e("legendY"),
    // accessibility support
    format: t.format,
    formatType: t.formatType
  }), i;
}
function sre(e, t, n) {
  const i = Ea(w$("size", e, n)), r = Ea(w$("strokeWidth", e, n)), s = Ea(ore(n[1].encode, t, Cd));
  return Nr(`max(ceil(sqrt(${i})+${r}),${s})`, t);
}
function w$(e, t, n) {
  return t[e] ? `scale("${t[e]}",datum)` : D6(e, n[0].encode);
}
function ore(e, t, n) {
  return D6("fontSize", e) || Aie("fontSize", t, n);
}
const are = `item.orient==="${Yu}"?-90:item.orient==="${Xu}"?90:0`;
function lre(e, t) {
  e = te(e) ? {
    text: e
  } : e;
  const n = Hn(e, t.config.title), i = e.encode || {}, r = i.group || {}, s = r.name || void 0, o = r.interactive, a = r.style, l = [], u = {}, c = ae(t.add(ir(null, [u])));
  return l.push(fre(e, n, ure(e), c)), e.subtitle && l.push(dre(e, n, i.subtitle, c)), Zm(Wf({
    role: rne,
    from: c,
    encode: cre(n, r),
    marks: l,
    aria: n("aria"),
    description: n("description"),
    zindex: n("zindex"),
    name: s,
    interactive: o,
    style: a
  }), t);
}
function ure(e) {
  const t = e.encode;
  return t && t.title || we({
    name: e.name,
    interactive: e.interactive,
    style: e.style
  }, t);
}
function cre(e, t) {
  const n = {
    enter: {},
    update: {}
  };
  return Ht(n, {
    orient: e("orient"),
    anchor: e("anchor"),
    align: {
      signal: N_
    },
    angle: {
      signal: are
    },
    limit: e("limit"),
    frame: e("frame"),
    offset: e("offset") || 0,
    padding: e("subtitlePadding")
  }), Vu(n, t, $d);
}
function fre(e, t, n, i) {
  const r = {
    value: 0
  }, s = e.text, o = {
    enter: {
      opacity: r
    },
    update: {
      opacity: {
        value: 1
      }
    },
    exit: {
      opacity: r
    }
  };
  return Ht(o, {
    text: s,
    align: {
      signal: "item.mark.group.align"
    },
    angle: {
      signal: "item.mark.group.angle"
    },
    limit: {
      signal: "item.mark.group.limit"
    },
    baseline: "top",
    dx: t("dx"),
    dy: t("dy"),
    fill: t("color"),
    font: t("font"),
    fontSize: t("fontSize"),
    fontStyle: t("fontStyle"),
    fontWeight: t("fontWeight"),
    lineHeight: t("lineHeight")
  }, {
    // update
    align: t("align"),
    angle: t("angle"),
    baseline: t("baseline")
  }), ai({
    type: ol,
    role: sne,
    style: yie,
    from: i,
    encode: o
  }, n);
}
function dre(e, t, n, i) {
  const r = {
    value: 0
  }, s = e.subtitle, o = {
    enter: {
      opacity: r
    },
    update: {
      opacity: {
        value: 1
      }
    },
    exit: {
      opacity: r
    }
  };
  return Ht(o, {
    text: s,
    align: {
      signal: "item.mark.group.align"
    },
    angle: {
      signal: "item.mark.group.angle"
    },
    limit: {
      signal: "item.mark.group.limit"
    },
    baseline: "top",
    dx: t("dx"),
    dy: t("dy"),
    fill: t("subtitleColor"),
    font: t("subtitleFont"),
    fontSize: t("subtitleFontSize"),
    fontStyle: t("subtitleFontStyle"),
    fontWeight: t("subtitleFontWeight"),
    lineHeight: t("subtitleLineHeight")
  }, {
    // update
    align: t("align"),
    angle: t("angle"),
    baseline: t("baseline")
  }), ai({
    type: ol,
    role: one,
    style: bie,
    from: i,
    encode: o
  }, n);
}
function hre(e, t) {
  const n = [];
  e.transform && e.transform.forEach((i) => {
    n.push(L_(i, t));
  }), e.on && e.on.forEach((i) => {
    z6(i, t, e.name);
  }), t.addDataPipeline(e.name, gre(e, t, n));
}
function gre(e, t, n) {
  const i = [];
  let r = null, s = !1, o = !1, a, l, u, c, f;
  for (e.values ? _t(e.values) || Jh(e.format) ? (i.push(_$(t, e)), i.push(r = Yo())) : i.push(r = Yo({
    $ingest: e.values,
    $format: e.format
  })) : e.url ? Jh(e.url) || Jh(e.format) ? (i.push(_$(t, e)), i.push(r = Yo())) : i.push(r = Yo({
    $request: e.url,
    $format: e.format
  })) : e.source && (r = a = ee(e.source).map((d) => ae(t.getData(d).output)), i.push(null)), l = 0, u = n.length; l < u; ++l)
    c = n[l], f = c.metadata, !r && !f.source && i.push(r = Yo()), i.push(c), f.generates && (o = !0), f.modifies && !o && (s = !0), f.source ? r = c : f.changes && (r = null);
  return a && (u = a.length - 1, i[0] = Vne({
    derive: s,
    pulse: u ? a : a[0]
  }), (s || u) && i.splice(1, 0, Yo())), r || i.push(Yo()), i.push(sl({})), i;
}
function Yo(e) {
  const t = ir({}, e);
  return t.metadata = {
    source: !0
  }, t;
}
function _$(e, t) {
  return zne({
    url: t.url ? e.property(t.url) : void 0,
    async: t.async ? e.property(t.async) : void 0,
    values: t.values ? e.property(t.values) : void 0,
    format: e.objectProperty(t.format)
  });
}
const B6 = (e) => e === Eo || e === rr, e0 = (e, t, n) => _t(e) ? bre(e.signal, t, n) : e === Yu || e === rr ? t : n, Nt = (e, t, n) => _t(e) ? mre(e.signal, t, n) : B6(e) ? t : n, Yi = (e, t, n) => _t(e) ? yre(e.signal, t, n) : B6(e) ? n : t, j6 = (e, t, n) => _t(e) ? vre(e.signal, t, n) : e === rr ? {
  value: t
} : {
  value: n
}, pre = (e, t, n) => _t(e) ? xre(e.signal, t, n) : e === Xu ? {
  value: t
} : {
  value: n
}, mre = (e, t, n) => U6(`${e} === '${rr}' || ${e} === '${Eo}'`, t, n), yre = (e, t, n) => U6(`${e} !== '${rr}' && ${e} !== '${Eo}'`, t, n), bre = (e, t, n) => P_(`${e} === '${Yu}' || ${e} === '${rr}'`, t, n), vre = (e, t, n) => P_(`${e} === '${rr}'`, t, n), xre = (e, t, n) => P_(`${e} === '${Xu}'`, t, n), U6 = (e, t, n) => (t = t != null ? Ot(t) : t, n = n != null ? Ot(n) : n, E$(t) && E$(n) ? (t = t ? t.signal || X(t.value) : null, n = n ? n.signal || X(n.value) : null, {
  signal: `${e} ? (${t}) : (${n})`
}) : [we({
  test: e
}, t)].concat(n || [])), E$ = (e) => e == null || Object.keys(e).length === 1, P_ = (e, t, n) => ({
  signal: `${e} ? (${zl(t)}) : (${zl(n)})`
}), wre = (e, t, n, i, r) => ({
  signal: (i != null ? `${e} === '${Yu}' ? (${zl(i)}) : ` : "") + (n != null ? `${e} === '${Eo}' ? (${zl(n)}) : ` : "") + (r != null ? `${e} === '${Xu}' ? (${zl(r)}) : ` : "") + (t != null ? `${e} === '${rr}' ? (${zl(t)}) : ` : "") + "(null)"
}), zl = (e) => _t(e) ? e.signal : e == null ? null : X(e), _re = (e, t) => t === 0 ? 0 : _t(e) ? {
  signal: `(${e.signal}) * ${t}`
} : {
  value: e * t
}, Hl = (e, t) => {
  const n = e.signal;
  return n && n.endsWith("(null)") ? {
    signal: n.slice(0, -6) + t.signal
  } : e;
};
function Sl(e, t, n, i) {
  let r;
  if (t && ce(t, e))
    return t[e];
  if (ce(n, e))
    return n[e];
  if (e.startsWith("title")) {
    switch (e) {
      case "titleColor":
        r = "fill";
        break;
      case "titleFont":
      case "titleFontSize":
      case "titleFontWeight":
        r = e[5].toLowerCase() + e.slice(6);
    }
    return i[F_][r];
  } else if (e.startsWith("label")) {
    switch (e) {
      case "labelColor":
        r = "fill";
        break;
      case "labelFont":
      case "labelFontSize":
        r = e[5].toLowerCase() + e.slice(6);
    }
    return i[Cd][r];
  }
  return null;
}
function S$(e) {
  const t = {};
  for (const n of e)
    if (n)
      for (const i in n)
        t[i] = 1;
  return Object.keys(t);
}
function Ere(e, t) {
  var n = t.config, i = n.style, r = n.axis, s = t.scaleType(e.scale) === "band" && n.axisBand, o = e.orient, a, l, u;
  if (_t(o)) {
    const f = S$([n.axisX, n.axisY]), d = S$([n.axisTop, n.axisBottom, n.axisLeft, n.axisRight]);
    a = {};
    for (u of f)
      a[u] = Nt(o, Sl(u, n.axisX, r, i), Sl(u, n.axisY, r, i));
    l = {};
    for (u of d)
      l[u] = wre(o.signal, Sl(u, n.axisTop, r, i), Sl(u, n.axisBottom, r, i), Sl(u, n.axisLeft, r, i), Sl(u, n.axisRight, r, i));
  } else
    a = o === rr || o === Eo ? n.axisX : n.axisY, l = n["axis" + o[0].toUpperCase() + o.slice(1)];
  return a || l || s ? we({}, r, a, l, s) : r;
}
function Sre(e, t, n, i) {
  const r = Hn(e, t), s = e.orient;
  let o, a;
  const l = {
    enter: o = {
      opacity: Ne
    },
    update: a = {
      opacity: wi
    },
    exit: {
      opacity: Ne
    }
  };
  Ht(l, {
    stroke: r("domainColor"),
    strokeCap: r("domainCap"),
    strokeDash: r("domainDash"),
    strokeDashOffset: r("domainDashOffset"),
    strokeWidth: r("domainWidth"),
    strokeOpacity: r("domainOpacity")
  });
  const u = k$(e, 0), c = k$(e, 1);
  return o.x = a.x = Nt(s, u, Ne), o.x2 = a.x2 = Nt(s, c), o.y = a.y = Yi(s, u, Ne), o.y2 = a.y2 = Yi(s, c), ai({
    type: O_,
    role: Vte,
    from: i,
    encode: l
  }, n);
}
function k$(e, t) {
  return {
    scale: e.scale,
    range: t
  };
}
function kre(e, t, n, i, r) {
  const s = Hn(e, t), o = e.orient, a = e.gridScale, l = e0(o, 1, -1), u = Are(e.offset, l);
  let c, f, d;
  const h = {
    enter: c = {
      opacity: Ne
    },
    update: d = {
      opacity: wi
    },
    exit: f = {
      opacity: Ne
    }
  };
  Ht(h, {
    stroke: s("gridColor"),
    strokeCap: s("gridCap"),
    strokeDash: s("gridDash"),
    strokeDashOffset: s("gridDashOffset"),
    strokeOpacity: s("gridOpacity"),
    strokeWidth: s("gridWidth")
  });
  const g = {
    scale: e.scale,
    field: xi,
    band: r.band,
    extra: r.extra,
    offset: r.offset,
    round: s("tickRound")
  }, p = Nt(o, {
    signal: "height"
  }, {
    signal: "width"
  }), m = a ? {
    scale: a,
    range: 0,
    mult: l,
    offset: u
  } : {
    value: 0,
    offset: u
  }, y = a ? {
    scale: a,
    range: 1,
    mult: l,
    offset: u
  } : we(p, {
    mult: l,
    offset: u
  });
  return c.x = d.x = Nt(o, g, m), c.y = d.y = Yi(o, g, m), c.x2 = d.x2 = Yi(o, y), c.y2 = d.y2 = Nt(o, y), f.x = Nt(o, g), f.y = Yi(o, g), ai({
    type: O_,
    role: Yte,
    key: xi,
    from: i,
    encode: h
  }, n);
}
function Are(e, t) {
  if (t !== 1)
    if (!ne(e))
      e = _t(t) ? {
        signal: `(${t.signal}) * (${e || 0})`
      } : t * (e || 0);
    else {
      let n = e = we({}, e);
      for (; n.mult != null; )
        if (ne(n.mult))
          n = n.mult = we({}, n.mult);
        else
          return n.mult = _t(t) ? {
            signal: `(${n.mult}) * (${t.signal})`
          } : n.mult * t, e;
      n.mult = t;
    }
  return e;
}
function Cre(e, t, n, i, r, s) {
  const o = Hn(e, t), a = e.orient, l = e0(a, -1, 1);
  let u, c, f;
  const d = {
    enter: u = {
      opacity: Ne
    },
    update: f = {
      opacity: wi
    },
    exit: c = {
      opacity: Ne
    }
  };
  Ht(d, {
    stroke: o("tickColor"),
    strokeCap: o("tickCap"),
    strokeDash: o("tickDash"),
    strokeDashOffset: o("tickDashOffset"),
    strokeOpacity: o("tickOpacity"),
    strokeWidth: o("tickWidth")
  });
  const h = Ot(r);
  h.mult = l;
  const g = {
    scale: e.scale,
    field: xi,
    band: s.band,
    extra: s.extra,
    offset: s.offset,
    round: o("tickRound")
  };
  return f.y = u.y = Nt(a, Ne, g), f.y2 = u.y2 = Nt(a, h), c.x = Nt(a, g), f.x = u.x = Yi(a, Ne, g), f.x2 = u.x2 = Yi(a, h), c.y = Yi(a, g), ai({
    type: O_,
    role: Kte,
    key: xi,
    from: i,
    encode: d
  }, n);
}
function Q1(e, t, n, i, r) {
  return {
    signal: 'flush(range("' + e + '"), scale("' + e + '", datum.value), ' + t + "," + n + "," + i + "," + r + ")"
  };
}
function $re(e, t, n, i, r, s) {
  const o = Hn(e, t), a = e.orient, l = e.scale, u = e0(a, -1, 1), c = Ea(o("labelFlush")), f = Ea(o("labelFlushOffset")), d = o("labelAlign"), h = o("labelBaseline");
  let g = c === 0 || !!c, p;
  const m = Ot(r);
  m.mult = u, m.offset = Ot(o("labelPadding") || 0), m.offset.mult = u;
  const y = {
    scale: l,
    field: xi,
    band: 0.5,
    offset: R6(s.offset, o("labelOffset"))
  }, b = Nt(a, g ? Q1(l, c, '"left"', '"right"', '"center"') : {
    value: "center"
  }, pre(a, "left", "right")), v = Nt(a, j6(a, "bottom", "top"), g ? Q1(l, c, '"top"', '"bottom"', '"middle"') : {
    value: "middle"
  }), _ = Q1(l, c, `-(${f})`, f, 0);
  g = g && f;
  const x = {
    opacity: Ne,
    x: Nt(a, y, m),
    y: Yi(a, y, m)
  }, S = {
    enter: x,
    update: p = {
      opacity: wi,
      text: {
        field: M_
      },
      x: x.x,
      y: x.y,
      align: b,
      baseline: v
    },
    exit: {
      opacity: Ne,
      x: x.x,
      y: x.y
    }
  };
  Ht(S, {
    dx: !d && g ? Nt(a, _) : null,
    dy: !h && g ? Yi(a, _) : null
  }), Ht(S, {
    angle: o("labelAngle"),
    fill: o("labelColor"),
    fillOpacity: o("labelOpacity"),
    font: o("labelFont"),
    fontSize: o("labelFontSize"),
    fontWeight: o("labelFontWeight"),
    fontStyle: o("labelFontStyle"),
    limit: o("labelLimit"),
    lineHeight: o("labelLineHeight")
  }, {
    align: d,
    baseline: h
  });
  const E = o("labelBound");
  let C = o("labelOverlap");
  return C = C || E ? {
    separation: o("labelSeparation"),
    method: C,
    order: "datum.index",
    bound: E ? {
      scale: l,
      orient: a,
      tolerance: E
    } : null
  } : void 0, p.align !== b && (p.align = Hl(p.align, b)), p.baseline !== v && (p.baseline = Hl(p.baseline, v)), ai({
    type: ol,
    role: Xte,
    style: Cd,
    key: xi,
    from: i,
    encode: S,
    overlap: C
  }, n);
}
function Mre(e, t, n, i) {
  const r = Hn(e, t), s = e.orient, o = e0(s, -1, 1);
  let a, l;
  const u = {
    enter: a = {
      opacity: Ne,
      anchor: Ot(r("titleAnchor", null)),
      align: {
        signal: N_
      }
    },
    update: l = we({}, a, {
      opacity: wi,
      text: Ot(e.title)
    }),
    exit: {
      opacity: Ne
    }
  }, c = {
    signal: `lerp(range("${e.scale}"), ${Jm(0, 1, 0.5)})`
  };
  return l.x = Nt(s, c), l.y = Yi(s, c), a.angle = Nt(s, Ne, _re(o, 90)), a.baseline = Nt(s, j6(s, Eo, rr), {
    value: Eo
  }), l.angle = a.angle, l.baseline = a.baseline, Ht(u, {
    fill: r("titleColor"),
    fillOpacity: r("titleOpacity"),
    font: r("titleFont"),
    fontSize: r("titleFontSize"),
    fontStyle: r("titleFontStyle"),
    fontWeight: r("titleFontWeight"),
    limit: r("titleLimit"),
    lineHeight: r("titleLineHeight")
  }, {
    // require update
    align: r("titleAlign"),
    angle: r("titleAngle"),
    baseline: r("titleBaseline")
  }), Fre(r, s, u, n), u.update.align = Hl(u.update.align, a.align), u.update.angle = Hl(u.update.angle, a.angle), u.update.baseline = Hl(u.update.baseline, a.baseline), ai({
    type: ol,
    role: Jte,
    style: F_,
    from: i,
    encode: u
  }, n);
}
function Fre(e, t, n, i) {
  const r = (a, l) => a != null ? (n.update[l] = Hl(Ot(a), n.update[l]), !1) : !Ol(l, i), s = r(e("titleX"), "x"), o = r(e("titleY"), "y");
  n.enter.auto = o === s ? Ot(o) : Nt(t, Ot(o), Ot(s));
}
function Tre(e, t) {
  const n = Ere(e, t), i = e.encode || {}, r = i.axis || {}, s = r.name || void 0, o = r.interactive, a = r.style, l = Hn(e, n), u = Cie(l), c = {
    scale: e.scale,
    ticks: !!l("ticks"),
    labels: !!l("labels"),
    grid: !!l("grid"),
    domain: !!l("domain"),
    title: e.title != null
  }, f = ae(t.add(ir({}, [c]))), d = ae(t.add(One({
    scale: t.scaleRef(e.scale),
    extra: t.property(u.extra),
    count: t.objectProperty(e.tickCount),
    values: t.objectProperty(e.values),
    minstep: t.property(e.tickMinStep),
    formatType: t.property(e.formatType),
    formatSpecifier: t.property(e.format)
  }))), h = [];
  let g;
  return c.grid && h.push(kre(e, n, i.grid, d, u)), c.ticks && (g = l("tickSize"), h.push(Cre(e, n, i.ticks, d, g, u))), c.labels && (g = c.ticks ? g : 0, h.push($re(e, n, i.labels, d, g, u))), c.domain && h.push(Sre(e, n, i.domain, f)), c.title && h.push(Mre(e, n, i.title, f)), Zm(Wf({
    role: Gte,
    from: f,
    encode: Vu(Ore(l, e), r, $d),
    marks: h,
    aria: l("aria"),
    description: l("description"),
    zindex: l("zindex"),
    name: s,
    interactive: o,
    style: a
  }), t);
}
function Ore(e, t) {
  const n = {
    enter: {},
    update: {}
  };
  return Ht(n, {
    orient: e("orient"),
    offset: e("offset") || 0,
    position: Ii(t.position, 0),
    titlePadding: e("titlePadding"),
    minExtent: e("minExtent"),
    maxExtent: e("maxExtent"),
    range: {
      signal: `abs(span(range("${t.scale}")))`
    },
    translate: e("translate"),
    // accessibility support
    format: t.format,
    formatType: t.formatType
  }), n;
}
function q6(e, t, n) {
  const i = ee(e.signals), r = ee(e.scales);
  return n || i.forEach((s) => w6(s, t)), ee(e.projections).forEach((s) => cie(s, t)), r.forEach((s) => Qne(s, t)), ee(e.data).forEach((s) => hre(s, t)), r.forEach((s) => Zne(s, t)), (n || i).forEach((s) => Tne(s, t)), ee(e.axes).forEach((s) => Tre(s, t)), ee(e.marks).forEach((s) => Zm(s, t)), ee(e.legends).forEach((s) => tre(s, t)), e.title && lre(e.title, t), t.parseLambdas(), t;
}
const Nre = (e) => Vu({
  enter: {
    x: {
      value: 0
    },
    y: {
      value: 0
    }
  },
  update: {
    width: {
      signal: "width"
    },
    height: {
      signal: "height"
    }
  }
}, e);
function Dre(e, t) {
  const n = t.config, i = ae(t.root = t.add(vp())), r = Rre(e, n);
  r.forEach((u) => w6(u, t)), t.description = e.description || n.description, t.eventConfig = n.events, t.legends = t.objectProperty(n.legend && n.legend.layout), t.locale = n.locale;
  const s = t.add(ir()), o = t.add(S6(x6(Nre(e.encode), Km, k_, e.style, t, {
    pulse: ae(s)
  }))), a = t.add(C6({
    layout: t.objectProperty(e.layout),
    legends: t.legends,
    autosize: t.signalRef("autosize"),
    mark: i,
    pulse: ae(o)
  }));
  t.operators.pop(), t.pushState(ae(o), ae(a), null), q6(e, t, r), t.operators.push(a);
  let l = t.add(E6({
    mark: i,
    pulse: ae(a)
  }));
  return l = t.add(A6({
    pulse: ae(l)
  })), l = t.add(sl({
    pulse: ae(l)
  })), t.addData("root", new za(t, s, s, l)), t;
}
function _c(e, t) {
  return t && t.signal ? {
    name: e,
    update: t.signal
  } : {
    name: e,
    value: t
  };
}
function Rre(e, t) {
  const n = (o) => Ii(e[o], t[o]), i = [_c("background", n("background")), _c("autosize", qte(n("autosize"))), _c("padding", Hte(n("padding"))), _c("width", n("width") || 0), _c("height", n("height") || 0)], r = i.reduce((o, a) => (o[a.name] = a, o), {}), s = {};
  return ee(e.signals).forEach((o) => {
    ce(r, o.name) ? o = we(r[o.name], o) : i.push(o), s[o.name] = o;
  }), ee(t.signals).forEach((o) => {
    !ce(s, o.name) && !ce(r, o.name) && i.push(o);
  }), i;
}
function W6(e, t) {
  this.config = e || {}, this.options = t || {}, this.bindings = [], this.field = {}, this.signals = {}, this.lambdas = {}, this.scales = {}, this.events = {}, this.data = {}, this.streams = [], this.updates = [], this.operators = [], this.eventConfig = null, this.locale = null, this._id = 0, this._subid = 0, this._nextsub = [0], this._parent = [], this._encode = [], this._lookup = [], this._markpath = [];
}
function A$(e) {
  this.config = e.config, this.options = e.options, this.legends = e.legends, this.field = Object.create(e.field), this.signals = Object.create(e.signals), this.lambdas = Object.create(e.lambdas), this.scales = Object.create(e.scales), this.events = Object.create(e.events), this.data = Object.create(e.data), this.streams = [], this.updates = [], this.operators = [], this._id = 0, this._subid = ++e._nextsub[0], this._nextsub = e._nextsub, this._parent = e._parent.slice(), this._encode = e._encode.slice(), this._lookup = e._lookup.slice(), this._markpath = e._markpath;
}
W6.prototype = A$.prototype = {
  parse(e) {
    return q6(e, this);
  },
  fork() {
    return new A$(this);
  },
  isSubscope() {
    return this._subid > 0;
  },
  toRuntime() {
    return this.finish(), {
      description: this.description,
      operators: this.operators,
      streams: this.streams,
      updates: this.updates,
      bindings: this.bindings,
      eventConfig: this.eventConfig,
      locale: this.locale
    };
  },
  id() {
    return (this._subid ? this._subid + ":" : 0) + this._id++;
  },
  add(e) {
    return this.operators.push(e), e.id = this.id(), e.refs && (e.refs.forEach((t) => {
      t.$ref = e.id;
    }), e.refs = null), e;
  },
  proxy(e) {
    const t = e instanceof nv ? ae(e) : e;
    return this.add(Gne({
      value: t
    }));
  },
  addStream(e) {
    return this.streams.push(e), e.id = this.id(), e;
  },
  addUpdate(e) {
    return this.updates.push(e), e;
  },
  // Apply metadata
  finish() {
    let e, t;
    this.root && (this.root.root = !0);
    for (e in this.signals)
      this.signals[e].signal = e;
    for (e in this.scales)
      this.scales[e].scale = e;
    function n(i, r, s) {
      let o, a;
      i && (o = i.data || (i.data = {}), a = o[r] || (o[r] = []), a.push(s));
    }
    for (e in this.data) {
      t = this.data[e], n(t.input, e, "input"), n(t.output, e, "output"), n(t.values, e, "values");
      for (const i in t.index)
        n(t.index[i], e, "index:" + i);
    }
    return this;
  },
  // ----
  pushState(e, t, n) {
    this._encode.push(ae(this.add(sl({
      pulse: e
    })))), this._parent.push(t), this._lookup.push(n ? ae(this.proxy(n)) : null), this._markpath.push(-1);
  },
  popState() {
    this._encode.pop(), this._parent.pop(), this._lookup.pop(), this._markpath.pop();
  },
  parent() {
    return Te(this._parent);
  },
  encode() {
    return Te(this._encode);
  },
  lookup() {
    return Te(this._lookup);
  },
  markpath() {
    const e = this._markpath;
    return ++e[e.length - 1];
  },
  // ----
  fieldRef(e, t) {
    if (te(e))
      return Uf(e, t);
    e.signal || j("Unsupported field reference: " + X(e));
    const n = e.signal;
    let i = this.field[n];
    if (!i) {
      const r = {
        name: this.signalRef(n)
      };
      t && (r.as = t), this.field[n] = i = ae(this.add(Lne(r)));
    }
    return i;
  },
  compareRef(e) {
    let t = !1;
    const n = (s) => _t(s) ? (t = !0, this.signalRef(s.signal)) : wne(s) ? (t = !0, this.exprRef(s.expr)) : s, i = ee(e.field).map(n), r = ee(e.order).map(n);
    return t ? ae(this.add(d$({
      fields: i,
      orders: r
    }))) : c$(i, r);
  },
  keyRef(e, t) {
    let n = !1;
    const i = (s) => _t(s) ? (n = !0, ae(r[s.signal])) : s, r = this.signals;
    return e = ee(e).map(i), n ? ae(this.add(Pne({
      fields: e,
      flat: t
    }))) : yne(e, t);
  },
  sortRef(e) {
    if (!e)
      return e;
    const t = Ym(e.op, e.field), n = e.order || bne;
    return n.signal ? ae(this.add(d$({
      fields: t,
      orders: this.signalRef(n.signal)
    }))) : c$(t, n);
  },
  // ----
  event(e, t) {
    const n = e + ":" + t;
    if (!this.events[n]) {
      const i = this.id();
      this.streams.push({
        id: i,
        source: e,
        type: t
      }), this.events[n] = i;
    }
    return this.events[n];
  },
  // ----
  hasOwnSignal(e) {
    return ce(this.signals, e);
  },
  addSignal(e, t) {
    this.hasOwnSignal(e) && j("Duplicate signal name: " + X(e));
    const n = t instanceof nv ? t : this.add(vp(t));
    return this.signals[e] = n;
  },
  getSignal(e) {
    return this.signals[e] || j("Unrecognized signal name: " + X(e)), this.signals[e];
  },
  signalRef(e) {
    return this.signals[e] ? ae(this.signals[e]) : (ce(this.lambdas, e) || (this.lambdas[e] = this.add(vp(null))), ae(this.lambdas[e]));
  },
  parseLambdas() {
    const e = Object.keys(this.lambdas);
    for (let t = 0, n = e.length; t < n; ++t) {
      const i = e[t], r = Nr(i, this), s = this.lambdas[i];
      s.params = r.$params, s.update = r.$expr;
    }
  },
  property(e) {
    return e && e.signal ? this.signalRef(e.signal) : e;
  },
  objectProperty(e) {
    return !e || !ne(e) ? e : this.signalRef(e.signal || I_(e));
  },
  exprRef(e, t) {
    const n = {
      expr: Nr(e, this)
    };
    return t && (n.expr.$name = t), ae(this.add(Dne(n)));
  },
  addBinding(e, t) {
    this.bindings || j("Nested signals do not support binding: " + X(e)), this.bindings.push(we({
      signal: e
    }, t));
  },
  // ----
  addScaleProj(e, t) {
    ce(this.scales, e) && j("Duplicate scale or projection name: " + X(e)), this.scales[e] = this.add(t);
  },
  addScale(e, t) {
    this.addScaleProj(e, Yne(t));
  },
  addProjection(e, t) {
    this.addScaleProj(e, Hne(t));
  },
  getScale(e) {
    return this.scales[e] || j("Unrecognized scale name: " + X(e)), this.scales[e];
  },
  scaleRef(e) {
    return ae(this.getScale(e));
  },
  scaleType(e) {
    return this.getScale(e).params.type;
  },
  projectionRef(e) {
    return this.scaleRef(e);
  },
  projectionType(e) {
    return this.scaleType(e);
  },
  // ----
  addData(e, t) {
    return ce(this.data, e) && j("Duplicate data set name: " + X(e)), this.data[e] = t;
  },
  getData(e) {
    return this.data[e] || j("Undefined data set name: " + X(e)), this.data[e];
  },
  addDataPipeline(e, t) {
    return ce(this.data, e) && j("Duplicate data set name: " + X(e)), this.addData(e, za.fromEntries(this, t));
  }
};
function I_(e) {
  return (U(e) ? Lre : Pre)(e);
}
function Lre(e) {
  const t = e.length;
  let n = "[";
  for (let i = 0; i < t; ++i) {
    const r = e[i];
    n += (i > 0 ? "," : "") + (ne(r) ? r.signal || I_(r) : X(r));
  }
  return n + "]";
}
function Pre(e) {
  let t = "{", n = 0, i, r;
  for (i in e)
    r = e[i], t += (++n > 1 ? "," : "") + X(i) + ":" + (ne(r) ? r.signal || I_(r) : X(r));
  return t + "}";
}
function Ire() {
  const e = "sans-serif", i = "#4c78a8", r = "#000", s = "#888", o = "#ddd";
  return {
    // default visualization description
    description: "Vega visualization",
    // default padding around visualization
    padding: 0,
    // default for automatic sizing; options: 'none', 'pad', 'fit'
    // or provide an object (e.g., {'type': 'pad', 'resize': true})
    autosize: "pad",
    // default view background color
    // covers the entire view component
    background: null,
    // default event handling configuration
    // preventDefault for view-sourced event types except 'wheel'
    events: {
      defaults: {
        allow: ["wheel"]
      }
    },
    // defaults for top-level group marks
    // accepts mark properties (fill, stroke, etc)
    // covers the data rectangle within group width/height
    group: null,
    // defaults for basic mark types
    // each subset accepts mark properties (fill, stroke, etc)
    mark: null,
    arc: {
      fill: i
    },
    area: {
      fill: i
    },
    image: null,
    line: {
      stroke: i,
      strokeWidth: 2
    },
    path: {
      stroke: i
    },
    rect: {
      fill: i
    },
    rule: {
      stroke: r
    },
    shape: {
      stroke: i
    },
    symbol: {
      fill: i,
      size: 64
    },
    text: {
      fill: r,
      font: e,
      fontSize: 11
    },
    trail: {
      fill: i,
      size: 2
    },
    // style definitions
    style: {
      // axis & legend labels
      "guide-label": {
        fill: r,
        font: e,
        fontSize: 10
      },
      // axis & legend titles
      "guide-title": {
        fill: r,
        font: e,
        fontSize: 11,
        fontWeight: "bold"
      },
      // headers, including chart title
      "group-title": {
        fill: r,
        font: e,
        fontSize: 13,
        fontWeight: "bold"
      },
      // chart subtitle
      "group-subtitle": {
        fill: r,
        font: e,
        fontSize: 12
      },
      // defaults for styled point marks in Vega-Lite
      point: {
        size: 30,
        strokeWidth: 2,
        shape: "circle"
      },
      circle: {
        size: 30,
        strokeWidth: 2
      },
      square: {
        size: 30,
        strokeWidth: 2,
        shape: "square"
      },
      // defaults for styled group marks in Vega-Lite
      cell: {
        fill: "transparent",
        stroke: o
      },
      view: {
        fill: "transparent"
      }
    },
    // defaults for title
    title: {
      orient: "top",
      anchor: "middle",
      offset: 4,
      subtitlePadding: 3
    },
    // defaults for axes
    axis: {
      minExtent: 0,
      maxExtent: 200,
      bandPosition: 0.5,
      domain: !0,
      domainWidth: 1,
      domainColor: s,
      grid: !1,
      gridWidth: 1,
      gridColor: o,
      labels: !0,
      labelAngle: 0,
      labelLimit: 180,
      labelOffset: 0,
      labelPadding: 2,
      ticks: !0,
      tickColor: s,
      tickOffset: 0,
      tickRound: !0,
      tickSize: 5,
      tickWidth: 1,
      titlePadding: 4
    },
    // correction for centering bias
    axisBand: {
      tickOffset: -0.5
    },
    // defaults for cartographic projection
    projection: {
      type: "mercator"
    },
    // defaults for legends
    legend: {
      orient: "right",
      padding: 0,
      gridAlign: "each",
      columnPadding: 10,
      rowPadding: 2,
      symbolDirection: "vertical",
      gradientDirection: "vertical",
      gradientLength: 200,
      gradientThickness: 16,
      gradientStrokeColor: o,
      gradientStrokeWidth: 0,
      gradientLabelOffset: 2,
      labelAlign: "left",
      labelBaseline: "middle",
      labelLimit: 160,
      labelOffset: 4,
      labelOverlap: !0,
      symbolLimit: 30,
      symbolType: "circle",
      symbolSize: 100,
      symbolOffset: 0,
      symbolStrokeWidth: 1.5,
      symbolBaseFillColor: "transparent",
      symbolBaseStrokeColor: s,
      titleLimit: 180,
      titleOrient: "top",
      titlePadding: 5,
      layout: {
        offset: 18,
        direction: "horizontal",
        left: {
          direction: "vertical"
        },
        right: {
          direction: "vertical"
        }
      }
    },
    // defaults for scale ranges
    range: {
      category: {
        scheme: "tableau10"
      },
      ordinal: {
        scheme: "blues"
      },
      heatmap: {
        scheme: "yellowgreenblue"
      },
      ramp: {
        scheme: "blues"
      },
      diverging: {
        scheme: "blueorange",
        extent: [1, 0]
      },
      symbol: ["circle", "square", "triangle-up", "cross", "diamond", "triangle-right", "triangle-down", "triangle-left"]
    }
  };
}
function zre(e, t, n) {
  return ne(e) || j("Input Vega specification must be an object."), t = Du(Ire(), t, e.config), Dre(e, new W6(t, n)).toRuntime();
}
var Bre = "5.27.0";
we(ru, HB, dG, WG, MY, EX, KK, MK, QK, _J, OJ, zJ);
const jre = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Bounds: pt,
  CanvasHandler: wo,
  CanvasRenderer: Of,
  DATE: zn,
  DAY: Qt,
  DAYOFYEAR: Tr,
  Dataflow: jl,
  Debug: U3,
  Error: Gv,
  EventStream: em,
  Gradient: LO,
  GroupItem: Em,
  HOURS: ri,
  Handler: xo,
  HybridHandler: dw,
  HybridRenderer: Rg,
  Info: j3,
  Item: _m,
  MILLISECONDS: Qi,
  MINUTES: si,
  MONTH: rn,
  Marks: oi,
  MultiPulse: yx,
  None: B3,
  Operator: Xe,
  Parameters: Zp,
  Pulse: ao,
  QUARTER: In,
  RenderType: Zs,
  Renderer: ui,
  ResourceLoader: j2,
  SECONDS: Si,
  SVGHandler: sw,
  SVGRenderer: Tm,
  SVGStringRenderer: fw,
  Scenegraph: iw,
  TIME_UNITS: ax,
  Transform: I,
  View: l6,
  WEEK: xt,
  Warn: Vv,
  YEAR: qt,
  accessor: Wn,
  accessorFields: nn,
  accessorName: ut,
  array: ee,
  ascending: Up,
  bandwidthNRD: wx,
  bin: ET,
  bootstrapCI: ST,
  boundClip: NN,
  boundContext: pd,
  boundItem: rb,
  boundMark: tN,
  boundStroke: Fs,
  changeset: tl,
  clampRange: Z3,
  codegenExpression: RR,
  compare: Qv,
  constant: ln,
  cumulativeLogNormal: Cx,
  cumulativeNormal: nm,
  cumulativeUniform: Tx,
  dayofyear: FF,
  debounce: Zv,
  defaultLocale: dx,
  definition: xT,
  densityLogNormal: Ax,
  densityNormal: _x,
  densityUniform: Fx,
  domChild: vt,
  domClear: di,
  domCreate: Js,
  domFind: rw,
  dotbin: kT,
  error: j,
  expressionFunction: gt,
  extend: we,
  extent: $r,
  extentIndex: eF,
  falsy: js,
  fastmap: Lu,
  field: _i,
  flush: tF,
  font: $m,
  fontFamily: bd,
  fontSize: zr,
  format: Oh,
  formatLocale: dg,
  formats: px,
  hasOwnProperty: ce,
  id: ed,
  identity: an,
  inferType: uT,
  inferTypes: cT,
  ingest: je,
  inherits: Y,
  inrange: Dl,
  interpolate: N2,
  interpolateColors: xm,
  interpolateRange: _O,
  intersect: MN,
  intersectBoxLine: Rl,
  intersectPath: U2,
  intersectPoint: q2,
  intersectRule: WO,
  isArray: U,
  isBoolean: To,
  isDate: so,
  isFunction: Ee,
  isIterable: nF,
  isNumber: Re,
  isObject: ne,
  isRegExp: iF,
  isString: te,
  isTuple: Jp,
  key: ex,
  lerp: rF,
  lineHeight: bo,
  loader: Xp,
  locale: aT,
  logger: Yv,
  lruCache: sF,
  markup: cw,
  merge: oF,
  mergeConfig: Du,
  multiLineOffset: ew,
  one: Nu,
  pad: aF,
  panLinear: V3,
  panLog: Y3,
  panPow: X3,
  panSymlog: K3,
  parse: zre,
  parseExpression: f_,
  parseSelector: Po,
  path: am,
  pathCurves: I2,
  pathEqual: DN,
  pathParse: cu,
  pathRectangle: zO,
  pathRender: $f,
  pathSymbols: IO,
  pathTrail: BO,
  peek: Te,
  point: Fm,
  projection: Tw,
  quantileLogNormal: $x,
  quantileNormal: im,
  quantileUniform: Ox,
  quantiles: vx,
  quantizeInterpolator: EO,
  quarter: J3,
  quartiles: xx,
  get random() {
    return ki;
  },
  randomInteger: X7,
  randomKDE: Sx,
  randomLCG: Y7,
  randomLogNormal: CT,
  randomMixture: $T,
  randomNormal: Ex,
  randomUniform: MT,
  read: hT,
  regressionConstant: Nx,
  regressionExp: TT,
  regressionLinear: Dx,
  regressionLoess: DT,
  regressionLog: FT,
  regressionPoly: NT,
  regressionPow: OT,
  regressionQuad: Rx,
  renderModule: Om,
  repeat: Fc,
  resetDefaultLocale: Hz,
  resetSVGClipId: UO,
  resetSVGDefIds: FH,
  responseType: dT,
  runtimeContext: XR,
  sampleCurve: sm,
  sampleLogNormal: kx,
  sampleNormal: tm,
  sampleUniform: Mx,
  scale: ze,
  sceneEqual: hw,
  sceneFromJSON: iN,
  scenePickVisit: Ag,
  sceneToJSON: nN,
  sceneVisit: Zi,
  sceneZOrder: W2,
  scheme: D2,
  serializeXML: xN,
  setHybridRendererOptions: AH,
  setRandom: G7,
  span: td,
  splitAccessPath: Pr,
  stringValue: X,
  textMetrics: ti,
  timeBin: VF,
  timeFloor: PF,
  timeFormatLocale: _f,
  timeInterval: Bu,
  timeOffset: BF,
  timeSequence: qF,
  timeUnitSpecifier: MF,
  timeUnits: lx,
  toBoolean: tx,
  toDate: nx,
  toNumber: Zt,
  toSet: Ji,
  toString: ix,
  transform: wT,
  transforms: ru,
  truncate: lF,
  truthy: Ei,
  tupleid: le,
  typeParsers: By,
  utcFloor: IF,
  utcInterval: ju,
  utcOffset: jF,
  utcSequence: WF,
  utcdayofyear: NF,
  utcquarter: Q3,
  utcweek: DF,
  version: Bre,
  visitArray: Ws,
  week: TF,
  writeConfig: Ru,
  zero: Xs,
  zoomLinear: Xv,
  zoomLog: Kv,
  zoomPow: og,
  zoomSymlog: Jv
}, Symbol.toStringTag, { value: "Module" }));
function Ure(e, t, n) {
  let i;
  t.x2 && (t.x ? (n && e.x > e.x2 && (i = e.x, e.x = e.x2, e.x2 = i), e.width = e.x2 - e.x) : e.x = e.x2 - (e.width || 0)), t.xc && (e.x = e.xc - (e.width || 0) / 2), t.y2 && (t.y ? (n && e.y > e.y2 && (i = e.y, e.y = e.y2, e.y2 = i), e.height = e.y2 - e.y) : e.y = e.y2 - (e.height || 0)), t.yc && (e.y = e.yc - (e.height || 0) / 2);
}
var qre = {
  NaN: NaN,
  E: Math.E,
  LN2: Math.LN2,
  LN10: Math.LN10,
  LOG2E: Math.LOG2E,
  LOG10E: Math.LOG10E,
  PI: Math.PI,
  SQRT1_2: Math.SQRT1_2,
  SQRT2: Math.SQRT2,
  MIN_VALUE: Number.MIN_VALUE,
  MAX_VALUE: Number.MAX_VALUE
}, Wre = {
  "*": (e, t) => e * t,
  "+": (e, t) => e + t,
  "-": (e, t) => e - t,
  "/": (e, t) => e / t,
  "%": (e, t) => e % t,
  ">": (e, t) => e > t,
  "<": (e, t) => e < t,
  "<=": (e, t) => e <= t,
  ">=": (e, t) => e >= t,
  "==": (e, t) => e == t,
  "!=": (e, t) => e != t,
  "===": (e, t) => e === t,
  "!==": (e, t) => e !== t,
  "&": (e, t) => e & t,
  "|": (e, t) => e | t,
  "^": (e, t) => e ^ t,
  "<<": (e, t) => e << t,
  ">>": (e, t) => e >> t,
  ">>>": (e, t) => e >>> t
}, Hre = {
  "+": (e) => +e,
  "-": (e) => -e,
  "~": (e) => ~e,
  "!": (e) => !e
};
const Gre = Array.prototype.slice, Xo = (e, t, n) => {
  const i = n ? n(t[0]) : t[0];
  return i[e].apply(i, Gre.call(t, 1));
}, Vre = (e, t, n, i, r, s, o) => new Date(e, t || 0, n ?? 1, i || 0, r || 0, s || 0, o || 0);
var Yre = {
  // math functions
  isNaN: Number.isNaN,
  isFinite: Number.isFinite,
  abs: Math.abs,
  acos: Math.acos,
  asin: Math.asin,
  atan: Math.atan,
  atan2: Math.atan2,
  ceil: Math.ceil,
  cos: Math.cos,
  exp: Math.exp,
  floor: Math.floor,
  log: Math.log,
  max: Math.max,
  min: Math.min,
  pow: Math.pow,
  random: Math.random,
  round: Math.round,
  sin: Math.sin,
  sqrt: Math.sqrt,
  tan: Math.tan,
  clamp: (e, t, n) => Math.max(t, Math.min(n, e)),
  // date functions
  now: Date.now,
  utc: Date.UTC,
  datetime: Vre,
  date: (e) => new Date(e).getDate(),
  day: (e) => new Date(e).getDay(),
  year: (e) => new Date(e).getFullYear(),
  month: (e) => new Date(e).getMonth(),
  hours: (e) => new Date(e).getHours(),
  minutes: (e) => new Date(e).getMinutes(),
  seconds: (e) => new Date(e).getSeconds(),
  milliseconds: (e) => new Date(e).getMilliseconds(),
  time: (e) => new Date(e).getTime(),
  timezoneoffset: (e) => new Date(e).getTimezoneOffset(),
  utcdate: (e) => new Date(e).getUTCDate(),
  utcday: (e) => new Date(e).getUTCDay(),
  utcyear: (e) => new Date(e).getUTCFullYear(),
  utcmonth: (e) => new Date(e).getUTCMonth(),
  utchours: (e) => new Date(e).getUTCHours(),
  utcminutes: (e) => new Date(e).getUTCMinutes(),
  utcseconds: (e) => new Date(e).getUTCSeconds(),
  utcmilliseconds: (e) => new Date(e).getUTCMilliseconds(),
  // sequence functions
  length: (e) => e.length,
  join: function() {
    return Xo("join", arguments);
  },
  indexof: function() {
    return Xo("indexOf", arguments);
  },
  lastindexof: function() {
    return Xo("lastIndexOf", arguments);
  },
  slice: function() {
    return Xo("slice", arguments);
  },
  reverse: (e) => e.slice().reverse(),
  // string functions
  parseFloat,
  parseInt,
  upper: (e) => String(e).toUpperCase(),
  lower: (e) => String(e).toLowerCase(),
  substring: function() {
    return Xo("substring", arguments, String);
  },
  split: function() {
    return Xo("split", arguments, String);
  },
  replace: function() {
    return Xo("replace", arguments, String);
  },
  trim: (e) => String(e).trim(),
  // regexp functions
  regexp: RegExp,
  test: (e, t) => RegExp(e).test(t)
};
const Xre = ["view", "item", "group", "xy", "x", "y"], uv = /* @__PURE__ */ new Set([Function, eval, setTimeout, setInterval]);
typeof setImmediate == "function" && uv.add(setImmediate);
const Kre = {
  Literal: (e, t) => t.value,
  Identifier: (e, t) => {
    const n = t.name;
    return e.memberDepth > 0 ? n : n === "datum" ? e.datum : n === "event" ? e.event : n === "item" ? e.item : qre[n] || e.params["$" + n];
  },
  MemberExpression: (e, t) => {
    const n = !t.computed, i = e(t.object);
    n && (e.memberDepth += 1);
    const r = e(t.property);
    if (n && (e.memberDepth -= 1), uv.has(i[r])) {
      console.error(`Prevented interpretation of member "${r}" which could lead to insecure code execution`);
      return;
    }
    return i[r];
  },
  CallExpression: (e, t) => {
    const n = t.arguments;
    let i = t.callee.name;
    return i.startsWith("_") && (i = i.slice(1)), i === "if" ? e(n[0]) ? e(n[1]) : e(n[2]) : (e.fn[i] || Yre[i]).apply(e.fn, n.map(e));
  },
  ArrayExpression: (e, t) => t.elements.map(e),
  BinaryExpression: (e, t) => Wre[t.operator](e(t.left), e(t.right)),
  UnaryExpression: (e, t) => Hre[t.operator](e(t.argument)),
  ConditionalExpression: (e, t) => e(t.test) ? e(t.consequent) : e(t.alternate),
  LogicalExpression: (e, t) => t.operator === "&&" ? e(t.left) && e(t.right) : e(t.left) || e(t.right),
  ObjectExpression: (e, t) => t.properties.reduce((n, i) => {
    e.memberDepth += 1;
    const r = e(i.key);
    return e.memberDepth -= 1, uv.has(e(i.value)) ? console.error(`Prevented interpretation of property "${r}" which could lead to insecure code execution`) : n[r] = e(i.value), n;
  }, {})
};
function Ec(e, t, n, i, r, s) {
  const o = (a) => Kre[a.type](o, a);
  return o.memberDepth = 0, o.fn = Object.create(t), o.params = n, o.datum = i, o.event = r, o.item = s, Xre.forEach((a) => o.fn[a] = function() {
    return r.vega[a](...arguments);
  }), o(e);
}
var Jre = {
  /**
   * Parse an expression used to update an operator value.
   */
  operator(e, t) {
    const n = t.ast, i = e.functions;
    return (r) => Ec(n, i, r);
  },
  /**
   * Parse an expression provided as an operator parameter value.
   */
  parameter(e, t) {
    const n = t.ast, i = e.functions;
    return (r, s) => Ec(n, i, s, r);
  },
  /**
   * Parse an expression applied to an event stream.
   */
  event(e, t) {
    const n = t.ast, i = e.functions;
    return (r) => Ec(n, i, void 0, void 0, r);
  },
  /**
   * Parse an expression used to handle an event-driven operator update.
   */
  handler(e, t) {
    const n = t.ast, i = e.functions;
    return (r, s) => {
      const o = s.item && s.item.datum;
      return Ec(n, i, r, o, s);
    };
  },
  /**
   * Parse an expression that performs visual encoding.
   */
  encode(e, t) {
    const {
      marktype: n,
      channels: i
    } = t, r = e.functions, s = n === "group" || n === "image" || n === "rect";
    return (o, a) => {
      const l = o.datum;
      let u = 0, c;
      for (const f in i)
        c = Ec(i[f].ast, r, a, l, void 0, o), o[f] !== c && (o[f] = c, u = 1);
      return n !== "rule" && Ure(o, i, s), u;
    };
  }
};
const Qre = "vega-lite", Zre = 'Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer', ese = "5.16.3", tse = [
  "Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)",
  "Dominik Moritz (https://www.domoritz.de)",
  "Arvind Satyanarayan (https://arvindsatya.com)",
  "Jeffrey Heer (https://jheer.org)"
], nse = "https://vega.github.io/vega-lite/", ise = "Vega-Lite is a concise high-level language for interactive visualization.", rse = [
  "vega",
  "chart",
  "visualization"
], sse = "build/vega-lite.js", ose = "build/vega-lite.min.js", ase = "build/vega-lite.min.js", lse = "build/src/index", use = "build/src/index.d.ts", cse = {
  vl2pdf: "./bin/vl2pdf",
  vl2png: "./bin/vl2png",
  vl2svg: "./bin/vl2svg",
  vl2vg: "./bin/vl2vg"
}, fse = [
  "bin",
  "build",
  "src",
  "vega-lite*",
  "tsconfig.json"
], dse = {
  changelog: "conventional-changelog -p angular -r 2",
  prebuild: "yarn clean:build",
  build: "yarn build:only",
  "build:only": "tsc -p tsconfig.build.json && rollup -c",
  "prebuild:examples": "yarn build:only",
  "build:examples": "yarn data && TZ=America/Los_Angeles scripts/build-examples.sh",
  "prebuild:examples-full": "yarn build:only",
  "build:examples-full": "TZ=America/Los_Angeles scripts/build-examples.sh 1",
  "build:example": "TZ=America/Los_Angeles scripts/build-example.sh",
  "build:toc": "yarn build:jekyll && scripts/generate-toc",
  "build:site": "rollup -c site/rollup.config.mjs",
  "build:jekyll": "pushd site && bundle exec jekyll build -q && popd",
  "build:versions": "scripts/update-version.sh",
  clean: "yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete",
  "clean:build": "del-cli 'build/*' !build/vega-lite-schema.json",
  data: "rsync -r node_modules/vega-datasets/data/* site/data",
  schema: "mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",
  renameschema: "scripts/rename-schema.sh",
  presite: "yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",
  site: "yarn site:only",
  "site:only": "pushd site && bundle exec jekyll serve -I -l && popd",
  prettierbase: "prettier '**/*.{md,css,yml}'",
  format: "eslint . --fix && yarn prettierbase --write",
  lint: "eslint . && yarn prettierbase --check",
  jest: "NODE_OPTIONS=--experimental-vm-modules npx jest",
  test: "yarn jest test/ && yarn lint && yarn schema && yarn jest examples/ && yarn test:runtime",
  "test:cover": "yarn jest --collectCoverage test/",
  "test:inspect": "node --inspect-brk --experimental-vm-modules ./node_modules/.bin/jest --runInBand test",
  "test:runtime": "NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest test-runtime/ --config test-runtime/jest-config.json",
  "test:runtime:generate": "yarn build:only && del-cli test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime",
  watch: "tsc -p tsconfig.build.json -w",
  "watch:site": "yarn build:site -w",
  "watch:test": "yarn jest --watch test/",
  "watch:test:runtime": "NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest --watch test-runtime/ --config test-runtime/jest-config.json",
  release: "release-it"
}, hse = {
  type: "git",
  url: "https://github.com/vega/vega-lite.git"
}, gse = "BSD-3-Clause", pse = {
  url: "https://github.com/vega/vega-lite/issues"
}, mse = {
  "@babel/core": "^7.22.10",
  "@babel/plugin-proposal-class-properties": "^7.18.6",
  "@babel/preset-env": "^7.22.10",
  "@babel/preset-typescript": "^7.22.5",
  "@release-it/conventional-changelog": "^7.0.0",
  "@rollup/plugin-alias": "^5.0.0",
  "@rollup/plugin-babel": "^6.0.3",
  "@rollup/plugin-commonjs": "^25.0.4",
  "@rollup/plugin-json": "^6.0.0",
  "@rollup/plugin-node-resolve": "^15.2.1",
  "@rollup/plugin-terser": "^0.4.3",
  "@types/chai": "^4.3.5",
  "@types/d3": "^7.4.0",
  "@types/jest": "^29.5.4",
  "@types/pako": "^2.0.0",
  "@typescript-eslint/eslint-plugin": "^6.4.1",
  "@typescript-eslint/parser": "^6.4.1",
  ajv: "^8.12.0",
  "ajv-formats": "^2.1.1",
  chai: "^4.3.7",
  cheerio: "^1.0.0-rc.12",
  "conventional-changelog-cli": "^4.0.0",
  d3: "^7.8.5",
  "del-cli": "^5.0.0",
  eslint: "^8.47.0",
  "eslint-config-prettier": "^9.0.0",
  "eslint-plugin-jest": "^27.2.3",
  "eslint-plugin-prettier": "^5.0.0",
  "fast-json-stable-stringify": "~2.1.0",
  "highlight.js": "^11.8.0",
  jest: "^29.6.3",
  "jest-dev-server": "^9.0.0",
  mkdirp: "^3.0.1",
  pako: "^2.1.0",
  prettier: "^3.0.2",
  puppeteer: "^15.0.0",
  "release-it": "^16.1.5",
  rollup: "^3.28.1",
  "rollup-plugin-bundle-size": "^1.0.3",
  "rollup-plugin-sourcemaps": "^0.6.3",
  serve: "^14.2.1",
  terser: "^5.19.2",
  "ts-jest": "^29.1.1",
  "ts-json-schema-generator": "^1.3.0",
  typescript: "~5.2.2",
  "vega-cli": "^5.25.0",
  "vega-datasets": "^2.7.0",
  "vega-embed": "^6.22.2",
  "vega-tooltip": "^0.33.0",
  "yaml-front-matter": "^4.1.1"
}, yse = {
  "json-stringify-pretty-compact": "~3.0.0",
  tslib: "~2.6.2",
  "vega-event-selector": "~3.0.1",
  "vega-expression": "~5.1.0",
  "vega-util": "~1.17.2",
  yargs: "~17.7.2"
}, bse = {
  vega: "^5.24.0"
}, vse = {
  node: ">=18"
}, xse = {
  name: Qre,
  author: Zre,
  version: ese,
  collaborators: tse,
  homepage: nse,
  description: ise,
  keywords: rse,
  main: sse,
  unpkg: ose,
  jsdelivr: ase,
  module: lse,
  types: use,
  bin: cse,
  files: fse,
  scripts: dse,
  repository: hse,
  license: gse,
  bugs: pse,
  devDependencies: mse,
  dependencies: yse,
  peerDependencies: bse,
  engines: vse
};
function z_(e) {
  return !!e.or;
}
function B_(e) {
  return !!e.and;
}
function j_(e) {
  return !!e.not;
}
function tg(e, t) {
  if (j_(e))
    tg(e.not, t);
  else if (B_(e))
    for (const n of e.and)
      tg(n, t);
  else if (z_(e))
    for (const n of e.or)
      tg(n, t);
  else
    t(e);
}
function Gl(e, t) {
  return j_(e) ? { not: Gl(e.not, t) } : B_(e) ? { and: e.and.map((n) => Gl(n, t)) } : z_(e) ? { or: e.or.map((n) => Gl(n, t)) } : t(e);
}
const me = structuredClone;
function H6(e) {
  throw new Error(e);
}
function vu(e, t) {
  const n = {};
  for (const i of t)
    ce(e, i) && (n[i] = e[i]);
  return n;
}
function Nn(e, t) {
  const n = { ...e };
  for (const i of t)
    delete n[i];
  return n;
}
Set.prototype.toJSON = function() {
  return `Set(${[...this].map((e) => Ve(e)).join(",")})`;
};
function $e(e) {
  if (Re(e))
    return e;
  const t = te(e) ? e : Ve(e);
  if (t.length < 250)
    return t;
  let n = 0;
  for (let i = 0; i < t.length; i++) {
    const r = t.charCodeAt(i);
    n = (n << 5) - n + r, n = n & n;
  }
  return n;
}
function cv(e) {
  return e === !1 || e === null;
}
function Me(e, t) {
  return e.includes(t);
}
function Ba(e, t) {
  let n = 0;
  for (const [i, r] of e.entries())
    if (t(r, i, n++))
      return !0;
  return !1;
}
function U_(e, t) {
  let n = 0;
  for (const [i, r] of e.entries())
    if (!t(r, i, n++))
      return !1;
  return !0;
}
function G6(e, ...t) {
  for (const n of t)
    wse(e, n ?? {});
  return e;
}
function wse(e, t) {
  for (const n of q(t))
    Ru(e, n, t[n], !0);
}
function xr(e, t) {
  const n = [], i = {};
  let r;
  for (const s of e)
    r = t(s), !(r in i) && (i[r] = 1, n.push(s));
  return n;
}
function _se(e, t) {
  const n = q(e), i = q(t);
  if (n.length !== i.length)
    return !1;
  for (const r of n)
    if (e[r] !== t[r])
      return !1;
  return !0;
}
function V6(e, t) {
  if (e.size !== t.size)
    return !1;
  for (const n of e)
    if (!t.has(n))
      return !1;
  return !0;
}
function q_(e, t) {
  for (const n of e)
    if (t.has(n))
      return !0;
  return !1;
}
function fv(e) {
  const t = /* @__PURE__ */ new Set();
  for (const n of e) {
    const r = Pr(n).map((o, a) => a === 0 ? o : `[${o}]`), s = r.map((o, a) => r.slice(0, a + 1).join(""));
    for (const o of s)
      t.add(o);
  }
  return t;
}
function W_(e, t) {
  return e === void 0 || t === void 0 ? !0 : q_(fv(e), fv(t));
}
function Ge(e) {
  return q(e).length === 0;
}
const q = Object.keys, Wt = Object.values, So = Object.entries;
function Hf(e) {
  return e === !0 || e === !1;
}
function tt(e) {
  const t = e.replace(/\W/g, "_");
  return (e.match(/^\d+/) ? "_" : "") + t;
}
function hf(e, t) {
  return j_(e) ? `!(${hf(e.not, t)})` : B_(e) ? `(${e.and.map((n) => hf(n, t)).join(") && (")})` : z_(e) ? `(${e.or.map((n) => hf(n, t)).join(") || (")})` : t(e);
}
function xp(e, t) {
  if (t.length === 0)
    return !0;
  const n = t.shift();
  return n in e && xp(e[n], t) && delete e[n], Ge(e);
}
function Md(e) {
  return e.charAt(0).toUpperCase() + e.substr(1);
}
function H_(e, t = "datum") {
  const n = Pr(e), i = [];
  for (let r = 1; r <= n.length; r++) {
    const s = `[${n.slice(0, r).map(X).join("][")}]`;
    i.push(`${t}${s}`);
  }
  return i.join(" && ");
}
function Y6(e, t = "datum") {
  return `${t}[${X(Pr(e).join("."))}]`;
}
function Ese(e) {
  return e.replace(/(\[|\]|\.|'|")/g, "\\$1");
}
function Ci(e) {
  return `${Pr(e).map(Ese).join("\\.")}`;
}
function ja(e, t, n) {
  return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), n);
}
function G_(e) {
  return `${Pr(e).join(".")}`;
}
function xu(e) {
  return e ? Pr(e).length : 0;
}
function dt(...e) {
  for (const t of e)
    if (t !== void 0)
      return t;
}
let X6 = 42;
function K6(e) {
  const t = ++X6;
  return e ? String(e) + t : t;
}
function Sse() {
  X6 = 42;
}
function J6(e) {
  return Q6(e) ? e : `__${e}`;
}
function Q6(e) {
  return e.startsWith("__");
}
function Gf(e) {
  if (e !== void 0)
    return (e % 360 + 360) % 360;
}
function t0(e) {
  return Re(e) ? !0 : !isNaN(e) && !isNaN(parseFloat(e));
}
const C$ = Object.getPrototypeOf(structuredClone({}));
function Qn(e, t) {
  if (e === t)
    return !0;
  if (e && t && typeof e == "object" && typeof t == "object") {
    if (e.constructor.name !== t.constructor.name)
      return !1;
    let n, i;
    if (Array.isArray(e)) {
      if (n = e.length, n != t.length)
        return !1;
      for (i = n; i-- !== 0; )
        if (!Qn(e[i], t[i]))
          return !1;
      return !0;
    }
    if (e instanceof Map && t instanceof Map) {
      if (e.size !== t.size)
        return !1;
      for (i of e.entries())
        if (!t.has(i[0]))
          return !1;
      for (i of e.entries())
        if (!Qn(i[1], t.get(i[0])))
          return !1;
      return !0;
    }
    if (e instanceof Set && t instanceof Set) {
      if (e.size !== t.size)
        return !1;
      for (i of e.entries())
        if (!t.has(i[0]))
          return !1;
      return !0;
    }
    if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
      if (n = e.length, n != t.length)
        return !1;
      for (i = n; i-- !== 0; )
        if (e[i] !== t[i])
          return !1;
      return !0;
    }
    if (e.constructor === RegExp)
      return e.source === t.source && e.flags === t.flags;
    if (e.valueOf !== Object.prototype.valueOf && e.valueOf !== C$.valueOf)
      return e.valueOf() === t.valueOf();
    if (e.toString !== Object.prototype.toString && e.toString !== C$.toString)
      return e.toString() === t.toString();
    const r = Object.keys(e);
    if (n = r.length, n !== Object.keys(t).length)
      return !1;
    for (i = n; i-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(t, r[i]))
        return !1;
    for (i = n; i-- !== 0; ) {
      const s = r[i];
      if (!Qn(e[s], t[s]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function Ve(e) {
  const t = [];
  return function n(i) {
    if (i && i.toJSON && typeof i.toJSON == "function" && (i = i.toJSON()), i === void 0)
      return;
    if (typeof i == "number")
      return isFinite(i) ? "" + i : "null";
    if (typeof i != "object")
      return JSON.stringify(i);
    let r, s;
    if (Array.isArray(i)) {
      for (s = "[", r = 0; r < i.length; r++)
        r && (s += ","), s += n(i[r]) || "null";
      return s + "]";
    }
    if (i === null)
      return "null";
    if (t.includes(i))
      throw new TypeError("Converting circular structure to JSON");
    const o = t.push(i) - 1, a = Object.keys(i).sort();
    for (s = "", r = 0; r < a.length; r++) {
      const l = a[r], u = n(i[l]);
      u && (s && (s += ","), s += JSON.stringify(l) + ":" + u);
    }
    return t.splice(o, 1), `{${s}}`;
  }(e);
}
const ms = "row", ys = "column", n0 = "facet", nt = "x", Pt = "y", sr = "x2", qr = "y2", Io = "xOffset", Ku = "yOffset", or = "radius", Os = "radius2", Fi = "theta", Ns = "theta2", ar = "latitude", lr = "longitude", ur = "latitude2", $i = "longitude2", jn = "color", Wr = "fill", Hr = "stroke", Un = "shape", Ds = "size", al = "angle", Rs = "opacity", zo = "fillOpacity", Bo = "strokeOpacity", jo = "strokeWidth", Uo = "strokeDash", Fd = "text", wu = "order", Td = "detail", i0 = "key", Ua = "tooltip", r0 = "href", s0 = "url", o0 = "description", kse = {
  x: 1,
  y: 1,
  x2: 1,
  y2: 1
}, Z6 = {
  theta: 1,
  theta2: 1,
  radius: 1,
  radius2: 1
};
function e4(e) {
  return e in Z6;
}
const V_ = {
  longitude: 1,
  longitude2: 1,
  latitude: 1,
  latitude2: 1
};
function t4(e) {
  switch (e) {
    case ar:
      return "y";
    case ur:
      return "y2";
    case lr:
      return "x";
    case $i:
      return "x2";
  }
}
function n4(e) {
  return e in V_;
}
const Ase = q(V_), Y_ = {
  ...kse,
  ...Z6,
  ...V_,
  xOffset: 1,
  yOffset: 1,
  // color
  color: 1,
  fill: 1,
  stroke: 1,
  // other non-position with scale
  opacity: 1,
  fillOpacity: 1,
  strokeOpacity: 1,
  strokeWidth: 1,
  strokeDash: 1,
  size: 1,
  angle: 1,
  shape: 1,
  // channels without scales
  order: 1,
  text: 1,
  detail: 1,
  key: 1,
  tooltip: 1,
  href: 1,
  url: 1,
  description: 1
};
function Vl(e) {
  return e === jn || e === Wr || e === Hr;
}
const i4 = {
  row: 1,
  column: 1,
  facet: 1
}, yi = q(i4), X_ = {
  ...Y_,
  ...i4
}, Cse = q(X_), { order: Vme, detail: Yme, tooltip: Xme, ...$se } = X_, { row: Kme, column: Jme, facet: Qme, ...Mse } = $se;
function Fse(e) {
  return !!Mse[e];
}
function r4(e) {
  return !!X_[e];
}
const Tse = [sr, qr, ur, $i, Ns, Os];
function s4(e) {
  return ll(e) !== e;
}
function ll(e) {
  switch (e) {
    case sr:
      return nt;
    case qr:
      return Pt;
    case ur:
      return ar;
    case $i:
      return lr;
    case Ns:
      return Fi;
    case Os:
      return or;
  }
  return e;
}
function ko(e) {
  if (e4(e))
    switch (e) {
      case Fi:
        return "startAngle";
      case Ns:
        return "endAngle";
      case or:
        return "outerRadius";
      case Os:
        return "innerRadius";
    }
  return e;
}
function Gr(e) {
  switch (e) {
    case nt:
      return sr;
    case Pt:
      return qr;
    case ar:
      return ur;
    case lr:
      return $i;
    case Fi:
      return Ns;
    case or:
      return Os;
  }
}
function qn(e) {
  switch (e) {
    case nt:
    case sr:
      return "width";
    case Pt:
    case qr:
      return "height";
  }
}
function o4(e) {
  switch (e) {
    case nt:
      return "xOffset";
    case Pt:
      return "yOffset";
    case sr:
      return "x2Offset";
    case qr:
      return "y2Offset";
    case Fi:
      return "thetaOffset";
    case or:
      return "radiusOffset";
    case Ns:
      return "theta2Offset";
    case Os:
      return "radius2Offset";
  }
}
function K_(e) {
  switch (e) {
    case nt:
      return "xOffset";
    case Pt:
      return "yOffset";
  }
}
function Ose(e) {
  switch (e) {
    case "xOffset":
      return "x";
    case "yOffset":
      return "y";
  }
}
const Nse = q(Y_), {
  x: Zme,
  y: e0e,
  // x2 and y2 share the same scale as x and y
  x2: t0e,
  y2: n0e,
  //
  xOffset: i0e,
  yOffset: r0e,
  latitude: s0e,
  longitude: o0e,
  latitude2: a0e,
  longitude2: l0e,
  theta: u0e,
  theta2: c0e,
  radius: f0e,
  radius2: d0e,
  // The rest of unit channels then have scale
  ...J_
} = Y_, Dse = q(J_), Q_ = {
  x: 1,
  y: 1
}, Vr = q(Q_);
function ht(e) {
  return e in Q_;
}
const Z_ = {
  theta: 1,
  radius: 1
}, Rse = q(Z_);
function a0(e) {
  return e === "width" ? nt : Pt;
}
const a4 = { xOffset: 1, yOffset: 1 };
function Od(e) {
  return e in a4;
}
const {
  // x2 and y2 share the same scale as x and y
  // text and tooltip have format instead of scale,
  // href has neither format, nor scale
  text: h0e,
  tooltip: g0e,
  href: p0e,
  url: m0e,
  description: y0e,
  // detail and order have no scale
  detail: b0e,
  key: v0e,
  order: x0e,
  ...l4
} = J_, Lse = q(l4);
function Pse(e) {
  return !!J_[e];
}
function Ise(e) {
  switch (e) {
    case jn:
    case Wr:
    case Hr:
    case Ds:
    case Un:
    case Rs:
    case jo:
    case Uo:
      return !0;
    case zo:
    case Bo:
    case al:
      return !1;
  }
}
const u4 = {
  ...Q_,
  ...Z_,
  ...a4,
  ...l4
}, l0 = q(u4);
function Ls(e) {
  return !!u4[e];
}
function zse(e, t) {
  return jse(e)[t];
}
const c4 = {
  // all marks
  arc: "always",
  area: "always",
  bar: "always",
  circle: "always",
  geoshape: "always",
  image: "always",
  line: "always",
  rule: "always",
  point: "always",
  rect: "always",
  square: "always",
  trail: "always",
  text: "always",
  tick: "always"
}, { geoshape: w0e, ...Bse } = c4;
function jse(e) {
  switch (e) {
    case jn:
    case Wr:
    case Hr:
    case o0:
    case Td:
    case i0:
    case Ua:
    case r0:
    case wu:
    case Rs:
    case zo:
    case Bo:
    case jo:
    case n0:
    case ms:
    case ys:
      return c4;
    case nt:
    case Pt:
    case Io:
    case Ku:
    case ar:
    case lr:
      return Bse;
    case sr:
    case qr:
    case ur:
    case $i:
      return {
        area: "always",
        bar: "always",
        image: "always",
        rect: "always",
        rule: "always",
        circle: "binned",
        point: "binned",
        square: "binned",
        tick: "binned",
        line: "binned",
        trail: "binned"
      };
    case Ds:
      return {
        point: "always",
        tick: "always",
        rule: "always",
        circle: "always",
        square: "always",
        bar: "always",
        text: "always",
        line: "always",
        trail: "always"
      };
    case Uo:
      return {
        line: "always",
        point: "always",
        tick: "always",
        rule: "always",
        circle: "always",
        square: "always",
        bar: "always",
        geoshape: "always"
      };
    case Un:
      return { point: "always", geoshape: "always" };
    case Fd:
      return { text: "always" };
    case al:
      return { point: "always", square: "always", text: "always" };
    case s0:
      return { image: "always" };
    case Fi:
      return { text: "always", arc: "always" };
    case or:
      return { text: "always", arc: "always" };
    case Ns:
    case Os:
      return { arc: "always" };
  }
}
function Z1(e) {
  switch (e) {
    case nt:
    case Pt:
    case Fi:
    case or:
    case Io:
    case Ku:
    case Ds:
    case al:
    case jo:
    case Rs:
    case zo:
    case Bo:
    case sr:
    case qr:
    case Ns:
    case Os:
      return;
    case n0:
    case ms:
    case ys:
    case Un:
    case Uo:
    case Fd:
    case Ua:
    case r0:
    case s0:
    case o0:
      return "discrete";
    case jn:
    case Wr:
    case Hr:
      return "flexible";
    case ar:
    case lr:
    case ur:
    case $i:
    case Td:
    case i0:
    case wu:
      return;
  }
}
const Use = {
  argmax: 1,
  argmin: 1,
  average: 1,
  count: 1,
  distinct: 1,
  product: 1,
  max: 1,
  mean: 1,
  median: 1,
  min: 1,
  missing: 1,
  q1: 1,
  q3: 1,
  ci0: 1,
  ci1: 1,
  stderr: 1,
  stdev: 1,
  stdevp: 1,
  sum: 1,
  valid: 1,
  values: 1,
  variance: 1,
  variancep: 1
}, qse = {
  count: 1,
  min: 1,
  max: 1
};
function Ss(e) {
  return !!e && !!e.argmin;
}
function qo(e) {
  return !!e && !!e.argmax;
}
function eE(e) {
  return te(e) && !!Use[e];
}
const Wse = /* @__PURE__ */ new Set([
  "count",
  "valid",
  "missing",
  "distinct"
]);
function f4(e) {
  return te(e) && Wse.has(e);
}
function Hse(e) {
  return te(e) && Me(["min", "max"], e);
}
const Gse = /* @__PURE__ */ new Set([
  "count",
  "sum",
  "distinct",
  "valid",
  "missing"
]), Vse = /* @__PURE__ */ new Set([
  "mean",
  "average",
  "median",
  "q1",
  "q3",
  "min",
  "max"
]);
function d4(e) {
  return To(e) && (e = x0(e, void 0)), "bin" + q(e).map((t) => u0(e[t]) ? tt(`_${t}_${So(e[t])}`) : tt(`_${t}_${e[t]}`)).join("");
}
function Je(e) {
  return e === !0 || ul(e) && !e.binned;
}
function Bt(e) {
  return e === "binned" || ul(e) && e.binned === !0;
}
function ul(e) {
  return ne(e);
}
function u0(e) {
  return e == null ? void 0 : e.param;
}
function $$(e) {
  switch (e) {
    case ms:
    case ys:
    case Ds:
    case jn:
    case Wr:
    case Hr:
    case jo:
    case Rs:
    case zo:
    case Bo:
    case Un:
      return 6;
    case Uo:
      return 4;
    default:
      return 10;
  }
}
function Nd(e) {
  return !!(e != null && e.expr);
}
function Fn(e) {
  const t = q(e || {}), n = {};
  for (const i of t)
    n[i] = Xn(e[i]);
  return n;
}
function h4(e) {
  const {
    // These are non-mark title config that need to be hardcoded
    anchor: t,
    frame: n,
    offset: i,
    orient: r,
    angle: s,
    limit: o,
    // color needs to be redirect to fill
    color: a,
    // subtitle properties
    subtitleColor: l,
    subtitleFont: u,
    subtitleFontSize: c,
    subtitleFontStyle: f,
    subtitleFontWeight: d,
    subtitleLineHeight: h,
    subtitlePadding: g,
    // The rest are mark config.
    ...p
  } = e, m = {
    ...p,
    ...a ? { fill: a } : {}
  }, y = {
    ...t ? { anchor: t } : {},
    ...n ? { frame: n } : {},
    ...i ? { offset: i } : {},
    ...r ? { orient: r } : {},
    ...s !== void 0 ? { angle: s } : {},
    ...o !== void 0 ? { limit: o } : {}
  }, b = {
    ...l ? { subtitleColor: l } : {},
    ...u ? { subtitleFont: u } : {},
    ...c ? { subtitleFontSize: c } : {},
    ...f ? { subtitleFontStyle: f } : {},
    ...d ? { subtitleFontWeight: d } : {},
    ...h ? { subtitleLineHeight: h } : {},
    ...g ? { subtitlePadding: g } : {}
  }, v = vu(e, ["align", "baseline", "dx", "dy", "limit"]);
  return { titleMarkConfig: m, subtitleMarkConfig: v, nonMarkTitleProperties: y, subtitle: b };
}
function Ys(e) {
  return te(e) || U(e) && te(e[0]);
}
function oe(e) {
  return !!(e != null && e.signal);
}
function Wo(e) {
  return !!e.step;
}
function Yse(e) {
  return U(e) ? !1 : "fields" in e && !("data" in e);
}
function Xse(e) {
  return U(e) ? !1 : "fields" in e && "data" in e;
}
function ds(e) {
  return U(e) ? !1 : "field" in e && "data" in e;
}
const Kse = {
  aria: 1,
  description: 1,
  ariaRole: 1,
  ariaRoleDescription: 1,
  blend: 1,
  opacity: 1,
  fill: 1,
  fillOpacity: 1,
  stroke: 1,
  strokeCap: 1,
  strokeWidth: 1,
  strokeOpacity: 1,
  strokeDash: 1,
  strokeDashOffset: 1,
  strokeJoin: 1,
  strokeOffset: 1,
  strokeMiterLimit: 1,
  startAngle: 1,
  endAngle: 1,
  padAngle: 1,
  innerRadius: 1,
  outerRadius: 1,
  size: 1,
  shape: 1,
  interpolate: 1,
  tension: 1,
  orient: 1,
  align: 1,
  baseline: 1,
  text: 1,
  dir: 1,
  dx: 1,
  dy: 1,
  ellipsis: 1,
  limit: 1,
  radius: 1,
  theta: 1,
  angle: 1,
  font: 1,
  fontSize: 1,
  fontWeight: 1,
  fontStyle: 1,
  lineBreak: 1,
  lineHeight: 1,
  cursor: 1,
  href: 1,
  tooltip: 1,
  cornerRadius: 1,
  cornerRadiusTopLeft: 1,
  cornerRadiusTopRight: 1,
  cornerRadiusBottomLeft: 1,
  cornerRadiusBottomRight: 1,
  aspect: 1,
  width: 1,
  height: 1,
  url: 1,
  smooth: 1
  // commented below are vg channel that do not have mark config.
  // x: 1,
  // y: 1,
  // x2: 1,
  // y2: 1,
  // xc'|'yc'
  // clip: 1,
  // path: 1,
  // url: 1,
}, Jse = q(Kse), Qse = {
  arc: 1,
  area: 1,
  group: 1,
  image: 1,
  line: 1,
  path: 1,
  rect: 1,
  rule: 1,
  shape: 1,
  symbol: 1,
  text: 1,
  trail: 1
}, dv = [
  "cornerRadius",
  "cornerRadiusTopLeft",
  "cornerRadiusTopRight",
  "cornerRadiusBottomLeft",
  "cornerRadiusBottomRight"
];
function g4(e) {
  const t = U(e.condition) ? e.condition.map(M$) : M$(e.condition);
  return {
    ...Xn(e),
    condition: t
  };
}
function Xn(e) {
  if (Nd(e)) {
    const { expr: t, ...n } = e;
    return { signal: t, ...n };
  }
  return e;
}
function M$(e) {
  if (Nd(e)) {
    const { expr: t, ...n } = e;
    return { signal: t, ...n };
  }
  return e;
}
function Ze(e) {
  if (Nd(e)) {
    const { expr: t, ...n } = e;
    return { signal: t, ...n };
  }
  return oe(e) ? e : e !== void 0 ? { value: e } : void 0;
}
function Zse(e) {
  return oe(e) ? e.signal : X(e);
}
function F$(e) {
  return oe(e) ? e.signal : X(e.value);
}
function Hi(e) {
  return oe(e) ? e.signal : e == null ? null : X(e);
}
function eoe(e, t, n) {
  for (const i of n) {
    const r = ks(i, t.markDef, t.config);
    r !== void 0 && (e[i] = Ze(r));
  }
  return e;
}
function p4(e) {
  return [].concat(e.type, e.style ?? []);
}
function qe(e, t, n, i = {}) {
  const { vgChannel: r, ignoreVgConfig: s } = i;
  return r && t[r] !== void 0 ? t[r] : t[e] !== void 0 ? t[e] : s && (!r || r === e) ? void 0 : ks(e, t, n, i);
}
function ks(e, t, n, { vgChannel: i } = {}) {
  return dt(
    // style config has highest precedence
    i ? wp(e, t, n.style) : void 0,
    wp(e, t, n.style),
    // then mark-specific config
    i ? n[t.type][i] : void 0,
    n[t.type][e],
    // Need to cast because MarkDef doesn't perfectly match with AnyMarkConfig, but if the type isn't available, we'll get nothing here, which is fine
    // If there is vgChannel, skip vl channel.
    // For example, vl size for text is vg fontSize, but config.mark.size is only for point size.
    i ? n.mark[i] : n.mark[e]
    // Need to cast for the same reason as above
  );
}
function wp(e, t, n) {
  return m4(e, p4(t), n);
}
function m4(e, t, n) {
  t = ee(t);
  let i;
  for (const r of t) {
    const s = n[r];
    s && s[e] !== void 0 && (i = s[e]);
  }
  return i;
}
function y4(e, t) {
  return ee(e).reduce((n, i) => (n.field.push(J(i, t)), n.order.push(i.sort ?? "ascending"), n), { field: [], order: [] });
}
function b4(e, t) {
  const n = [...e];
  return t.forEach((i) => {
    for (const r of n)
      if (Qn(r, i))
        return;
    n.push(i);
  }), n;
}
function v4(e, t) {
  return Qn(e, t) || !t ? e : e ? [...ee(e), ...ee(t)].join(", ") : t;
}
function x4(e, t) {
  const n = e.value, i = t.value;
  if (n == null || i === null)
    return {
      explicit: e.explicit,
      value: null
    };
  if ((Ys(n) || oe(n)) && (Ys(i) || oe(i)))
    return {
      explicit: e.explicit,
      value: v4(n, i)
    };
  if (Ys(n) || oe(n))
    return {
      explicit: e.explicit,
      value: n
    };
  if (Ys(i) || oe(i))
    return {
      explicit: e.explicit,
      value: i
    };
  if (!Ys(n) && !oe(n) && !Ys(i) && !oe(i))
    return {
      explicit: e.explicit,
      value: b4(n, i)
    };
  throw new Error("It should never reach here");
}
function tE(e) {
  return `Invalid specification ${Ve(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`;
}
const toe = 'Autosize "fit" only works for single views and layered views.';
function T$(e) {
  return `${e == "width" ? "Width" : "Height"} "container" only works for single views and layered views.`;
}
function O$(e) {
  const t = e == "width" ? "Width" : "Height", n = e == "width" ? "x" : "y";
  return `${t} "container" only works well with autosize "fit" or "fit-${n}".`;
}
function N$(e) {
  return e ? `Dropping "fit-${e}" because spec has discrete ${qn(e)}.` : 'Dropping "fit" because spec has discrete size.';
}
function nE(e) {
  return `Unknown field for ${e}. Cannot calculate view size.`;
}
function D$(e) {
  return `Cannot project a selection on encoding channel "${e}", which has no field.`;
}
function noe(e, t) {
  return `Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`;
}
function ioe(e) {
  return `The "nearest" transform is not supported for ${e} marks.`;
}
function w4(e) {
  return `Selection not supported for ${e} yet.`;
}
function roe(e) {
  return `Cannot find a selection named "${e}".`;
}
const soe = "Scale bindings are currently only supported for scales with unbinned, continuous domains.", ooe = "Legend bindings are only supported for selections over an individual field or encoding channel.";
function aoe(e) {
  return `Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`;
}
function loe(e) {
  return `Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`;
}
const uoe = "The same selection must be used to override scale domains in a layered view.", coe = 'Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';
function foe(e) {
  return `Unknown repeated value "${e}".`;
}
function R$(e) {
  return `The "columns" property cannot be used when "${e}" has nested row/column.`;
}
const doe = "Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";
function hoe(e) {
  return `Unrecognized parse "${e}".`;
}
function L$(e, t, n) {
  return `An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`;
}
const goe = "Attempt to add the same child twice.";
function poe(e) {
  return `Ignoring an invalid transform: ${Ve(e)}.`;
}
const moe = 'If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.';
function P$(e) {
  return `Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`;
}
function yoe(e) {
  const { parentProjection: t, projection: n } = e;
  return `Layer's shared projection ${Ve(t)} is overridden by a child projection ${Ve(n)}.`;
}
const boe = "Arc marks uses theta channel rather than angle, replacing angle with theta.";
function voe(e) {
  return `${e}Offset dropped because ${e} is continuous`;
}
function xoe(e, t, n) {
  return `Channel ${e} is a ${t}. Converted to {value: ${Ve(n)}}.`;
}
function _4(e) {
  return `Invalid field type "${e}".`;
}
function woe(e, t) {
  return `Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`;
}
function _oe(e) {
  return `Invalid aggregation operator "${e}".`;
}
function E4(e, t) {
  const { fill: n, stroke: i } = t;
  return `Dropping color ${e} as the plot also has ${n && i ? "fill and stroke" : n ? "fill" : "stroke"}.`;
}
function Eoe(e) {
  return `Position range does not support relative band size for ${e}.`;
}
function hv(e, t) {
  return `Dropping ${Ve(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`;
}
const Soe = "Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";
function c0(e, t, n) {
  return `${e} dropped as it is incompatible with "${t}"${n ? ` when ${n}` : ""}.`;
}
function koe(e) {
  return `${e}-encoding is dropped as ${e} is not a valid encoding channel.`;
}
function Aoe(e) {
  return `${e} encoding should be discrete (ordinal / nominal / binned).`;
}
function Coe(e) {
  return `${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`;
}
function $oe(e) {
  return `Facet encoding dropped as ${e.join(" and ")} ${e.length > 1 ? "are" : "is"} also specified.`;
}
function ey(e, t) {
  return `Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t === "ordinal" ? "order" : "magnitude"}.`;
}
function Moe(e) {
  return `The ${e} for range marks cannot be an expression`;
}
function Foe(e, t) {
  return `Line mark is for continuous lines and thus cannot be used with ${e && t ? "x2 and y2" : e ? "x2" : "y2"}. We will use the rule mark (line segments) instead.`;
}
function Toe(e, t) {
  return `Specified orient "${e}" overridden with "${t}".`;
}
function Ooe(e) {
  return `Cannot use the scale property "${e}" with non-color channel.`;
}
function Noe(e) {
  return `Cannot use the relative band size with ${e} scale.`;
}
function Doe(e) {
  return `Using unaggregated domain with raw field has no effect (${Ve(e)}).`;
}
function Roe(e) {
  return `Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`;
}
function Loe(e) {
  return `Unaggregated domain is currently unsupported for log scale (${Ve(e)}).`;
}
function Poe(e) {
  return `Cannot apply size to non-oriented mark "${e}".`;
}
function Ioe(e, t, n) {
  return `Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`;
}
function zoe(e, t) {
  return `FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`;
}
function S4(e, t, n) {
  return `${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`;
}
function k4(e) {
  return `The step for "${e}" is dropped because the ${e === "width" ? "x" : "y"} is continuous.`;
}
function Boe(e, t, n, i) {
  return `Conflicting ${t.toString()} property "${e.toString()}" (${Ve(n)} and ${Ve(i)}). Using ${Ve(n)}.`;
}
function joe(e, t, n, i) {
  return `Conflicting ${t.toString()} property "${e.toString()}" (${Ve(n)} and ${Ve(i)}). Using the union of the two domains.`;
}
function Uoe(e) {
  return `Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`;
}
function qoe(e) {
  return `Dropping sort property ${Ve(e)} as unioned domains only support boolean or op "count", "min", and "max".`;
}
const I$ = "Domains that should be unioned has conflicting sort properties. Sort will be set to true.", Woe = "Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.", Hoe = "Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.", Goe = "Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.";
function Voe(e) {
  return `Cannot stack "${e}" if there is already "${e}2".`;
}
function Yoe(e) {
  return `Cannot stack non-linear scale (${e}).`;
}
function Xoe(e) {
  return `Stacking is applied even though the aggregate function is non-summative ("${e}").`;
}
function _p(e, t) {
  return `Invalid ${e}: ${Ve(t)}.`;
}
function Koe(e) {
  return `Dropping day from datetime ${Ve(e)} as day cannot be combined with other units.`;
}
function Joe(e, t) {
  return `${t ? "extent " : ""}${t && e ? "and " : ""}${e ? "center " : ""}${t && e ? "are " : "is "}not needed when data are aggregated.`;
}
function Qoe(e, t, n) {
  return `${e} is not usually used with ${t} for ${n}.`;
}
function Zoe(e, t) {
  return `Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`;
}
function z$(e) {
  return `1D error band does not support ${e}.`;
}
function A4(e) {
  return `Channel ${e} is required for "binned" bin.`;
}
function eae(e) {
  return `Channel ${e} should not be used with "binned" bin.`;
}
function tae(e) {
  return `Domain for ${e} is required for threshold scale.`;
}
const C4 = Yv(Vv);
let _u = C4;
function nae(e) {
  return _u = e, _u;
}
function iae() {
  return _u = C4, _u;
}
function G(...e) {
  _u.warn(...e);
}
function rae(...e) {
  _u.debug(...e);
}
function cl(e) {
  if (e && ne(e)) {
    for (const t of rE)
      if (t in e)
        return !0;
  }
  return !1;
}
const $4 = [
  "january",
  "february",
  "march",
  "april",
  "may",
  "june",
  "july",
  "august",
  "september",
  "october",
  "november",
  "december"
], sae = $4.map((e) => e.substr(0, 3)), M4 = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"], oae = M4.map((e) => e.substr(0, 3));
function aae(e) {
  if (t0(e) && (e = +e), Re(e))
    return e > 4 && G(_p("quarter", e)), e - 1;
  throw new Error(_p("quarter", e));
}
function lae(e) {
  if (t0(e) && (e = +e), Re(e))
    return e - 1;
  {
    const t = e.toLowerCase(), n = $4.indexOf(t);
    if (n !== -1)
      return n;
    const i = t.substr(0, 3), r = sae.indexOf(i);
    if (r !== -1)
      return r;
    throw new Error(_p("month", e));
  }
}
function uae(e) {
  if (t0(e) && (e = +e), Re(e))
    return e % 7;
  {
    const t = e.toLowerCase(), n = M4.indexOf(t);
    if (n !== -1)
      return n;
    const i = t.substr(0, 3), r = oae.indexOf(i);
    if (r !== -1)
      return r;
    throw new Error(_p("day", e));
  }
}
function iE(e, t) {
  const n = [];
  if (t && e.day !== void 0 && q(e).length > 1 && (G(Koe(e)), e = me(e), delete e.day), e.year !== void 0 ? n.push(e.year) : n.push(2012), e.month !== void 0) {
    const i = t ? lae(e.month) : e.month;
    n.push(i);
  } else if (e.quarter !== void 0) {
    const i = t ? aae(e.quarter) : e.quarter;
    n.push(Re(i) ? i * 3 : `${i}*3`);
  } else
    n.push(0);
  if (e.date !== void 0)
    n.push(e.date);
  else if (e.day !== void 0) {
    const i = t ? uae(e.day) : e.day;
    n.push(Re(i) ? i + 1 : `${i}+1`);
  } else
    n.push(1);
  for (const i of ["hours", "minutes", "seconds", "milliseconds"]) {
    const r = e[i];
    n.push(typeof r > "u" ? 0 : r);
  }
  return n;
}
function qa(e) {
  const n = iE(e, !0).join(", ");
  return e.utc ? `utc(${n})` : `datetime(${n})`;
}
function cae(e) {
  const n = iE(e, !1).join(", ");
  return e.utc ? `utc(${n})` : `datetime(${n})`;
}
function fae(e) {
  const t = iE(e, !0);
  return e.utc ? +new Date(Date.UTC(...t)) : +new Date(...t);
}
const F4 = {
  year: 1,
  quarter: 1,
  month: 1,
  week: 1,
  day: 1,
  dayofyear: 1,
  date: 1,
  hours: 1,
  minutes: 1,
  seconds: 1,
  milliseconds: 1
}, rE = q(F4);
function dae(e) {
  return !!F4[e];
}
function fl(e) {
  return ne(e) ? e.binned : T4(e);
}
function T4(e) {
  return e && e.startsWith("binned");
}
function sE(e) {
  return e.startsWith("utc");
}
function hae(e) {
  return e.substring(3);
}
const gae = {
  "year-month": "%b %Y ",
  "year-month-date": "%b %d, %Y "
};
function f0(e) {
  return rE.filter((t) => N4(e, t));
}
function O4(e) {
  const t = f0(e);
  return t[t.length - 1];
}
function N4(e, t) {
  const n = e.indexOf(t);
  return !(n < 0 || n > 0 && t === "seconds" && e.charAt(n - 1) === "i" || e.length > n + 3 && t === "day" && e.charAt(n + 3) === "o" || n > 0 && t === "year" && e.charAt(n - 1) === "f");
}
function pae(e, t, { end: n } = { end: !1 }) {
  const i = H_(t), r = sE(e) ? "utc" : "";
  function s(l) {
    return l === "quarter" ? `(${r}quarter(${i})-1)` : `${r}${l}(${i})`;
  }
  let o;
  const a = {};
  for (const l of rE)
    N4(e, l) && (a[l] = s(l), o = l);
  return n && (a[o] += "+1"), cae(a);
}
function D4(e) {
  if (!e)
    return;
  const t = f0(e);
  return `timeUnitSpecifier(${Ve(t)}, ${Ve(gae)})`;
}
function mae(e, t, n) {
  if (!e)
    return;
  const i = D4(e);
  return `${n || sE(e) ? "utc" : "time"}Format(${t}, ${i})`;
}
function Dt(e) {
  if (!e)
    return;
  let t;
  return te(e) ? T4(e) ? t = {
    unit: e.substring(6),
    binned: !0
  } : t = {
    unit: e
  } : ne(e) && (t = {
    ...e,
    ...e.unit ? { unit: e.unit } : {}
  }), sE(t.unit) && (t.utc = !0, t.unit = hae(t.unit)), t;
}
function yae(e) {
  const { utc: t, ...n } = Dt(e);
  return n.unit ? (t ? "utc" : "") + q(n).map((i) => tt(`${i === "unit" ? "" : `_${i}_`}${n[i]}`)).join("") : (t ? "utc" : "") + "timeunit" + q(n).map((i) => tt(`_${i}_${n[i]}`)).join("");
}
function R4(e, t = (n) => n) {
  const n = Dt(e), i = O4(n.unit);
  if (i && i !== "day") {
    const r = {
      year: 2001,
      month: 1,
      date: 1,
      hours: 0,
      minutes: 0,
      seconds: 0,
      milliseconds: 0
    }, { step: s, part: o } = L4(i, n.step), a = {
      ...r,
      [o]: +r[o] + s
    };
    return `${t(qa(a))} - ${t(qa(r))}`;
  }
}
const bae = {
  year: 1,
  month: 1,
  date: 1,
  hours: 1,
  minutes: 1,
  seconds: 1,
  milliseconds: 1
};
function vae(e) {
  return !!bae[e];
}
function L4(e, t = 1) {
  if (vae(e))
    return { part: e, step: t };
  switch (e) {
    case "day":
    case "dayofyear":
      return { part: "date", step: t };
    case "quarter":
      return { part: "month", step: t * 3 };
    case "week":
      return { part: "date", step: t * 7 };
  }
}
function xae(e) {
  return e == null ? void 0 : e.param;
}
function oE(e) {
  return !!(e != null && e.field) && e.equal !== void 0;
}
function aE(e) {
  return !!(e != null && e.field) && e.lt !== void 0;
}
function lE(e) {
  return !!(e != null && e.field) && e.lte !== void 0;
}
function uE(e) {
  return !!(e != null && e.field) && e.gt !== void 0;
}
function cE(e) {
  return !!(e != null && e.field) && e.gte !== void 0;
}
function fE(e) {
  if (e != null && e.field) {
    if (U(e.range) && e.range.length === 2)
      return !0;
    if (oe(e.range))
      return !0;
  }
  return !1;
}
function dE(e) {
  return !!(e != null && e.field) && (U(e.oneOf) || U(e.in));
}
function wae(e) {
  return !!(e != null && e.field) && e.valid !== void 0;
}
function P4(e) {
  return dE(e) || oE(e) || fE(e) || aE(e) || uE(e) || lE(e) || cE(e);
}
function dr(e, t) {
  return w0(e, { timeUnit: t, wrapTime: !0 });
}
function _ae(e, t) {
  return e.map((n) => dr(n, t));
}
function I4(e, t = !0) {
  const { field: n } = e, i = Dt(e.timeUnit), { unit: r, binned: s } = i || {}, o = J(e, { expr: "datum" }), a = r ? (
    // For timeUnit, cast into integer with time() so we can use ===, inrange, indexOf to compare values directly.
    // TODO: We calculate timeUnit on the fly here. Consider if we would like to consolidate this with timeUnit pipeline
    // TODO: support utc
    `time(${s ? o : pae(r, n)})`
  ) : o;
  if (oE(e))
    return `${a}===${dr(e.equal, r)}`;
  if (aE(e)) {
    const l = e.lt;
    return `${a}<${dr(l, r)}`;
  } else if (uE(e)) {
    const l = e.gt;
    return `${a}>${dr(l, r)}`;
  } else if (lE(e)) {
    const l = e.lte;
    return `${a}<=${dr(l, r)}`;
  } else if (cE(e)) {
    const l = e.gte;
    return `${a}>=${dr(l, r)}`;
  } else {
    if (dE(e))
      return `indexof([${_ae(e.oneOf, r).join(",")}], ${a}) !== -1`;
    if (wae(e))
      return hE(a, e.valid);
    if (fE(e)) {
      const { range: l } = e, u = oe(l) ? { signal: `${l.signal}[0]` } : l[0], c = oe(l) ? { signal: `${l.signal}[1]` } : l[1];
      if (u !== null && c !== null && t)
        return "inrange(" + a + ", [" + dr(u, r) + ", " + dr(c, r) + "])";
      const f = [];
      return u !== null && f.push(`${a} >= ${dr(u, r)}`), c !== null && f.push(`${a} <= ${dr(c, r)}`), f.length > 0 ? f.join(" && ") : "true";
    }
  }
  throw new Error(`Invalid field predicate: ${Ve(e)}`);
}
function hE(e, t = !0) {
  return t ? `isValid(${e}) && isFinite(+${e})` : `!isValid(${e}) || !isFinite(+${e})`;
}
function Eae(e) {
  return P4(e) && e.timeUnit ? {
    ...e,
    timeUnit: Dt(e.timeUnit)
  } : e;
}
const Dd = {
  quantitative: "quantitative",
  ordinal: "ordinal",
  temporal: "temporal",
  nominal: "nominal",
  geojson: "geojson"
};
function Sae(e) {
  return e === "quantitative" || e === "temporal";
}
function z4(e) {
  return e === "ordinal" || e === "nominal";
}
const Wa = Dd.quantitative, gE = Dd.ordinal, Eu = Dd.temporal, pE = Dd.nominal, Ju = Dd.geojson;
function kae(e) {
  if (e)
    switch (e = e.toLowerCase(), e) {
      case "q":
      case Wa:
        return "quantitative";
      case "t":
      case Eu:
        return "temporal";
      case "o":
      case gE:
        return "ordinal";
      case "n":
      case pE:
        return "nominal";
      case Ju:
        return "geojson";
    }
}
const Dn = {
  // Continuous - Quantitative
  LINEAR: "linear",
  LOG: "log",
  POW: "pow",
  SQRT: "sqrt",
  SYMLOG: "symlog",
  IDENTITY: "identity",
  SEQUENTIAL: "sequential",
  // Continuous - Time
  TIME: "time",
  UTC: "utc",
  // Discretizing scales
  QUANTILE: "quantile",
  QUANTIZE: "quantize",
  THRESHOLD: "threshold",
  BIN_ORDINAL: "bin-ordinal",
  // Discrete scales
  ORDINAL: "ordinal",
  POINT: "point",
  BAND: "band"
}, gv = {
  linear: "numeric",
  log: "numeric",
  pow: "numeric",
  sqrt: "numeric",
  symlog: "numeric",
  identity: "numeric",
  sequential: "numeric",
  time: "time",
  utc: "time",
  ordinal: "ordinal",
  "bin-ordinal": "bin-ordinal",
  point: "ordinal-position",
  band: "ordinal-position",
  quantile: "discretizing",
  quantize: "discretizing",
  threshold: "discretizing"
};
function Aae(e, t) {
  const n = gv[e], i = gv[t];
  return n === i || n === "ordinal-position" && i === "time" || i === "ordinal-position" && n === "time";
}
const Cae = {
  // numeric
  linear: 0,
  log: 1,
  pow: 1,
  sqrt: 1,
  symlog: 1,
  identity: 1,
  sequential: 1,
  // time
  time: 0,
  utc: 0,
  // ordinal-position -- these have higher precedence than continuous scales as they support more types of data
  point: 10,
  band: 11,
  // non grouped types
  ordinal: 0,
  "bin-ordinal": 0,
  quantile: 0,
  quantize: 0,
  threshold: 0
};
function B$(e) {
  return Cae[e];
}
const B4 = /* @__PURE__ */ new Set([
  "linear",
  "log",
  "pow",
  "sqrt",
  "symlog"
]), j4 = /* @__PURE__ */ new Set([
  ...B4,
  "time",
  "utc"
]);
function U4(e) {
  return B4.has(e);
}
const q4 = /* @__PURE__ */ new Set([
  "quantile",
  "quantize",
  "threshold"
]), $ae = /* @__PURE__ */ new Set([
  ...j4,
  ...q4,
  "sequential",
  "identity"
]), Mae = /* @__PURE__ */ new Set([
  "ordinal",
  "bin-ordinal",
  "point",
  "band"
]);
function Rt(e) {
  return Mae.has(e);
}
function li(e) {
  return $ae.has(e);
}
function Gi(e) {
  return j4.has(e);
}
function Su(e) {
  return q4.has(e);
}
const Fae = {
  pointPadding: 0.5,
  barBandPaddingInner: 0.1,
  rectBandPaddingInner: 0,
  bandWithNestedOffsetPaddingInner: 0.2,
  bandWithNestedOffsetPaddingOuter: 0.2,
  minBandSize: 2,
  minFontSize: 8,
  maxFontSize: 40,
  minOpacity: 0.3,
  maxOpacity: 0.8,
  // FIXME: revise if these *can* become ratios of width/height step
  minSize: 9,
  minStrokeWidth: 1,
  maxStrokeWidth: 4,
  quantileCount: 4,
  quantizeCount: 4,
  zero: !0
};
function Tae(e) {
  return !te(e) && !!e.name;
}
function W4(e) {
  return e == null ? void 0 : e.param;
}
function Oae(e) {
  return e == null ? void 0 : e.unionWith;
}
function Nae(e) {
  return ne(e) && "field" in e;
}
const Dae = {
  type: 1,
  domain: 1,
  domainMax: 1,
  domainMin: 1,
  domainMid: 1,
  domainRaw: 1,
  align: 1,
  range: 1,
  rangeMax: 1,
  rangeMin: 1,
  scheme: 1,
  bins: 1,
  // Other properties
  reverse: 1,
  round: 1,
  // quantitative / time
  clamp: 1,
  nice: 1,
  // quantitative
  base: 1,
  exponent: 1,
  constant: 1,
  interpolate: 1,
  zero: 1,
  // band/point
  padding: 1,
  paddingInner: 1,
  paddingOuter: 1
}, { type: _0e, domain: E0e, range: S0e, rangeMax: k0e, rangeMin: A0e, scheme: C0e, ...Rae } = Dae, Lae = q(Rae);
function pv(e, t) {
  switch (t) {
    case "type":
    case "domain":
    case "reverse":
    case "range":
      return !0;
    case "scheme":
    case "interpolate":
      return !["point", "band", "identity"].includes(e);
    case "bins":
      return !["point", "band", "identity", "ordinal"].includes(e);
    case "round":
      return Gi(e) || e === "band" || e === "point";
    case "padding":
    case "rangeMin":
    case "rangeMax":
      return Gi(e) || ["point", "band"].includes(e);
    case "paddingOuter":
    case "align":
      return ["point", "band"].includes(e);
    case "paddingInner":
      return e === "band";
    case "domainMax":
    case "domainMid":
    case "domainMin":
    case "domainRaw":
    case "clamp":
      return Gi(e);
    case "nice":
      return Gi(e) || e === "quantize" || e === "threshold";
    case "exponent":
      return e === "pow";
    case "base":
      return e === "log";
    case "constant":
      return e === "symlog";
    case "zero":
      return li(e) && !Me([
        "log",
        "time",
        "utc",
        "threshold",
        "quantile"
        // quantile depends on distribution so zero does not matter
      ], e);
  }
}
function H4(e, t) {
  switch (t) {
    case "interpolate":
    case "scheme":
    case "domainMid":
      return Vl(e) ? void 0 : Ooe(t);
    case "align":
    case "type":
    case "bins":
    case "domain":
    case "domainMax":
    case "domainMin":
    case "domainRaw":
    case "range":
    case "base":
    case "exponent":
    case "constant":
    case "nice":
    case "padding":
    case "paddingInner":
    case "paddingOuter":
    case "rangeMax":
    case "rangeMin":
    case "reverse":
    case "round":
    case "clamp":
    case "zero":
      return;
  }
}
function Pae(e, t) {
  return Me([gE, pE], t) ? e === void 0 || Rt(e) : t === Eu ? Me([Dn.TIME, Dn.UTC, void 0], e) : t === Wa ? U4(e) || Su(e) || e === void 0 : !0;
}
function Iae(e, t, n = !1) {
  if (!Ls(e))
    return !1;
  switch (e) {
    case nt:
    case Pt:
    case Io:
    case Ku:
    case Fi:
    case or:
      return Gi(t) || t === "band" ? !0 : t === "point" ? !n : !1;
    case Ds:
    case jo:
    case Rs:
    case zo:
    case Bo:
    case al:
      return Gi(t) || Su(t) || Me(["band", "point", "ordinal"], t);
    case jn:
    case Wr:
    case Hr:
      return t !== "band";
    case Uo:
    case Un:
      return t === "ordinal" || Su(t);
  }
}
const kn = {
  arc: "arc",
  area: "area",
  bar: "bar",
  image: "image",
  line: "line",
  point: "point",
  rect: "rect",
  rule: "rule",
  text: "text",
  tick: "tick",
  trail: "trail",
  circle: "circle",
  square: "square",
  geoshape: "geoshape"
}, G4 = kn.arc, d0 = kn.area, h0 = kn.bar, zae = kn.image, g0 = kn.line, p0 = kn.point, Bae = kn.rect, Ep = kn.rule, V4 = kn.text, mE = kn.tick, jae = kn.trail, yE = kn.circle, bE = kn.square, Y4 = kn.geoshape;
function Ho(e) {
  return ["line", "area", "trail"].includes(e);
}
function Vf(e) {
  return [
    "rect",
    "bar",
    "image",
    "arc"
    /* arc is rect/interval in polar coordinate */
  ].includes(e);
}
const Uae = new Set(q(kn));
function Dr(e) {
  return e.type;
}
const qae = [
  "stroke",
  "strokeWidth",
  "strokeDash",
  "strokeDashOffset",
  "strokeOpacity",
  "strokeJoin",
  "strokeMiterLimit"
], Wae = ["fill", "fillOpacity"], Hae = [...qae, ...Wae], Gae = {
  color: 1,
  filled: 1,
  invalid: 1,
  order: 1,
  radius2: 1,
  theta2: 1,
  timeUnitBandSize: 1,
  timeUnitBandPosition: 1
}, j$ = q(Gae), Vae = {
  area: ["line", "point"],
  bar: ["binSpacing", "continuousBandSize", "discreteBandSize", "minBandSize"],
  rect: ["binSpacing", "continuousBandSize", "discreteBandSize", "minBandSize"],
  line: ["point"],
  tick: ["bandSize", "thickness"]
}, Yae = {
  color: "#4c78a8",
  invalid: "filter",
  timeUnitBandSize: 1
}, Xae = {
  mark: 1,
  arc: 1,
  area: 1,
  bar: 1,
  circle: 1,
  image: 1,
  line: 1,
  point: 1,
  rect: 1,
  rule: 1,
  square: 1,
  text: 1,
  tick: 1,
  trail: 1,
  geoshape: 1
}, X4 = q(Xae);
function Ha(e) {
  return e && e.band != null;
}
const Kae = {
  horizontal: ["cornerRadiusTopRight", "cornerRadiusBottomRight"],
  vertical: ["cornerRadiusTopLeft", "cornerRadiusTopRight"]
}, K4 = 5, Jae = {
  binSpacing: 1,
  continuousBandSize: K4,
  minBandSize: 0.25,
  timeUnitBandPosition: 0.5
}, Qae = {
  binSpacing: 0,
  continuousBandSize: K4,
  minBandSize: 0.25,
  timeUnitBandPosition: 0.5
}, Zae = {
  thickness: 1
};
function ele(e) {
  return Dr(e) ? e.type : e;
}
function vE(e) {
  const { channel: t, channelDef: n, markDef: i, scale: r, config: s } = e, o = wE(e);
  return (
    // Only this for field def without counting aggregate (as count wouldn't be null)
    H(n) && !f4(n.aggregate) && // and only for continuous scale
    r && Gi(r.get("type")) ? tle({
      fieldDef: n,
      channel: t,
      markDef: i,
      ref: o,
      config: s
    }) : o
  );
}
function tle({ fieldDef: e, channel: t, markDef: n, ref: i, config: r }) {
  return Ho(n.type) ? i : qe("invalid", n, r) === null ? [nle(e, t), i] : i;
}
function nle(e, t) {
  const n = xE(e, !0), r = ll(t) === "y" ? { field: { group: "height" } } : (
    // x / angle / radius can all use 0
    { value: 0 }
  );
  return { test: n, ...r };
}
function xE(e, t = !0) {
  return hE(te(e) ? e : J(e, { expr: "datum" }), !t);
}
function ile(e) {
  const { datum: t } = e;
  return cl(t) ? qa(t) : `${Ve(t)}`;
}
function Sa(e, t, n, i) {
  const r = {};
  if (t && (r.scale = t), Yr(e)) {
    const { datum: s } = e;
    cl(s) ? r.signal = qa(s) : oe(s) ? r.signal = s.signal : Nd(s) ? r.signal = s.expr : r.value = s;
  } else
    r.field = J(e, n);
  if (i) {
    const { offset: s, band: o } = i;
    s && (r.offset = s), o && (r.band = o);
  }
  return r;
}
function Sp({ scaleName: e, fieldOrDatumDef: t, fieldOrDatumDef2: n, offset: i, startSuffix: r, endSuffix: s = "end", bandPosition: o = 0.5 }) {
  const a = !oe(o) && 0 < o && o < 1 ? "datum" : void 0, l = J(t, { expr: a, suffix: r }), u = n !== void 0 ? J(n, { expr: a }) : J(t, { suffix: s, expr: a }), c = {};
  if (o === 0 || o === 1) {
    c.scale = e;
    const f = o === 0 ? l : u;
    c.field = f;
  } else {
    const f = oe(o) ? `(1-${o.signal}) * ${l} + ${o.signal} * ${u}` : `${1 - o} * ${l} + ${o} * ${u}`;
    c.signal = `scale("${e}", ${f})`;
  }
  return i && (c.offset = i), c;
}
function rle({ scaleName: e, fieldDef: t }) {
  const n = J(t, { expr: "datum" }), i = J(t, { expr: "datum", suffix: "end" });
  return `abs(scale("${e}", ${i}) - scale("${e}", ${n}))`;
}
function wE({ channel: e, channelDef: t, channel2Def: n, markDef: i, config: r, scaleName: s, scale: o, stack: a, offset: l, defaultRef: u, bandPosition: c }) {
  if (t) {
    if (be(t)) {
      const f = o == null ? void 0 : o.get("type");
      if (En(t)) {
        c ?? (c = Ao({
          fieldDef: t,
          fieldDef2: n,
          markDef: i,
          config: r
        }));
        const { bin: d, timeUnit: h, type: g } = t;
        if (Je(d) || c && h && g === Eu)
          return a != null && a.impute ? Sa(t, s, { binSuffix: "mid" }, { offset: l }) : c && !Rt(f) ? Sp({ scaleName: s, fieldOrDatumDef: t, bandPosition: c, offset: l }) : Sa(t, s, Id(t, e) ? { binSuffix: "range" } : {}, {
            offset: l
          });
        if (Bt(d)) {
          if (H(n))
            return Sp({
              scaleName: s,
              fieldOrDatumDef: t,
              fieldOrDatumDef2: n,
              bandPosition: c,
              offset: l
            });
          G(A4(e === nt ? sr : qr));
        }
      }
      return Sa(
        t,
        s,
        Rt(f) ? { binSuffix: "range" } : {},
        // no need for bin suffix if there is no scale
        {
          offset: l,
          // For band, to get mid point, need to offset by half of the band
          band: f === "band" ? c ?? t.bandPosition ?? 0.5 : void 0
        }
      );
    } else if (er(t)) {
      const f = t.value, d = l ? { offset: l } : {};
      return { ...gf(e, f), ...d };
    }
  }
  return Ee(u) && (u = u()), u && {
    ...u,
    // only include offset when it is non-zero (zero = no offset)
    ...l ? { offset: l } : {}
  };
}
function gf(e, t) {
  return Me(["x", "x2"], e) && t === "width" ? { field: { group: "width" } } : Me(["y", "y2"], e) && t === "height" ? { field: { group: "height" } } : Ze(t);
}
function Ga(e) {
  return e && e !== "number" && e !== "time";
}
function J4(e, t, n) {
  return `${e}(${t}${n ? `, ${Ve(n)}` : ""})`;
}
const sle = " – ";
function _E({ fieldOrDatumDef: e, format: t, formatType: n, expr: i, normalizeStack: r, config: s }) {
  var l, u;
  if (Ga(n))
    return Vi({
      fieldOrDatumDef: e,
      format: t,
      formatType: n,
      expr: i,
      config: s
    });
  const o = Q4(e, i, r), a = ku(e);
  if (t === void 0 && n === void 0 && s.customFormatTypes) {
    if (a === "quantitative") {
      if (r && s.normalizedNumberFormatType)
        return Vi({
          fieldOrDatumDef: e,
          format: s.normalizedNumberFormat,
          formatType: s.normalizedNumberFormatType,
          expr: i,
          config: s
        });
      if (s.numberFormatType)
        return Vi({
          fieldOrDatumDef: e,
          format: s.numberFormat,
          formatType: s.numberFormatType,
          expr: i,
          config: s
        });
    }
    if (a === "temporal" && s.timeFormatType && H(e) && e.timeUnit === void 0)
      return Vi({
        fieldOrDatumDef: e,
        format: s.timeFormat,
        formatType: s.timeFormatType,
        expr: i,
        config: s
      });
  }
  if (Cu(e)) {
    const c = ale({
      field: o,
      timeUnit: H(e) ? (l = Dt(e.timeUnit)) == null ? void 0 : l.unit : void 0,
      format: t,
      formatType: s.timeFormatType,
      rawTimeFormat: s.timeFormat,
      isUTCScale: dl(e) && ((u = e.scale) == null ? void 0 : u.type) === Dn.UTC
    });
    return c ? { signal: c } : void 0;
  }
  if (t = mv({ type: a, specifiedFormat: t, config: s, normalizeStack: r }), H(e) && Je(e.bin)) {
    const c = J(e, { expr: i, binSuffix: "end" });
    return {
      signal: Rd(o, c, t, n, s)
    };
  } else
    return t || ku(e) === "quantitative" ? {
      signal: `${tL(o, t)}`
    } : { signal: `isValid(${o}) ? ${o} : ""+${o}` };
}
function Q4(e, t, n) {
  return H(e) ? n ? `${J(e, { expr: t, suffix: "end" })}-${J(e, {
    expr: t,
    suffix: "start"
  })}` : J(e, { expr: t }) : ile(e);
}
function Vi({ fieldOrDatumDef: e, format: t, formatType: n, expr: i, normalizeStack: r, config: s, field: o }) {
  if (o ?? (o = Q4(e, i, r)), o !== "datum.value" && // For axis/legend, we can't correctly know the end of the bin from `datum`
  H(e) && Je(e.bin)) {
    const a = J(e, { expr: i, binSuffix: "end" });
    return {
      signal: Rd(o, a, t, n, s)
    };
  }
  return { signal: J4(n, o, t) };
}
function Z4(e, t, n, i, r, s) {
  var o;
  if (!(te(i) && Ga(i)) && !(n === void 0 && i === void 0 && r.customFormatTypes && ku(e) === "quantitative" && (r.normalizedNumberFormatType && Au(e) && e.stack === "normalize" || r.numberFormatType))) {
    if (Au(e) && e.stack === "normalize" && r.normalizedNumberFormat)
      return mv({
        type: "quantitative",
        config: r,
        normalizeStack: !0
      });
    if (Cu(e)) {
      const a = H(e) ? (o = Dt(e.timeUnit)) == null ? void 0 : o.unit : void 0;
      return a === void 0 && r.customFormatTypes && r.timeFormatType ? void 0 : ole({ specifiedFormat: n, timeUnit: a, config: r, omitTimeFormatConfig: s });
    }
    return mv({ type: t, specifiedFormat: n, config: r });
  }
}
function eL(e, t, n) {
  var i;
  if (e && (oe(e) || e === "number" || e === "time"))
    return e;
  if (Cu(t) && n !== "time" && n !== "utc")
    return H(t) && ((i = Dt(t == null ? void 0 : t.timeUnit)) != null && i.utc) ? "utc" : "time";
}
function mv({ type: e, specifiedFormat: t, config: n, normalizeStack: i }) {
  if (te(t))
    return t;
  if (e === Wa)
    return i ? n.normalizedNumberFormat : n.numberFormat;
}
function ole({ specifiedFormat: e, timeUnit: t, config: n, omitTimeFormatConfig: i }) {
  return e || (t ? {
    signal: D4(t)
  } : i ? void 0 : n.timeFormat);
}
function tL(e, t) {
  return `format(${e}, "${t || ""}")`;
}
function U$(e, t, n, i) {
  return Ga(n) ? J4(n, e, t) : tL(e, (te(t) ? t : void 0) ?? i.numberFormat);
}
function Rd(e, t, n, i, r) {
  if (n === void 0 && i === void 0 && r.customFormatTypes && r.numberFormatType)
    return Rd(e, t, r.numberFormat, r.numberFormatType, r);
  const s = U$(e, n, i, r), o = U$(t, n, i, r);
  return `${hE(e, !1)} ? "null" : ${s} + "${sle}" + ${o}`;
}
function ale({ field: e, timeUnit: t, format: n, formatType: i, rawTimeFormat: r, isUTCScale: s }) {
  return !t || n ? !t && i ? `${i}(${e}, '${n}')` : (n = te(n) ? n : r, `${s ? "utc" : "time"}Format(${e}, '${n}')`) : mae(t, e, s);
}
const m0 = "min", lle = {
  x: 1,
  y: 1,
  color: 1,
  fill: 1,
  stroke: 1,
  strokeWidth: 1,
  size: 1,
  shape: 1,
  fillOpacity: 1,
  strokeOpacity: 1,
  opacity: 1,
  text: 1
};
function q$(e) {
  return e in lle;
}
function nL(e) {
  return !!(e != null && e.encoding);
}
function Sr(e) {
  return e && (e.op === "count" || !!e.field);
}
function iL(e) {
  return e && U(e);
}
function Ld(e) {
  return "row" in e || "column" in e;
}
function EE(e) {
  return !!e && "header" in e;
}
function y0(e) {
  return "facet" in e;
}
function ule(e) {
  return e.param;
}
function cle(e) {
  return e && !te(e) && "repeat" in e;
}
function W$(e) {
  const { field: t, timeUnit: n, bin: i, aggregate: r } = e;
  return {
    ...n ? { timeUnit: n } : {},
    ...i ? { bin: i } : {},
    ...r ? { aggregate: r } : {},
    field: t
  };
}
function SE(e) {
  return "sort" in e;
}
function Ao({ fieldDef: e, fieldDef2: t, markDef: n, config: i }) {
  if (be(e) && e.bandPosition !== void 0)
    return e.bandPosition;
  if (H(e)) {
    const { timeUnit: r, bin: s } = e;
    if (r && !t)
      return ks("timeUnitBandPosition", n, i);
    if (Je(s))
      return 0.5;
  }
}
function rL({ channel: e, fieldDef: t, fieldDef2: n, markDef: i, config: r, scaleType: s, useVlSizeChannel: o }) {
  var u, c, f;
  const a = qn(e), l = qe(o ? "size" : a, i, r, {
    vgChannel: a
  });
  if (l !== void 0)
    return l;
  if (H(t)) {
    const { timeUnit: d, bin: h } = t;
    if (d && !n)
      return { band: ks("timeUnitBandSize", i, r) };
    if (Je(h) && !Rt(s))
      return { band: 1 };
  }
  if (Vf(i.type))
    return s ? Rt(s) ? ((u = r[i.type]) == null ? void 0 : u.discreteBandSize) || { band: 1 } : (c = r[i.type]) == null ? void 0 : c.continuousBandSize : (f = r[i.type]) == null ? void 0 : f.discreteBandSize;
}
function sL(e, t, n, i) {
  return Je(e.bin) || e.timeUnit && En(e) && e.type === "temporal" ? Ao({ fieldDef: e, fieldDef2: t, markDef: n, config: i }) !== void 0 : !1;
}
function oL(e) {
  return e && !!e.sort && !e.field;
}
function b0(e) {
  return e && "condition" in e;
}
function v0(e) {
  const t = e == null ? void 0 : e.condition;
  return !!t && !U(t) && H(t);
}
function Pd(e) {
  const t = e == null ? void 0 : e.condition;
  return !!t && !U(t) && be(t);
}
function fle(e) {
  const t = e == null ? void 0 : e.condition;
  return !!t && (U(t) || er(t));
}
function H(e) {
  return e && (!!e.field || e.aggregate === "count");
}
function ku(e) {
  return e == null ? void 0 : e.type;
}
function Yr(e) {
  return e && "datum" in e;
}
function ro(e) {
  return En(e) && !Ap(e) || kp(e);
}
function H$(e) {
  return En(e) && e.type === "quantitative" && !e.bin || kp(e);
}
function kp(e) {
  return Yr(e) && Re(e.datum);
}
function be(e) {
  return H(e) || Yr(e);
}
function En(e) {
  return e && ("field" in e || e.aggregate === "count") && "type" in e;
}
function er(e) {
  return e && "value" in e && "value" in e;
}
function dl(e) {
  return e && ("scale" in e || "sort" in e);
}
function Au(e) {
  return e && ("axis" in e || "stack" in e || "impute" in e);
}
function aL(e) {
  return e && "legend" in e;
}
function lL(e) {
  return e && ("format" in e || "formatType" in e);
}
function dle(e) {
  return Nn(e, ["legend", "axis", "header", "scale"]);
}
function hle(e) {
  return "op" in e;
}
function J(e, t = {}) {
  let n = e.field;
  const i = t.prefix;
  let r = t.suffix, s = "";
  if (ple(e))
    n = J6("count");
  else {
    let o;
    if (!t.nofn)
      if (hle(e))
        o = e.op;
      else {
        const { bin: a, aggregate: l, timeUnit: u } = e;
        Je(a) ? (o = d4(a), r = (t.binSuffix ?? "") + (t.suffix ?? "")) : l ? qo(l) ? (s = `["${n}"]`, n = `argmax_${l.argmax}`) : Ss(l) ? (s = `["${n}"]`, n = `argmin_${l.argmin}`) : o = String(l) : u && !fl(u) && (o = yae(u), r = (!["range", "mid"].includes(t.binSuffix) && t.binSuffix || "") + (t.suffix ?? ""));
      }
    o && (n = n ? `${o}_${n}` : o);
  }
  return r && (n = `${n}_${r}`), i && (n = `${i}_${n}`), t.forAs ? G_(n) : t.expr ? Y6(n, t.expr) + s : Ci(n) + s;
}
function Ap(e) {
  switch (e.type) {
    case "nominal":
    case "ordinal":
    case "geojson":
      return !0;
    case "quantitative":
      return H(e) && !!e.bin;
    case "temporal":
      return !1;
  }
  throw new Error(_4(e.type));
}
function gle(e) {
  var t;
  return dl(e) && Su((t = e.scale) == null ? void 0 : t.type);
}
function ple(e) {
  return e.aggregate === "count";
}
function mle(e, t) {
  var o;
  const { field: n, bin: i, timeUnit: r, aggregate: s } = e;
  if (s === "count")
    return t.countTitle;
  if (Je(i))
    return `${n} (binned)`;
  if (r && !fl(r)) {
    const a = (o = Dt(r)) == null ? void 0 : o.unit;
    if (a)
      return `${n} (${f0(a).join("-")})`;
  } else if (s)
    return qo(s) ? `${n} for max ${s.argmax}` : Ss(s) ? `${n} for min ${s.argmin}` : `${Md(s)} of ${n}`;
  return n;
}
function yle(e) {
  const { aggregate: t, bin: n, timeUnit: i, field: r } = e;
  if (qo(t))
    return `${r} for argmax(${t.argmax})`;
  if (Ss(t))
    return `${r} for argmin(${t.argmin})`;
  const s = i && !fl(i) ? Dt(i) : void 0, o = t || (s == null ? void 0 : s.unit) || (s == null ? void 0 : s.maxbins) && "timeunit" || Je(n) && "bin";
  return o ? `${o.toUpperCase()}(${r})` : r;
}
const uL = (e, t) => {
  switch (t.fieldTitle) {
    case "plain":
      return e.field;
    case "functional":
      return yle(e);
    default:
      return mle(e, t);
  }
};
let cL = uL;
function fL(e) {
  cL = e;
}
function ble() {
  fL(uL);
}
function Yl(e, t, { allowDisabling: n, includeDefault: i = !0 }) {
  var a;
  const r = (a = kE(e)) == null ? void 0 : a.title;
  if (!H(e))
    return r ?? e.title;
  const s = e, o = i ? AE(s, t) : void 0;
  return n ? dt(r, s.title, o) : r ?? s.title ?? o;
}
function kE(e) {
  if (Au(e) && e.axis)
    return e.axis;
  if (aL(e) && e.legend)
    return e.legend;
  if (EE(e) && e.header)
    return e.header;
}
function AE(e, t) {
  return cL(e, t);
}
function Cp(e) {
  if (lL(e)) {
    const { format: t, formatType: n } = e;
    return { format: t, formatType: n };
  } else {
    const t = kE(e) ?? {}, { format: n, formatType: i } = t;
    return { format: n, formatType: i };
  }
}
function vle(e, t) {
  var s;
  switch (t) {
    case "latitude":
    case "longitude":
      return "quantitative";
    case "row":
    case "column":
    case "facet":
    case "shape":
    case "strokeDash":
      return "nominal";
    case "order":
      return "ordinal";
  }
  if (SE(e) && U(e.sort))
    return "ordinal";
  const { aggregate: n, bin: i, timeUnit: r } = e;
  if (r)
    return "temporal";
  if (i || n && !qo(n) && !Ss(n))
    return "quantitative";
  if (dl(e) && ((s = e.scale) != null && s.type))
    switch (gv[e.scale.type]) {
      case "numeric":
      case "discretizing":
        return "quantitative";
      case "time":
        return "temporal";
    }
  return "nominal";
}
function Rr(e) {
  if (H(e))
    return e;
  if (v0(e))
    return e.condition;
}
function wt(e) {
  if (be(e))
    return e;
  if (Pd(e))
    return e.condition;
}
function dL(e, t, n, i = {}) {
  if (te(e) || Re(e) || To(e)) {
    const r = te(e) ? "string" : Re(e) ? "number" : "boolean";
    return G(xoe(t, r, e)), { value: e };
  }
  return be(e) ? $p(e, t, n, i) : Pd(e) ? {
    ...e,
    // Need to cast as normalizeFieldDef normally return FieldDef, but here we know that it is definitely Condition<FieldDef>
    condition: $p(e.condition, t, n, i)
  } : e;
}
function $p(e, t, n, i) {
  if (lL(e)) {
    const { format: r, formatType: s, ...o } = e;
    if (Ga(s) && !n.customFormatTypes)
      return G(P$(t)), $p(o, t, n, i);
  } else {
    const r = Au(e) ? "axis" : aL(e) ? "legend" : EE(e) ? "header" : null;
    if (r && e[r]) {
      const { format: s, formatType: o, ...a } = e[r];
      if (Ga(o) && !n.customFormatTypes)
        return G(P$(t)), $p({ ...e, [r]: a }, t, n, i);
    }
  }
  return H(e) ? CE(e, t, i) : xle(e);
}
function xle(e) {
  let t = e.type;
  if (t)
    return e;
  const { datum: n } = e;
  return t = Re(n) ? "quantitative" : te(n) ? "nominal" : cl(n) ? "temporal" : void 0, { ...e, type: t };
}
function CE(e, t, { compositeMark: n = !1 } = {}) {
  const { aggregate: i, timeUnit: r, bin: s, field: o } = e, a = { ...e };
  if (!n && i && !eE(i) && !qo(i) && !Ss(i) && (G(_oe(i)), delete a.aggregate), r && (a.timeUnit = Dt(r)), o && (a.field = `${o}`), Je(s) && (a.bin = x0(s, t)), Bt(s) && !ht(t) && G(eae(t)), En(a)) {
    const { type: l } = a, u = kae(l);
    l !== u && (a.type = u), l !== "quantitative" && f4(i) && (G(woe(l, i)), a.type = "quantitative");
  } else if (!s4(t)) {
    const l = vle(a, t);
    a.type = l;
  }
  if (En(a)) {
    const { compatible: l, warning: u } = wle(a, t) || {};
    l === !1 && G(u);
  }
  if (SE(a) && te(a.sort)) {
    const { sort: l } = a;
    if (q$(l))
      return {
        ...a,
        sort: { encoding: l }
      };
    const u = l.substr(1);
    if (l.charAt(0) === "-" && q$(u))
      return {
        ...a,
        sort: { encoding: u, order: "descending" }
      };
  }
  if (EE(a)) {
    const { header: l } = a;
    if (l) {
      const { orient: u, ...c } = l;
      if (u)
        return {
          ...a,
          header: {
            ...c,
            labelOrient: l.labelOrient || u,
            titleOrient: l.titleOrient || u
          }
        };
    }
  }
  return a;
}
function x0(e, t) {
  return To(e) ? { maxbins: $$(t) } : e === "binned" ? {
    binned: !0
  } : !e.maxbins && !e.step ? { ...e, maxbins: $$(t) } : e;
}
const kl = { compatible: !0 };
function wle(e, t) {
  const n = e.type;
  if (n === "geojson" && t !== "shape")
    return {
      compatible: !1,
      warning: `Channel ${t} should not be used with a geojson data.`
    };
  switch (t) {
    case ms:
    case ys:
    case n0:
      return Ap(e) ? kl : {
        compatible: !1,
        warning: Aoe(t)
      };
    case nt:
    case Pt:
    case Io:
    case Ku:
    case jn:
    case Wr:
    case Hr:
    case Fd:
    case Td:
    case i0:
    case Ua:
    case r0:
    case s0:
    case al:
    case Fi:
    case or:
    case o0:
      return kl;
    case lr:
    case $i:
    case ar:
    case ur:
      return n !== Wa ? {
        compatible: !1,
        warning: `Channel ${t} should be used with a quantitative field only, not ${e.type} field.`
      } : kl;
    case Rs:
    case zo:
    case Bo:
    case jo:
    case Ds:
    case Ns:
    case Os:
    case sr:
    case qr:
      return n === "nominal" && !e.sort ? {
        compatible: !1,
        warning: `Channel ${t} should not be used with an unsorted discrete field.`
      } : kl;
    case Un:
    case Uo:
      return !Ap(e) && !gle(e) ? {
        compatible: !1,
        warning: Coe(t)
      } : kl;
    case wu:
      return e.type === "nominal" && !("sort" in e) ? {
        compatible: !1,
        warning: "Channel order is inappropriate for nominal field, which has no inherent order."
      } : kl;
  }
}
function Cu(e) {
  const { formatType: t } = Cp(e);
  return t === "time" || !t && _le(e);
}
function _le(e) {
  return e && (e.type === "temporal" || H(e) && !!e.timeUnit);
}
function w0(e, { timeUnit: t, type: n, wrapTime: i, undefinedIfExprNotRequired: r }) {
  var l;
  const s = t && ((l = Dt(t)) == null ? void 0 : l.unit);
  let o = s || n === "temporal", a;
  return Nd(e) ? a = e.expr : oe(e) ? a = e.signal : cl(e) ? (o = !0, a = qa(e)) : (te(e) || Re(e)) && o && (a = `datetime(${Ve(e)})`, dae(s) && (Re(e) && e < 1e4 || te(e) && isNaN(Date.parse(e))) && (a = qa({ [s]: e }))), a ? i && o ? `time(${a})` : a : r ? void 0 : Ve(e);
}
function hL(e, t) {
  const { type: n } = e;
  return t.map((i) => {
    const r = H(e) && !fl(e.timeUnit) ? e.timeUnit : void 0, s = w0(i, {
      timeUnit: r,
      type: n,
      undefinedIfExprNotRequired: !0
    });
    return s !== void 0 ? { signal: s } : i;
  });
}
function Id(e, t) {
  return Je(e.bin) ? Ls(t) && ["ordinal", "nominal"].includes(e.type) : (console.warn("Only call this method for binned field defs."), !1);
}
const G$ = {
  labelAlign: {
    part: "labels",
    vgProp: "align"
  },
  labelBaseline: {
    part: "labels",
    vgProp: "baseline"
  },
  labelColor: {
    part: "labels",
    vgProp: "fill"
  },
  labelFont: {
    part: "labels",
    vgProp: "font"
  },
  labelFontSize: {
    part: "labels",
    vgProp: "fontSize"
  },
  labelFontStyle: {
    part: "labels",
    vgProp: "fontStyle"
  },
  labelFontWeight: {
    part: "labels",
    vgProp: "fontWeight"
  },
  labelOpacity: {
    part: "labels",
    vgProp: "opacity"
  },
  labelOffset: null,
  labelPadding: null,
  gridColor: {
    part: "grid",
    vgProp: "stroke"
  },
  gridDash: {
    part: "grid",
    vgProp: "strokeDash"
  },
  gridDashOffset: {
    part: "grid",
    vgProp: "strokeDashOffset"
  },
  gridOpacity: {
    part: "grid",
    vgProp: "opacity"
  },
  gridWidth: {
    part: "grid",
    vgProp: "strokeWidth"
  },
  tickColor: {
    part: "ticks",
    vgProp: "stroke"
  },
  tickDash: {
    part: "ticks",
    vgProp: "strokeDash"
  },
  tickDashOffset: {
    part: "ticks",
    vgProp: "strokeDashOffset"
  },
  tickOpacity: {
    part: "ticks",
    vgProp: "opacity"
  },
  tickSize: null,
  tickWidth: {
    part: "ticks",
    vgProp: "strokeWidth"
  }
};
function zd(e) {
  return e == null ? void 0 : e.condition;
}
const gL = ["domain", "grid", "labels", "ticks", "title"], Ele = {
  grid: "grid",
  gridCap: "grid",
  gridColor: "grid",
  gridDash: "grid",
  gridDashOffset: "grid",
  gridOpacity: "grid",
  gridScale: "grid",
  gridWidth: "grid",
  orient: "main",
  bandPosition: "both",
  aria: "main",
  description: "main",
  domain: "main",
  domainCap: "main",
  domainColor: "main",
  domainDash: "main",
  domainDashOffset: "main",
  domainOpacity: "main",
  domainWidth: "main",
  format: "main",
  formatType: "main",
  labelAlign: "main",
  labelAngle: "main",
  labelBaseline: "main",
  labelBound: "main",
  labelColor: "main",
  labelFlush: "main",
  labelFlushOffset: "main",
  labelFont: "main",
  labelFontSize: "main",
  labelFontStyle: "main",
  labelFontWeight: "main",
  labelLimit: "main",
  labelLineHeight: "main",
  labelOffset: "main",
  labelOpacity: "main",
  labelOverlap: "main",
  labelPadding: "main",
  labels: "main",
  labelSeparation: "main",
  maxExtent: "main",
  minExtent: "main",
  offset: "both",
  position: "main",
  tickCap: "main",
  tickColor: "main",
  tickDash: "main",
  tickDashOffset: "main",
  tickMinStep: "both",
  tickOffset: "both",
  tickOpacity: "main",
  tickRound: "both",
  ticks: "main",
  tickSize: "main",
  tickWidth: "both",
  title: "main",
  titleAlign: "main",
  titleAnchor: "main",
  titleAngle: "main",
  titleBaseline: "main",
  titleColor: "main",
  titleFont: "main",
  titleFontSize: "main",
  titleFontStyle: "main",
  titleFontWeight: "main",
  titleLimit: "main",
  titleLineHeight: "main",
  titleOpacity: "main",
  titlePadding: "main",
  titleX: "main",
  titleY: "main",
  encode: "both",
  scale: "both",
  tickBand: "both",
  tickCount: "both",
  tickExtra: "both",
  translate: "both",
  values: "both",
  zindex: "both"
  // this is actually set afterward, so it doesn't matter
}, pL = {
  orient: 1,
  aria: 1,
  bandPosition: 1,
  description: 1,
  domain: 1,
  domainCap: 1,
  domainColor: 1,
  domainDash: 1,
  domainDashOffset: 1,
  domainOpacity: 1,
  domainWidth: 1,
  format: 1,
  formatType: 1,
  grid: 1,
  gridCap: 1,
  gridColor: 1,
  gridDash: 1,
  gridDashOffset: 1,
  gridOpacity: 1,
  gridWidth: 1,
  labelAlign: 1,
  labelAngle: 1,
  labelBaseline: 1,
  labelBound: 1,
  labelColor: 1,
  labelFlush: 1,
  labelFlushOffset: 1,
  labelFont: 1,
  labelFontSize: 1,
  labelFontStyle: 1,
  labelFontWeight: 1,
  labelLimit: 1,
  labelLineHeight: 1,
  labelOffset: 1,
  labelOpacity: 1,
  labelOverlap: 1,
  labelPadding: 1,
  labels: 1,
  labelSeparation: 1,
  maxExtent: 1,
  minExtent: 1,
  offset: 1,
  position: 1,
  tickBand: 1,
  tickCap: 1,
  tickColor: 1,
  tickCount: 1,
  tickDash: 1,
  tickDashOffset: 1,
  tickExtra: 1,
  tickMinStep: 1,
  tickOffset: 1,
  tickOpacity: 1,
  tickRound: 1,
  ticks: 1,
  tickSize: 1,
  tickWidth: 1,
  title: 1,
  titleAlign: 1,
  titleAnchor: 1,
  titleAngle: 1,
  titleBaseline: 1,
  titleColor: 1,
  titleFont: 1,
  titleFontSize: 1,
  titleFontStyle: 1,
  titleFontWeight: 1,
  titleLimit: 1,
  titleLineHeight: 1,
  titleOpacity: 1,
  titlePadding: 1,
  titleX: 1,
  titleY: 1,
  translate: 1,
  values: 1,
  zindex: 1
}, Sle = {
  ...pL,
  style: 1,
  labelExpr: 1,
  encoding: 1
};
function V$(e) {
  return !!Sle[e];
}
const kle = {
  axis: 1,
  axisBand: 1,
  axisBottom: 1,
  axisDiscrete: 1,
  axisLeft: 1,
  axisPoint: 1,
  axisQuantitative: 1,
  axisRight: 1,
  axisTemporal: 1,
  axisTop: 1,
  axisX: 1,
  axisXBand: 1,
  axisXDiscrete: 1,
  axisXPoint: 1,
  axisXQuantitative: 1,
  axisXTemporal: 1,
  axisY: 1,
  axisYBand: 1,
  axisYDiscrete: 1,
  axisYPoint: 1,
  axisYQuantitative: 1,
  axisYTemporal: 1
}, mL = q(kle);
function Ps(e) {
  return "mark" in e;
}
class _0 {
  constructor(t, n) {
    this.name = t, this.run = n;
  }
  hasMatchingType(t) {
    return Ps(t) ? ele(t.mark) === this.name : !1;
  }
}
function ka(e, t) {
  const n = e && e[t];
  return n ? U(n) ? Ba(n, (i) => !!i.field) : H(n) || v0(n) : !1;
}
function yL(e, t) {
  const n = e && e[t];
  return n ? U(n) ? Ba(n, (i) => !!i.field) : H(n) || Yr(n) || Pd(n) : !1;
}
function bL(e, t) {
  if (ht(t)) {
    const n = e[t];
    if ((H(n) || Yr(n)) && (z4(n.type) || H(n) && n.timeUnit)) {
      const i = K_(t);
      return yL(e, i);
    }
  }
  return !1;
}
function $E(e) {
  return Ba(Cse, (t) => {
    if (ka(e, t)) {
      const n = e[t];
      if (U(n))
        return Ba(n, (i) => !!i.aggregate);
      {
        const i = Rr(n);
        return i && !!i.aggregate;
      }
    }
    return !1;
  });
}
function vL(e, t) {
  const n = [], i = [], r = [], s = [], o = {};
  return ME(e, (a, l) => {
    if (H(a)) {
      const { field: u, aggregate: c, bin: f, timeUnit: d, ...h } = a;
      if (c || d || f) {
        const g = kE(a), p = g == null ? void 0 : g.title;
        let m = J(a, { forAs: !0 });
        const y = {
          // Only add title if it doesn't exist
          ...p ? [] : { title: Yl(a, t, { allowDisabling: !0 }) },
          ...h,
          // Always overwrite field
          field: m
        };
        if (c) {
          let b;
          if (qo(c) ? (b = "argmax", m = J({ op: "argmax", field: c.argmax }, { forAs: !0 }), y.field = `${m}.${u}`) : Ss(c) ? (b = "argmin", m = J({ op: "argmin", field: c.argmin }, { forAs: !0 }), y.field = `${m}.${u}`) : c !== "boxplot" && c !== "errorbar" && c !== "errorband" && (b = c), b) {
            const v = {
              op: b,
              as: m
            };
            u && (v.field = u), s.push(v);
          }
        } else if (n.push(m), En(a) && Je(f)) {
          if (i.push({ bin: f, field: u, as: m }), n.push(J(a, { binSuffix: "end" })), Id(a, l) && n.push(J(a, { binSuffix: "range" })), ht(l)) {
            const b = {
              field: `${m}_end`
            };
            o[`${l}2`] = b;
          }
          y.bin = "binned", s4(l) || (y.type = Wa);
        } else if (d && !fl(d)) {
          r.push({
            timeUnit: d,
            field: u,
            as: m
          });
          const b = En(a) && a.type !== Eu && "time";
          b && (l === Fd || l === Ua ? y.formatType = b : Pse(l) ? y.legend = {
            formatType: b,
            ...y.legend
          } : ht(l) && (y.axis = {
            formatType: b,
            ...y.axis
          }));
        }
        o[l] = y;
      } else
        n.push(u), o[l] = e[l];
    } else
      o[l] = e[l];
  }), {
    bins: i,
    timeUnits: r,
    aggregate: s,
    groupby: n,
    encoding: o
  };
}
function Ale(e, t, n) {
  const i = zse(t, n);
  if (i) {
    if (i === "binned") {
      const r = e[t === sr ? nt : Pt];
      return !!(H(r) && H(e[t]) && Bt(r.bin));
    }
  } else
    return !1;
  return !0;
}
function Cle(e, t, n, i) {
  const r = {};
  for (const s of q(e))
    r4(s) || G(koe(s));
  for (let s of Nse) {
    if (!e[s])
      continue;
    const o = e[s];
    if (Od(s)) {
      const a = Ose(s), l = r[a];
      if (H(l) && Sae(l.type) && H(o) && !l.timeUnit) {
        G(voe(a));
        continue;
      }
    }
    if (s === "angle" && t === "arc" && !e.theta && (G(boe), s = Fi), !Ale(e, s, t)) {
      G(c0(s, t));
      continue;
    }
    if (s === Ds && t === "line") {
      const a = Rr(e[s]);
      if (a != null && a.aggregate) {
        G(Soe);
        continue;
      }
    }
    if (s === jn && (n ? "fill" in e : "stroke" in e)) {
      G(E4("encoding", { fill: "fill" in e, stroke: "stroke" in e }));
      continue;
    }
    if (s === Td || s === wu && !U(o) && !er(o) || s === Ua && U(o)) {
      if (o) {
        if (s === wu) {
          const a = e[s];
          if (oL(a)) {
            r[s] = a;
            continue;
          }
        }
        r[s] = ee(o).reduce((a, l) => (H(l) ? a.push(CE(l, s)) : G(hv(l, s)), a), []);
      }
    } else {
      if (s === Ua && o === null)
        r[s] = null;
      else if (!H(o) && !Yr(o) && !er(o) && !b0(o) && !oe(o)) {
        G(hv(o, s));
        continue;
      }
      r[s] = dL(o, s, i);
    }
  }
  return r;
}
function E0(e, t) {
  const n = {};
  for (const i of q(e)) {
    const r = dL(e[i], i, t, { compositeMark: !0 });
    n[i] = r;
  }
  return n;
}
function $le(e) {
  const t = [];
  for (const n of q(e))
    if (ka(e, n)) {
      const i = e[n], r = ee(i);
      for (const s of r)
        H(s) ? t.push(s) : v0(s) && t.push(s.condition);
    }
  return t;
}
function ME(e, t, n) {
  if (e)
    for (const i of q(e)) {
      const r = e[i];
      if (U(r))
        for (const s of r)
          t.call(n, s, i);
      else
        t.call(n, r, i);
    }
}
function Mle(e, t, n, i) {
  return e ? q(e).reduce((r, s) => {
    const o = e[s];
    return U(o) ? o.reduce((a, l) => t.call(i, a, l, s), r) : t.call(i, r, o, s);
  }, n) : n;
}
function xL(e, t) {
  return q(t).reduce((n, i) => {
    switch (i) {
      case nt:
      case Pt:
      case r0:
      case o0:
      case s0:
      case sr:
      case qr:
      case Io:
      case Ku:
      case Fi:
      case Ns:
      case or:
      case Os:
      case ar:
      case lr:
      case ur:
      case $i:
      case Fd:
      case Un:
      case al:
      case Ua:
        return n;
      case wu:
        if (e === "line" || e === "trail")
          return n;
      case Td:
      case i0: {
        const r = t[i];
        if (U(r) || H(r))
          for (const s of ee(r))
            s.aggregate || n.push(J(s, {}));
        return n;
      }
      case Ds:
        if (e === "trail")
          return n;
      case jn:
      case Wr:
      case Hr:
      case Rs:
      case zo:
      case Bo:
      case Uo:
      case jo: {
        const r = Rr(t[i]);
        return r && !r.aggregate && n.push(J(r, {})), n;
      }
    }
  }, []);
}
function Fle(e) {
  const { tooltip: t, ...n } = e;
  if (!t)
    return { filteredEncoding: n };
  let i, r;
  if (U(t)) {
    for (const s of t)
      s.aggregate ? (i || (i = []), i.push(s)) : (r || (r = []), r.push(s));
    i && (n.tooltip = i);
  } else
    t.aggregate ? n.tooltip = t : r = t;
  return U(r) && r.length === 1 && (r = r[0]), { customTooltipWithoutAggregatedField: r, filteredEncoding: n };
}
function yv(e, t, n, i = !0) {
  if ("tooltip" in n)
    return { tooltip: n.tooltip };
  const r = e.map(({ fieldPrefix: o, titlePrefix: a }) => {
    const l = i ? ` of ${FE(t)}` : "";
    return {
      field: o + t.field,
      type: t.type,
      title: oe(a) ? { signal: `${a}"${escape(l)}"` } : a + l
    };
  }), s = $le(n).map(dle);
  return {
    tooltip: [
      ...r,
      // need to cast because TextFieldDef supports fewer types of bin
      ...xr(s, $e)
    ]
  };
}
function FE(e) {
  const { title: t, field: n } = e;
  return dt(t, n);
}
function TE(e, t, n, i, r) {
  const { scale: s, axis: o } = n;
  return ({ partName: a, mark: l, positionPrefix: u, endPositionPrefix: c = void 0, extraEncoding: f = {} }) => {
    const d = FE(n);
    return wL(e, a, r, {
      mark: l,
      encoding: {
        [t]: {
          field: `${u}_${n.field}`,
          type: n.type,
          ...d !== void 0 ? { title: d } : {},
          ...s !== void 0 ? { scale: s } : {},
          ...o !== void 0 ? { axis: o } : {}
        },
        ...te(c) ? {
          [`${t}2`]: {
            field: `${c}_${n.field}`
          }
        } : {},
        ...i,
        ...f
      }
    });
  };
}
function wL(e, t, n, i) {
  const { clip: r, color: s, opacity: o } = e, a = e.type;
  return e[t] || e[t] === void 0 && n[t] ? [
    {
      ...i,
      mark: {
        ...n[t],
        ...r ? { clip: r } : {},
        ...s ? { color: s } : {},
        ...o ? { opacity: o } : {},
        ...Dr(i.mark) ? i.mark : { type: i.mark },
        style: `${a}-${String(t)}`,
        ...To(e[t]) ? {} : e[t]
      }
    }
  ] : [];
}
function _L(e, t, n) {
  const { encoding: i } = e, r = t === "vertical" ? "y" : "x", s = i[r], o = i[`${r}2`], a = i[`${r}Error`], l = i[`${r}Error2`];
  return {
    continuousAxisChannelDef: vh(s, n),
    continuousAxisChannelDef2: vh(o, n),
    continuousAxisChannelDefError: vh(a, n),
    continuousAxisChannelDefError2: vh(l, n),
    continuousAxis: r
  };
}
function vh(e, t) {
  if (e != null && e.aggregate) {
    const { aggregate: n, ...i } = e;
    return n !== t && G(Zoe(n, t)), i;
  } else
    return e;
}
function EL(e, t) {
  const { mark: n, encoding: i } = e, { x: r, y: s } = i;
  if (Dr(n) && n.orient)
    return n.orient;
  if (ro(r)) {
    if (ro(s)) {
      const o = H(r) && r.aggregate, a = H(s) && s.aggregate;
      if (!o && a === t)
        return "vertical";
      if (!a && o === t)
        return "horizontal";
      if (o === t && a === t)
        throw new Error("Both x and y cannot have aggregate");
      return Cu(s) && !Cu(r) ? "horizontal" : "vertical";
    }
    return "horizontal";
  } else {
    if (ro(s))
      return "vertical";
    throw new Error(`Need a valid continuous axis for ${t}s`);
  }
}
const Mp = "boxplot", Tle = ["box", "median", "outliers", "rule", "ticks"], Ole = new _0(Mp, kL);
function SL(e) {
  return Re(e) ? "tukey" : e;
}
function kL(e, { config: t }) {
  e = {
    ...e,
    encoding: E0(e.encoding, t)
  };
  const { mark: n, encoding: i, params: r, projection: s, ...o } = e, a = Dr(n) ? n : { type: n };
  r && G(w4("boxplot"));
  const l = a.extent ?? t.boxplot.extent, u = qe(
    "size",
    a,
    // TODO: https://github.com/vega/vega-lite/issues/6245
    t
  ), c = a.invalid, f = SL(l), { bins: d, timeUnits: h, transform: g, continuousAxisChannelDef: p, continuousAxis: m, groupby: y, aggregate: b, encodingWithoutContinuousAxis: v, ticksOrient: _, boxOrient: x, customTooltipWithoutAggregatedField: S } = Nle(e, l, t), { color: E, size: C, ...$ } = v, N = (It) => TE(a, m, p, It, t.boxplot), O = N($), P = N(v), T = N({ ...$, ...C ? { size: C } : {} }), D = yv([
    { fieldPrefix: f === "min-max" ? "upper_whisker_" : "max_", titlePrefix: "Max" },
    { fieldPrefix: "upper_box_", titlePrefix: "Q3" },
    { fieldPrefix: "mid_box_", titlePrefix: "Median" },
    { fieldPrefix: "lower_box_", titlePrefix: "Q1" },
    { fieldPrefix: f === "min-max" ? "lower_whisker_" : "min_", titlePrefix: "Min" }
  ], p, v), M = { type: "tick", color: "black", opacity: 1, orient: _, invalid: c, aria: !1 }, w = f === "min-max" ? D : (
    // for tukey / k-IQR, just show upper/lower-whisker
    yv([
      { fieldPrefix: "upper_whisker_", titlePrefix: "Upper Whisker" },
      { fieldPrefix: "lower_whisker_", titlePrefix: "Lower Whisker" }
    ], p, v)
  ), k = [
    ...O({
      partName: "rule",
      mark: { type: "rule", invalid: c, aria: !1 },
      positionPrefix: "lower_whisker",
      endPositionPrefix: "lower_box",
      extraEncoding: w
    }),
    ...O({
      partName: "rule",
      mark: { type: "rule", invalid: c, aria: !1 },
      positionPrefix: "upper_box",
      endPositionPrefix: "upper_whisker",
      extraEncoding: w
    }),
    ...O({
      partName: "ticks",
      mark: M,
      positionPrefix: "lower_whisker",
      extraEncoding: w
    }),
    ...O({
      partName: "ticks",
      mark: M,
      positionPrefix: "upper_whisker",
      extraEncoding: w
    })
  ], A = [
    ...f !== "tukey" ? k : [],
    ...P({
      partName: "box",
      mark: {
        type: "bar",
        ...u ? { size: u } : {},
        orient: x,
        invalid: c,
        ariaRoleDescription: "box"
      },
      positionPrefix: "lower_box",
      endPositionPrefix: "upper_box",
      extraEncoding: D
    }),
    ...T({
      partName: "median",
      mark: {
        type: "tick",
        invalid: c,
        ...ne(t.boxplot.median) && t.boxplot.median.color ? { color: t.boxplot.median.color } : {},
        ...u ? { size: u } : {},
        orient: _,
        aria: !1
      },
      positionPrefix: "mid_box",
      extraEncoding: D
    })
  ];
  if (f === "min-max")
    return {
      ...o,
      transform: (o.transform ?? []).concat(g),
      layer: A
    };
  const F = `datum["lower_box_${p.field}"]`, R = `datum["upper_box_${p.field}"]`, L = `(${R} - ${F})`, V = `${F} - ${l} * ${L}`, K = `${R} + ${l} * ${L}`, Q = `datum["${p.field}"]`, ie = {
    joinaggregate: AL(p.field),
    groupby: y
  }, Le = {
    transform: [
      {
        filter: `(${V} <= ${Q}) && (${Q} <= ${K})`
      },
      {
        aggregate: [
          {
            op: "min",
            field: p.field,
            as: `lower_whisker_${p.field}`
          },
          {
            op: "max",
            field: p.field,
            as: `upper_whisker_${p.field}`
          },
          // preserve lower_box / upper_box
          {
            op: "min",
            field: `lower_box_${p.field}`,
            as: `lower_box_${p.field}`
          },
          {
            op: "max",
            field: `upper_box_${p.field}`,
            as: `upper_box_${p.field}`
          },
          ...b
        ],
        groupby: y
      }
    ],
    layer: k
  }, { tooltip: Oe, ...mt } = $, { scale: Z, axis: ye } = p, xe = FE(p), W = Nn(ye, ["title"]), yt = wL(a, "outliers", t.boxplot, {
    transform: [{ filter: `(${Q} < ${V}) || (${Q} > ${K})` }],
    mark: "point",
    encoding: {
      [m]: {
        field: p.field,
        type: p.type,
        ...xe !== void 0 ? { title: xe } : {},
        ...Z !== void 0 ? { scale: Z } : {},
        // add axis without title since we already added the title above
        ...Ge(W) ? {} : { axis: W }
      },
      ...mt,
      ...E ? { color: E } : {},
      ...S ? { tooltip: S } : {}
    }
  })[0];
  let De;
  const kt = [...d, ...h, ie];
  return yt ? De = {
    transform: kt,
    layer: [yt, Le]
  } : (De = Le, De.transform.unshift(...kt)), {
    ...o,
    layer: [
      De,
      {
        // boxplot
        transform: g,
        layer: A
      }
    ]
  };
}
function AL(e) {
  return [
    {
      op: "q1",
      field: e,
      as: `lower_box_${e}`
    },
    {
      op: "q3",
      field: e,
      as: `upper_box_${e}`
    }
  ];
}
function Nle(e, t, n) {
  const i = EL(e, Mp), { continuousAxisChannelDef: r, continuousAxis: s } = _L(e, i, Mp), o = r.field, a = SL(t), l = [
    ...AL(o),
    {
      op: "median",
      field: o,
      as: `mid_box_${o}`
    },
    {
      op: "min",
      field: o,
      as: (a === "min-max" ? "lower_whisker_" : "min_") + o
    },
    {
      op: "max",
      field: o,
      as: (a === "min-max" ? "upper_whisker_" : "max_") + o
    }
  ], u = a === "min-max" || a === "tukey" ? [] : [
    // This is for the  original k-IQR, which we do not expose
    {
      calculate: `datum["upper_box_${o}"] - datum["lower_box_${o}"]`,
      as: `iqr_${o}`
    },
    {
      calculate: `min(datum["upper_box_${o}"] + datum["iqr_${o}"] * ${t}, datum["max_${o}"])`,
      as: `upper_whisker_${o}`
    },
    {
      calculate: `max(datum["lower_box_${o}"] - datum["iqr_${o}"] * ${t}, datum["min_${o}"])`,
      as: `lower_whisker_${o}`
    }
  ], { [s]: c, ...f } = e.encoding, { customTooltipWithoutAggregatedField: d, filteredEncoding: h } = Fle(f), { bins: g, timeUnits: p, aggregate: m, groupby: y, encoding: b } = vL(h, n), v = i === "vertical" ? "horizontal" : "vertical", _ = i, x = [
    ...g,
    ...p,
    {
      aggregate: [...m, ...l],
      groupby: y
    },
    ...u
  ];
  return {
    bins: g,
    timeUnits: p,
    transform: x,
    groupby: y,
    aggregate: m,
    continuousAxisChannelDef: r,
    continuousAxis: s,
    encodingWithoutContinuousAxis: b,
    ticksOrient: v,
    boxOrient: _,
    customTooltipWithoutAggregatedField: d
  };
}
const OE = "errorbar", Dle = ["ticks", "rule"], Rle = new _0(OE, CL);
function CL(e, { config: t }) {
  e = {
    ...e,
    encoding: E0(e.encoding, t)
  };
  const { transform: n, continuousAxisChannelDef: i, continuousAxis: r, encodingWithoutContinuousAxis: s, ticksOrient: o, markDef: a, outerSpec: l, tooltipEncoding: u } = $L(e, OE, t);
  delete s.size;
  const c = TE(a, r, i, s, t.errorbar), f = a.thickness, d = a.size, h = {
    type: "tick",
    orient: o,
    aria: !1,
    ...f !== void 0 ? { thickness: f } : {},
    ...d !== void 0 ? { size: d } : {}
  }, g = [
    ...c({
      partName: "ticks",
      mark: h,
      positionPrefix: "lower",
      extraEncoding: u
    }),
    ...c({
      partName: "ticks",
      mark: h,
      positionPrefix: "upper",
      extraEncoding: u
    }),
    ...c({
      partName: "rule",
      mark: {
        type: "rule",
        ariaRoleDescription: "errorbar",
        ...f !== void 0 ? { size: f } : {}
      },
      positionPrefix: "lower",
      endPositionPrefix: "upper",
      extraEncoding: u
    })
  ];
  return {
    ...l,
    transform: n,
    ...g.length > 1 ? { layer: g } : { ...g[0] }
  };
}
function Lle(e, t) {
  const { encoding: n } = e;
  if (Ple(n))
    return {
      orient: EL(e, t),
      inputType: "raw"
    };
  const i = Ile(n), r = zle(n), s = n.x, o = n.y;
  if (i) {
    if (r)
      throw new Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);
    const a = n.x2, l = n.y2;
    if (be(a) && be(l))
      throw new Error(`${t} cannot have both x2 and y2`);
    if (be(a)) {
      if (ro(s))
        return { orient: "horizontal", inputType: "aggregated-upper-lower" };
      throw new Error(`Both x and x2 have to be quantitative in ${t}`);
    } else if (be(l)) {
      if (ro(o))
        return { orient: "vertical", inputType: "aggregated-upper-lower" };
      throw new Error(`Both y and y2 have to be quantitative in ${t}`);
    }
    throw new Error("No ranged axis");
  } else {
    const a = n.xError, l = n.xError2, u = n.yError, c = n.yError2;
    if (be(l) && !be(a))
      throw new Error(`${t} cannot have xError2 without xError`);
    if (be(c) && !be(u))
      throw new Error(`${t} cannot have yError2 without yError`);
    if (be(a) && be(u))
      throw new Error(`${t} cannot have both xError and yError with both are quantiative`);
    if (be(a)) {
      if (ro(s))
        return { orient: "horizontal", inputType: "aggregated-error" };
      throw new Error("All x, xError, and xError2 (if exist) have to be quantitative");
    } else if (be(u)) {
      if (ro(o))
        return { orient: "vertical", inputType: "aggregated-error" };
      throw new Error("All y, yError, and yError2 (if exist) have to be quantitative");
    }
    throw new Error("No ranged axis");
  }
}
function Ple(e) {
  return (be(e.x) || be(e.y)) && !be(e.x2) && !be(e.y2) && !be(e.xError) && !be(e.xError2) && !be(e.yError) && !be(e.yError2);
}
function Ile(e) {
  return be(e.x2) || be(e.y2);
}
function zle(e) {
  return be(e.xError) || be(e.xError2) || be(e.yError) || be(e.yError2);
}
function $L(e, t, n) {
  const { mark: i, encoding: r, params: s, projection: o, ...a } = e, l = Dr(i) ? i : { type: i };
  s && G(w4(t));
  const { orient: u, inputType: c } = Lle(e, t), { continuousAxisChannelDef: f, continuousAxisChannelDef2: d, continuousAxisChannelDefError: h, continuousAxisChannelDefError2: g, continuousAxis: p } = _L(e, u, t), { errorBarSpecificAggregate: m, postAggregateCalculates: y, tooltipSummary: b, tooltipTitleWithFieldName: v } = Ble(l, f, d, h, g, c, t, n), { [p]: _, [p === "x" ? "x2" : "y2"]: x, [p === "x" ? "xError" : "yError"]: S, [p === "x" ? "xError2" : "yError2"]: E, ...C } = r, { bins: $, timeUnits: N, aggregate: O, groupby: P, encoding: T } = vL(C, n), D = [...O, ...m], M = c !== "raw" ? [] : P, w = yv(b, f, T, v);
  return {
    transform: [
      ...a.transform ?? [],
      ...$,
      ...N,
      ...D.length === 0 ? [] : [{ aggregate: D, groupby: M }],
      ...y
    ],
    groupby: M,
    continuousAxisChannelDef: f,
    continuousAxis: p,
    encodingWithoutContinuousAxis: T,
    ticksOrient: u === "vertical" ? "horizontal" : "vertical",
    markDef: l,
    outerSpec: a,
    tooltipEncoding: w
  };
}
function Ble(e, t, n, i, r, s, o, a) {
  let l = [], u = [];
  const c = t.field;
  let f, d = !1;
  if (s === "raw") {
    const h = e.center ? e.center : e.extent ? e.extent === "iqr" ? "median" : "mean" : a.errorbar.center, g = e.extent ? e.extent : h === "mean" ? "stderr" : "iqr";
    if (h === "median" != (g === "iqr") && G(Qoe(h, g, o)), g === "stderr" || g === "stdev")
      l = [
        { op: g, field: c, as: `extent_${c}` },
        { op: h, field: c, as: `center_${c}` }
      ], u = [
        {
          calculate: `datum["center_${c}"] + datum["extent_${c}"]`,
          as: `upper_${c}`
        },
        {
          calculate: `datum["center_${c}"] - datum["extent_${c}"]`,
          as: `lower_${c}`
        }
      ], f = [
        { fieldPrefix: "center_", titlePrefix: Md(h) },
        { fieldPrefix: "upper_", titlePrefix: Y$(h, g, "+") },
        { fieldPrefix: "lower_", titlePrefix: Y$(h, g, "-") }
      ], d = !0;
    else {
      let p, m, y;
      g === "ci" ? (p = "mean", m = "ci0", y = "ci1") : (p = "median", m = "q1", y = "q3"), l = [
        { op: m, field: c, as: `lower_${c}` },
        { op: y, field: c, as: `upper_${c}` },
        { op: p, field: c, as: `center_${c}` }
      ], f = [
        {
          fieldPrefix: "upper_",
          titlePrefix: Yl({ field: c, aggregate: y, type: "quantitative" }, a, {
            allowDisabling: !1
          })
        },
        {
          fieldPrefix: "lower_",
          titlePrefix: Yl({ field: c, aggregate: m, type: "quantitative" }, a, {
            allowDisabling: !1
          })
        },
        {
          fieldPrefix: "center_",
          titlePrefix: Yl({ field: c, aggregate: p, type: "quantitative" }, a, {
            allowDisabling: !1
          })
        }
      ];
    }
  } else {
    (e.center || e.extent) && G(Joe(e.center, e.extent)), s === "aggregated-upper-lower" ? (f = [], u = [
      { calculate: `datum["${n.field}"]`, as: `upper_${c}` },
      { calculate: `datum["${c}"]`, as: `lower_${c}` }
    ]) : s === "aggregated-error" && (f = [{ fieldPrefix: "", titlePrefix: c }], u = [
      {
        calculate: `datum["${c}"] + datum["${i.field}"]`,
        as: `upper_${c}`
      }
    ], r ? u.push({
      calculate: `datum["${c}"] + datum["${r.field}"]`,
      as: `lower_${c}`
    }) : u.push({
      calculate: `datum["${c}"] - datum["${i.field}"]`,
      as: `lower_${c}`
    }));
    for (const h of u)
      f.push({
        fieldPrefix: h.as.substring(0, 6),
        titlePrefix: ja(ja(h.calculate, 'datum["', ""), '"]', "")
      });
  }
  return { postAggregateCalculates: u, errorBarSpecificAggregate: l, tooltipSummary: f, tooltipTitleWithFieldName: d };
}
function Y$(e, t, n) {
  return `${Md(e)} ${n} ${t}`;
}
const NE = "errorband", jle = ["band", "borders"], Ule = new _0(NE, ML);
function ML(e, { config: t }) {
  e = {
    ...e,
    encoding: E0(e.encoding, t)
  };
  const { transform: n, continuousAxisChannelDef: i, continuousAxis: r, encodingWithoutContinuousAxis: s, markDef: o, outerSpec: a, tooltipEncoding: l } = $L(e, NE, t), u = o, c = TE(u, r, i, s, t.errorband), f = e.encoding.x !== void 0 && e.encoding.y !== void 0;
  let d = { type: f ? "area" : "rect" }, h = { type: f ? "line" : "rule" };
  const g = {
    ...u.interpolate ? { interpolate: u.interpolate } : {},
    ...u.tension && u.interpolate ? { tension: u.tension } : {}
  };
  return f ? (d = {
    ...d,
    ...g,
    ariaRoleDescription: "errorband"
  }, h = {
    ...h,
    ...g,
    aria: !1
  }) : u.interpolate ? G(z$("interpolate")) : u.tension && G(z$("tension")), {
    ...a,
    transform: n,
    layer: [
      ...c({
        partName: "band",
        mark: d,
        positionPrefix: "lower",
        endPositionPrefix: "upper",
        extraEncoding: l
      }),
      ...c({
        partName: "borders",
        mark: h,
        positionPrefix: "lower",
        extraEncoding: l
      }),
      ...c({
        partName: "borders",
        mark: h,
        positionPrefix: "upper",
        extraEncoding: l
      })
    ]
  };
}
const FL = {};
function DE(e, t, n) {
  const i = new _0(e, t);
  FL[e] = { normalizer: i, parts: n };
}
function qle() {
  return q(FL);
}
DE(Mp, kL, Tle);
DE(OE, CL, Dle);
DE(NE, ML, jle);
const Wle = [
  "gradientHorizontalMaxLength",
  "gradientHorizontalMinLength",
  "gradientVerticalMaxLength",
  "gradientVerticalMinLength",
  "unselectedOpacity"
], TL = {
  titleAlign: "align",
  titleAnchor: "anchor",
  titleAngle: "angle",
  titleBaseline: "baseline",
  titleColor: "color",
  titleFont: "font",
  titleFontSize: "fontSize",
  titleFontStyle: "fontStyle",
  titleFontWeight: "fontWeight",
  titleLimit: "limit",
  titleLineHeight: "lineHeight",
  titleOrient: "orient",
  titlePadding: "offset"
}, OL = {
  labelAlign: "align",
  labelAnchor: "anchor",
  labelAngle: "angle",
  labelBaseline: "baseline",
  labelColor: "color",
  labelFont: "font",
  labelFontSize: "fontSize",
  labelFontStyle: "fontStyle",
  labelFontWeight: "fontWeight",
  labelLimit: "limit",
  labelLineHeight: "lineHeight",
  labelOrient: "orient",
  labelPadding: "offset"
}, Hle = q(TL), Gle = q(OL), Vle = {
  header: 1,
  headerRow: 1,
  headerColumn: 1,
  headerFacet: 1
}, NL = q(Vle), DL = [
  "size",
  "shape",
  "fill",
  "stroke",
  "strokeDash",
  "strokeWidth",
  "opacity"
], Yle = {
  gradientHorizontalMaxLength: 200,
  gradientHorizontalMinLength: 100,
  gradientVerticalMaxLength: 200,
  gradientVerticalMinLength: 64,
  unselectedOpacity: 0.35
}, Xle = {
  aria: 1,
  clipHeight: 1,
  columnPadding: 1,
  columns: 1,
  cornerRadius: 1,
  description: 1,
  direction: 1,
  fillColor: 1,
  format: 1,
  formatType: 1,
  gradientLength: 1,
  gradientOpacity: 1,
  gradientStrokeColor: 1,
  gradientStrokeWidth: 1,
  gradientThickness: 1,
  gridAlign: 1,
  labelAlign: 1,
  labelBaseline: 1,
  labelColor: 1,
  labelFont: 1,
  labelFontSize: 1,
  labelFontStyle: 1,
  labelFontWeight: 1,
  labelLimit: 1,
  labelOffset: 1,
  labelOpacity: 1,
  labelOverlap: 1,
  labelPadding: 1,
  labelSeparation: 1,
  legendX: 1,
  legendY: 1,
  offset: 1,
  orient: 1,
  padding: 1,
  rowPadding: 1,
  strokeColor: 1,
  symbolDash: 1,
  symbolDashOffset: 1,
  symbolFillColor: 1,
  symbolLimit: 1,
  symbolOffset: 1,
  symbolOpacity: 1,
  symbolSize: 1,
  symbolStrokeColor: 1,
  symbolStrokeWidth: 1,
  symbolType: 1,
  tickCount: 1,
  tickMinStep: 1,
  title: 1,
  titleAlign: 1,
  titleAnchor: 1,
  titleBaseline: 1,
  titleColor: 1,
  titleFont: 1,
  titleFontSize: 1,
  titleFontStyle: 1,
  titleFontWeight: 1,
  titleLimit: 1,
  titleLineHeight: 1,
  titleOpacity: 1,
  titleOrient: 1,
  titlePadding: 1,
  type: 1,
  values: 1,
  zindex: 1
}, tr = "_vgsid_", Kle = {
  point: {
    on: "click",
    fields: [tr],
    toggle: "event.shiftKey",
    resolve: "global",
    clear: "dblclick"
  },
  interval: {
    on: "[pointerdown, window:pointerup] > window:pointermove!",
    encodings: ["x", "y"],
    translate: "[pointerdown, window:pointerup] > window:pointermove!",
    zoom: "wheel!",
    mark: { fill: "#333", fillOpacity: 0.125, stroke: "white" },
    resolve: "global",
    clear: "dblclick"
  }
};
function RE(e) {
  return e === "legend" || !!(e != null && e.legend);
}
function ty(e) {
  return RE(e) && ne(e);
}
function LE(e) {
  return !!(e != null && e.select);
}
function RL(e) {
  const t = [];
  for (const n of e || []) {
    if (LE(n))
      continue;
    const { expr: i, bind: r, ...s } = n;
    if (r && i) {
      const o = {
        ...s,
        bind: r,
        init: i
      };
      t.push(o);
    } else {
      const o = {
        ...s,
        ...i ? { update: i } : {},
        ...r ? { bind: r } : {}
      };
      t.push(o);
    }
  }
  return t;
}
function Jle(e) {
  return S0(e) || IE(e) || PE(e);
}
function PE(e) {
  return "concat" in e;
}
function S0(e) {
  return "vconcat" in e;
}
function IE(e) {
  return "hconcat" in e;
}
function LL({ step: e, offsetIsDiscrete: t }) {
  return t ? e.for ?? "offset" : "position";
}
function Lr(e) {
  return ne(e) && e.step !== void 0;
}
function X$(e) {
  return e.view || e.width || e.height;
}
const K$ = 20, Qle = {
  align: 1,
  bounds: 1,
  center: 1,
  columns: 1,
  spacing: 1
}, Zle = q(Qle);
function eue(e, t, n) {
  const i = n[t], r = {}, { spacing: s, columns: o } = i;
  s !== void 0 && (r.spacing = s), o !== void 0 && (y0(e) && !Ld(e.facet) || PE(e)) && (r.columns = o), S0(e) && (r.columns = 1);
  for (const a of Zle)
    if (e[a] !== void 0)
      if (a === "spacing") {
        const l = e[a];
        r[a] = Re(l) ? l : {
          row: l.row ?? s,
          column: l.column ?? s
        };
      } else
        r[a] = e[a];
  return r;
}
function bv(e, t) {
  return e[t] ?? e[t === "width" ? "continuousWidth" : "continuousHeight"];
}
function Fp(e, t) {
  const n = Tp(e, t);
  return Lr(n) ? n.step : PL;
}
function Tp(e, t) {
  const n = e[t] ?? e[t === "width" ? "discreteWidth" : "discreteHeight"];
  return dt(n, { step: e.step });
}
const PL = 20, tue = {
  continuousWidth: 200,
  continuousHeight: 200,
  step: PL
}, nue = {
  background: "white",
  padding: 5,
  timeFormat: "%b %d, %Y",
  countTitle: "Count of Records",
  view: tue,
  mark: Yae,
  arc: {},
  area: {},
  bar: Jae,
  circle: {},
  geoshape: {},
  image: {},
  line: {},
  point: {},
  rect: Qae,
  rule: { color: "black" },
  square: {},
  text: { color: "black" },
  tick: Zae,
  trail: {},
  boxplot: {
    size: 14,
    extent: 1.5,
    box: {},
    median: { color: "white" },
    outliers: {},
    rule: {},
    ticks: null
  },
  errorbar: {
    center: "mean",
    rule: !0,
    ticks: !1
  },
  errorband: {
    band: {
      opacity: 0.3
    },
    borders: !1
  },
  scale: Fae,
  projection: {},
  legend: Yle,
  header: { titlePadding: 10, labelPadding: 10 },
  headerColumn: {},
  headerRow: {},
  headerFacet: {},
  selection: Kle,
  style: {},
  title: {},
  facet: { spacing: K$ },
  concat: { spacing: K$ },
  normalizedNumberFormat: ".0%"
}, Zr = [
  "#4c78a8",
  "#f58518",
  "#e45756",
  "#72b7b2",
  "#54a24b",
  "#eeca3b",
  "#b279a2",
  "#ff9da6",
  "#9d755d",
  "#bab0ac"
], J$ = {
  text: 11,
  guideLabel: 10,
  guideTitle: 11,
  groupTitle: 13,
  groupSubtitle: 12
}, Q$ = {
  blue: Zr[0],
  orange: Zr[1],
  red: Zr[2],
  teal: Zr[3],
  green: Zr[4],
  yellow: Zr[5],
  purple: Zr[6],
  pink: Zr[7],
  brown: Zr[8],
  gray0: "#000",
  gray1: "#111",
  gray2: "#222",
  gray3: "#333",
  gray4: "#444",
  gray5: "#555",
  gray6: "#666",
  gray7: "#777",
  gray8: "#888",
  gray9: "#999",
  gray10: "#aaa",
  gray11: "#bbb",
  gray12: "#ccc",
  gray13: "#ddd",
  gray14: "#eee",
  gray15: "#fff"
};
function iue(e = {}) {
  return {
    signals: [
      {
        name: "color",
        value: ne(e) ? { ...Q$, ...e } : Q$
      }
    ],
    mark: { color: { signal: "color.blue" } },
    rule: { color: { signal: "color.gray0" } },
    text: {
      color: { signal: "color.gray0" }
    },
    style: {
      "guide-label": {
        fill: { signal: "color.gray0" }
      },
      "guide-title": {
        fill: { signal: "color.gray0" }
      },
      "group-title": {
        fill: { signal: "color.gray0" }
      },
      "group-subtitle": {
        fill: { signal: "color.gray0" }
      },
      cell: {
        stroke: { signal: "color.gray8" }
      }
    },
    axis: {
      domainColor: { signal: "color.gray13" },
      gridColor: { signal: "color.gray8" },
      tickColor: { signal: "color.gray13" }
    },
    range: {
      category: [
        { signal: "color.blue" },
        { signal: "color.orange" },
        { signal: "color.red" },
        { signal: "color.teal" },
        { signal: "color.green" },
        { signal: "color.yellow" },
        { signal: "color.purple" },
        { signal: "color.pink" },
        { signal: "color.brown" },
        { signal: "color.grey8" }
      ]
    }
  };
}
function rue(e) {
  return {
    signals: [
      {
        name: "fontSize",
        value: ne(e) ? { ...J$, ...e } : J$
      }
    ],
    text: {
      fontSize: { signal: "fontSize.text" }
    },
    style: {
      "guide-label": {
        fontSize: { signal: "fontSize.guideLabel" }
      },
      "guide-title": {
        fontSize: { signal: "fontSize.guideTitle" }
      },
      "group-title": {
        fontSize: { signal: "fontSize.groupTitle" }
      },
      "group-subtitle": {
        fontSize: { signal: "fontSize.groupSubtitle" }
      }
    }
  };
}
function sue(e) {
  return {
    text: { font: e },
    style: {
      "guide-label": { font: e },
      "guide-title": { font: e },
      "group-title": { font: e },
      "group-subtitle": { font: e }
    }
  };
}
function IL(e) {
  const t = q(e || {}), n = {};
  for (const i of t) {
    const r = e[i];
    n[i] = zd(r) ? g4(r) : Xn(r);
  }
  return n;
}
function oue(e) {
  const t = q(e), n = {};
  for (const i of t)
    n[i] = IL(e[i]);
  return n;
}
const aue = [
  ...X4,
  ...mL,
  ...NL,
  "background",
  "padding",
  "legend",
  "lineBreak",
  "scale",
  "style",
  "title",
  "view"
];
function zL(e = {}) {
  const { color: t, font: n, fontSize: i, selection: r, ...s } = e, o = Du({}, me(nue), n ? sue(n) : {}, t ? iue(t) : {}, i ? rue(i) : {}, s || {});
  r && Ru(o, "selection", r, !0);
  const a = Nn(o, aue);
  for (const l of ["background", "lineBreak", "padding"])
    o[l] && (a[l] = Xn(o[l]));
  for (const l of X4)
    o[l] && (a[l] = Fn(o[l]));
  for (const l of mL)
    o[l] && (a[l] = IL(o[l]));
  for (const l of NL)
    o[l] && (a[l] = Fn(o[l]));
  return o.legend && (a.legend = Fn(o.legend)), o.scale && (a.scale = Fn(o.scale)), o.style && (a.style = oue(o.style)), o.title && (a.title = Fn(o.title)), o.view && (a.view = Fn(o.view)), a;
}
const lue = /* @__PURE__ */ new Set(["view", ...Uae]), uue = [
  "color",
  "fontSize",
  "background",
  "padding",
  "facet",
  "concat",
  "numberFormat",
  "numberFormatType",
  "normalizedNumberFormat",
  "normalizedNumberFormatType",
  "timeFormat",
  "countTitle",
  "header",
  "axisQuantitative",
  "axisTemporal",
  "axisDiscrete",
  "axisPoint",
  "axisXBand",
  "axisXPoint",
  "axisXDiscrete",
  "axisXQuantitative",
  "axisXTemporal",
  "axisYBand",
  "axisYPoint",
  "axisYDiscrete",
  "axisYQuantitative",
  "axisYTemporal",
  "scale",
  "selection",
  "overlay"
  // FIXME: Redesign and unhide this
], cue = {
  view: ["continuousWidth", "continuousHeight", "discreteWidth", "discreteHeight", "step"],
  ...Vae
};
function fue(e) {
  e = me(e);
  for (const t of uue)
    delete e[t];
  if (e.axis)
    for (const t in e.axis)
      zd(e.axis[t]) && delete e.axis[t];
  if (e.legend)
    for (const t of Wle)
      delete e.legend[t];
  if (e.mark) {
    for (const t of j$)
      delete e.mark[t];
    e.mark.tooltip && ne(e.mark.tooltip) && delete e.mark.tooltip;
  }
  e.params && (e.signals = (e.signals || []).concat(RL(e.params)), delete e.params);
  for (const t of lue) {
    for (const i of j$)
      delete e[t][i];
    const n = cue[t];
    if (n)
      for (const i of n)
        delete e[t][i];
    hue(e, t);
  }
  for (const t of qle())
    delete e[t];
  due(e);
  for (const t in e)
    ne(e[t]) && Ge(e[t]) && delete e[t];
  return Ge(e) ? void 0 : e;
}
function due(e) {
  const { titleMarkConfig: t, subtitleMarkConfig: n, subtitle: i } = h4(e.title);
  Ge(t) || (e.style["group-title"] = {
    ...e.style["group-title"],
    ...t
    // config.title has higher precedence than config.style.group-title in Vega
  }), Ge(n) || (e.style["group-subtitle"] = {
    ...e.style["group-subtitle"],
    ...n
  }), Ge(i) ? delete e.title : e.title = i;
}
function hue(e, t, n, i) {
  const r = i ? e[t][i] : e[t];
  t === "view" && (n = "cell");
  const s = {
    ...r,
    ...e.style[n ?? t]
  };
  Ge(s) || (e.style[n ?? t] = s), i || delete e[t];
}
function k0(e) {
  return "layer" in e;
}
function gue(e) {
  return "repeat" in e;
}
function pue(e) {
  return !U(e.repeat) && e.repeat.layer;
}
class zE {
  map(t, n) {
    return y0(t) ? this.mapFacet(t, n) : gue(t) ? this.mapRepeat(t, n) : IE(t) ? this.mapHConcat(t, n) : S0(t) ? this.mapVConcat(t, n) : PE(t) ? this.mapConcat(t, n) : this.mapLayerOrUnit(t, n);
  }
  mapLayerOrUnit(t, n) {
    if (k0(t))
      return this.mapLayer(t, n);
    if (Ps(t))
      return this.mapUnit(t, n);
    throw new Error(tE(t));
  }
  mapLayer(t, n) {
    return {
      ...t,
      layer: t.layer.map((i) => this.mapLayerOrUnit(i, n))
    };
  }
  mapHConcat(t, n) {
    return {
      ...t,
      hconcat: t.hconcat.map((i) => this.map(i, n))
    };
  }
  mapVConcat(t, n) {
    return {
      ...t,
      vconcat: t.vconcat.map((i) => this.map(i, n))
    };
  }
  mapConcat(t, n) {
    const { concat: i, ...r } = t;
    return {
      ...r,
      concat: i.map((s) => this.map(s, n))
    };
  }
  mapFacet(t, n) {
    return {
      // as any is required here since TS cannot infer that FO may only be FieldName or Field, but not RepeatRef
      ...t,
      // TODO: remove "any" once we support all facet listed in https://github.com/vega/vega-lite/issues/2760
      spec: this.map(t.spec, n)
    };
  }
  mapRepeat(t, n) {
    return {
      ...t,
      // as any is required here since TS cannot infer that the output type satisfies the input type
      spec: this.map(t.spec, n)
    };
  }
}
const mue = {
  zero: 1,
  center: 1,
  normalize: 1
};
function yue(e) {
  return e in mue;
}
const bue = /* @__PURE__ */ new Set([G4, h0, d0, Ep, p0, yE, bE, g0, V4, mE]), vue = /* @__PURE__ */ new Set([h0, d0, G4]);
function Al(e) {
  return H(e) && ku(e) === "quantitative" && !e.bin;
}
function Z$(e, t, { orient: n, type: i }) {
  const r = t === "x" ? "y" : "radius", s = t === "x" && ["bar", "area"].includes(i), o = e[t], a = e[r];
  if (H(o) && H(a))
    if (Al(o) && Al(a)) {
      if (o.stack)
        return t;
      if (a.stack)
        return r;
      const l = H(o) && !!o.aggregate, u = H(a) && !!a.aggregate;
      if (l !== u)
        return l ? t : r;
      if (s) {
        if (n === "vertical")
          return r;
        if (n === "horizontal")
          return t;
      }
    } else {
      if (Al(o))
        return t;
      if (Al(a))
        return r;
    }
  else {
    if (Al(o))
      return s && n === "vertical" ? void 0 : t;
    if (Al(a))
      return s && n === "horizontal" ? void 0 : r;
  }
}
function xue(e) {
  switch (e) {
    case "x":
      return "y";
    case "y":
      return "x";
    case "theta":
      return "radius";
    case "radius":
      return "theta";
  }
}
function BL(e, t) {
  var p, m;
  const n = Dr(e) ? e : { type: e }, i = n.type;
  if (!bue.has(i))
    return null;
  const r = Z$(t, "x", n) || Z$(t, "theta", n);
  if (!r)
    return null;
  const s = t[r], o = H(s) ? J(s, {}) : void 0, a = xue(r), l = [], u = /* @__PURE__ */ new Set();
  if (t[a]) {
    const y = t[a], b = H(y) ? J(y, {}) : void 0;
    b && b !== o && (l.push(a), u.add(b));
  }
  const c = a === "x" ? "xOffset" : "yOffset", f = t[c], d = H(f) ? J(f, {}) : void 0;
  d && d !== o && (l.push(c), u.add(d));
  const h = Dse.reduce((y, b) => {
    if (b !== "tooltip" && ka(t, b)) {
      const v = t[b];
      for (const _ of ee(v)) {
        const x = Rr(_);
        if (x.aggregate)
          continue;
        const S = J(x, {});
        // if fielddef is a repeat, just include it in the stack by
        (!S || // otherwise, the field must be different from the groupBy fields.
        !u.has(S)) && y.push({ channel: b, fieldDef: x });
      }
    }
    return y;
  }, []);
  let g;
  return s.stack !== void 0 ? To(s.stack) ? g = s.stack ? "zero" : null : g = s.stack : vue.has(i) && (g = "zero"), !g || !yue(g) || $E(t) && h.length === 0 ? null : (p = s == null ? void 0 : s.scale) != null && p.type && ((m = s == null ? void 0 : s.scale) == null ? void 0 : m.type) !== Dn.LINEAR ? (s != null && s.stack && G(Yoe(s.scale.type)), null) : be(t[Gr(r)]) ? (s.stack !== void 0 && G(Voe(r)), null) : (H(s) && s.aggregate && !Gse.has(s.aggregate) && G(Xoe(s.aggregate)), {
    groupbyChannels: l,
    groupbyFields: u,
    fieldChannel: r,
    impute: s.impute === null ? !1 : Ho(i),
    stackBy: h,
    offset: g
  });
}
function jL(e, t, n) {
  const i = Fn(e), r = qe("orient", i, n);
  if (i.orient = Sue(i.type, t, r), r !== void 0 && r !== i.orient && G(Toe(i.orient, r)), i.type === "bar" && i.orient) {
    const a = qe("cornerRadiusEnd", i, n);
    if (a !== void 0) {
      const l = i.orient === "horizontal" && t.x2 || i.orient === "vertical" && t.y2 ? ["cornerRadius"] : Kae[i.orient];
      for (const u of l)
        i[u] = a;
      i.cornerRadiusEnd !== void 0 && delete i.cornerRadiusEnd;
    }
  }
  return qe("opacity", i, n) === void 0 && (i.opacity = _ue(i.type, t)), qe("cursor", i, n) === void 0 && (i.cursor = wue(i, t, n)), i;
}
function wue(e, t, n) {
  return t.href || e.href || qe("href", e, n) ? "pointer" : e.cursor;
}
function _ue(e, t) {
  if (Me([p0, mE, yE, bE], e) && !$E(t))
    return 0.7;
}
function Eue(e, t, { graticule: n }) {
  if (n)
    return !1;
  const i = ks("filled", e, t), r = e.type;
  return dt(i, r !== p0 && r !== g0 && r !== Ep);
}
function Sue(e, t, n) {
  switch (e) {
    case p0:
    case yE:
    case bE:
    case V4:
    case Bae:
    case zae:
      return;
  }
  const { x: i, y: r, x2: s, y2: o } = t;
  switch (e) {
    case h0:
      if (H(i) && (Bt(i.bin) || H(r) && r.aggregate && !i.aggregate))
        return "vertical";
      if (H(r) && (Bt(r.bin) || H(i) && i.aggregate && !r.aggregate))
        return "horizontal";
      if (o || s) {
        if (n)
          return n;
        if (!s)
          return (H(i) && i.type === Wa && !Je(i.bin) || kp(i)) && H(r) && Bt(r.bin) ? "horizontal" : "vertical";
        if (!o)
          return (H(r) && r.type === Wa && !Je(r.bin) || kp(r)) && H(i) && Bt(i.bin) ? "vertical" : "horizontal";
      }
    case Ep:
      if (s && !(H(i) && Bt(i.bin)) && o && !(H(r) && Bt(r.bin)))
        return;
    case d0:
      if (o)
        return H(r) && Bt(r.bin) ? "horizontal" : "vertical";
      if (s)
        return H(i) && Bt(i.bin) ? "vertical" : "horizontal";
      if (e === Ep) {
        if (i && !r)
          return "vertical";
        if (r && !i)
          return "horizontal";
      }
    case g0:
    case mE: {
      const a = H$(i), l = H$(r);
      if (n)
        return n;
      if (a && !l)
        return e !== "tick" ? "horizontal" : "vertical";
      if (!a && l)
        return e !== "tick" ? "vertical" : "horizontal";
      if (a && l)
        return "vertical";
      {
        const u = En(i) && i.type === Eu, c = En(r) && r.type === Eu;
        if (u && !c)
          return "vertical";
        if (!u && c)
          return "horizontal";
      }
      return;
    }
  }
  return "vertical";
}
function kue(e) {
  const { point: t, line: n, ...i } = e;
  return q(i).length > 1 ? i : i.type;
}
function Aue(e) {
  for (const t of ["line", "area", "rule", "trail"])
    e[t] && (e = {
      ...e,
      // TODO: remove as any
      [t]: Nn(e[t], ["point", "line"])
    });
  return e;
}
function ny(e, t = {}, n) {
  return e.point === "transparent" ? { opacity: 0 } : e.point ? ne(e.point) ? e.point : {} : e.point !== void 0 ? null : t.point || n.shape ? ne(t.point) ? t.point : {} : void 0;
}
function eM(e, t = {}) {
  return e.line ? e.line === !0 ? {} : e.line : e.line !== void 0 ? null : t.line ? t.line === !0 ? {} : t.line : void 0;
}
class Cue {
  constructor() {
    this.name = "path-overlay";
  }
  hasMatchingType(t, n) {
    if (Ps(t)) {
      const { mark: i, encoding: r } = t, s = Dr(i) ? i : { type: i };
      switch (s.type) {
        case "line":
        case "rule":
        case "trail":
          return !!ny(s, n[s.type], r);
        case "area":
          return (
            // false / null are also included as we want to remove the properties
            !!ny(s, n[s.type], r) || !!eM(s, n[s.type])
          );
      }
    }
    return !1;
  }
  run(t, n, i) {
    const { config: r } = n, { params: s, projection: o, mark: a, name: l, encoding: u, ...c } = t, f = E0(u, r), d = Dr(a) ? a : { type: a }, h = ny(d, r[d.type], f), g = d.type === "area" && eM(d, r[d.type]), p = [
      {
        name: l,
        ...s ? { params: s } : {},
        mark: kue({
          // TODO: extract this 0.7 to be shared with default opacity for point/tick/...
          ...d.type === "area" && d.opacity === void 0 && d.fillOpacity === void 0 ? { opacity: 0.7 } : {},
          ...d
        }),
        // drop shape from encoding as this might be used to trigger point overlay
        encoding: Nn(f, ["shape"])
      }
    ], m = BL(jL(d, f, r), f);
    let y = f;
    if (m) {
      const { fieldChannel: b, offset: v } = m;
      y = {
        ...f,
        [b]: {
          ...f[b],
          ...v ? { stack: v } : {}
        }
      };
    }
    return y = Nn(y, ["y2", "x2"]), g && p.push({
      ...o ? { projection: o } : {},
      mark: {
        type: "line",
        ...vu(d, ["clip", "interpolate", "tension", "tooltip"]),
        ...g
      },
      encoding: y
    }), h && p.push({
      ...o ? { projection: o } : {},
      mark: {
        type: "point",
        opacity: 1,
        filled: !0,
        ...vu(d, ["clip", "tooltip"]),
        ...h
      },
      encoding: y
    }), i({
      ...c,
      layer: p
    }, {
      ...n,
      config: Aue(r)
    });
  }
}
function $ue(e, t) {
  return t ? Ld(e) ? qL(e, t) : UL(e, t) : e;
}
function iy(e, t) {
  return t ? qL(e, t) : e;
}
function vv(e, t, n) {
  const i = t[e];
  if (cle(i)) {
    if (i.repeat in n)
      return { ...t, [e]: n[i.repeat] };
    G(foe(i.repeat));
    return;
  }
  return t;
}
function UL(e, t) {
  if (e = vv("field", e, t), e !== void 0) {
    if (e === null)
      return null;
    if (SE(e) && Sr(e.sort)) {
      const n = vv("field", e.sort, t);
      e = {
        ...e,
        ...n ? { sort: n } : {}
      };
    }
    return e;
  }
}
function tM(e, t) {
  if (H(e))
    return UL(e, t);
  {
    const n = vv("datum", e, t);
    return n !== e && !n.type && (n.type = "nominal"), n;
  }
}
function nM(e, t) {
  if (be(e)) {
    const n = tM(e, t);
    if (n)
      return n;
    if (b0(e))
      return { condition: e.condition };
  } else {
    if (Pd(e)) {
      const n = tM(e.condition, t);
      if (n)
        return {
          ...e,
          condition: n
        };
      {
        const { condition: i, ...r } = e;
        return r;
      }
    }
    return e;
  }
}
function qL(e, t) {
  const n = {};
  for (const i in e)
    if (ce(e, i)) {
      const r = e[i];
      if (U(r))
        n[i] = r.map((s) => nM(s, t)).filter((s) => s);
      else {
        const s = nM(r, t);
        s !== void 0 && (n[i] = s);
      }
    }
  return n;
}
class Mue {
  constructor() {
    this.name = "RuleForRangedLine";
  }
  hasMatchingType(t) {
    if (Ps(t)) {
      const { encoding: n, mark: i } = t;
      if (i === "line" || Dr(i) && i.type === "line")
        for (const r of Tse) {
          const s = ll(r), o = n[s];
          if (n[r] && (H(o) && !Bt(o.bin) || Yr(o)))
            return !0;
        }
    }
    return !1;
  }
  run(t, n, i) {
    const { encoding: r, mark: s } = t;
    return G(Foe(!!r.x2, !!r.y2)), i({
      ...t,
      mark: ne(s) ? { ...s, type: "rule" } : "rule"
    }, n);
  }
}
class Fue extends zE {
  constructor() {
    super(...arguments), this.nonFacetUnitNormalizers = [
      Ole,
      Rle,
      Ule,
      new Cue(),
      new Mue()
    ];
  }
  map(t, n) {
    if (Ps(t)) {
      const i = ka(t.encoding, ms), r = ka(t.encoding, ys), s = ka(t.encoding, n0);
      if (i || r || s)
        return this.mapFacetedUnit(t, n);
    }
    return super.map(t, n);
  }
  // This is for normalizing non-facet unit
  mapUnit(t, n) {
    const { parentEncoding: i, parentProjection: r } = n, s = iy(t.encoding, n.repeater), o = {
      ...t,
      ...t.name ? { name: [n.repeaterPrefix, t.name].filter((l) => l).join("_") } : {},
      ...s ? { encoding: s } : {}
    };
    if (i || r)
      return this.mapUnitWithParentEncodingOrProjection(o, n);
    const a = this.mapLayerOrUnit.bind(this);
    for (const l of this.nonFacetUnitNormalizers)
      if (l.hasMatchingType(o, n.config))
        return l.run(o, n, a);
    return o;
  }
  mapRepeat(t, n) {
    return pue(t) ? this.mapLayerRepeat(t, n) : this.mapNonLayerRepeat(t, n);
  }
  mapLayerRepeat(t, n) {
    const { repeat: i, spec: r, ...s } = t, { row: o, column: a, layer: l } = i, { repeater: u = {}, repeaterPrefix: c = "" } = n;
    return o || a ? this.mapRepeat({
      ...t,
      repeat: {
        ...o ? { row: o } : {},
        ...a ? { column: a } : {}
      },
      spec: {
        repeat: { layer: l },
        spec: r
      }
    }, n) : {
      ...s,
      layer: l.map((f) => {
        const d = {
          ...u,
          layer: f
        }, h = `${(r.name ? `${r.name}_` : "") + c}child__layer_${tt(f)}`, g = this.mapLayerOrUnit(r, { ...n, repeater: d, repeaterPrefix: h });
        return g.name = h, g;
      })
    };
  }
  mapNonLayerRepeat(t, n) {
    const { repeat: i, spec: r, data: s, ...o } = t;
    !U(i) && t.columns && (t = Nn(t, ["columns"]), G(R$("repeat")));
    const a = [], { repeater: l = {}, repeaterPrefix: u = "" } = n, c = !U(i) && i.row || [l ? l.row : null], f = !U(i) && i.column || [l ? l.column : null], d = U(i) && i || [l ? l.repeat : null];
    for (const g of d)
      for (const p of c)
        for (const m of f) {
          const y = {
            repeat: g,
            row: p,
            column: m,
            layer: l.layer
          }, b = (r.name ? `${r.name}_` : "") + u + "child__" + (U(i) ? `${tt(g)}` : (i.row ? `row_${tt(p)}` : "") + (i.column ? `column_${tt(m)}` : "")), v = this.map(r, { ...n, repeater: y, repeaterPrefix: b });
          v.name = b, a.push(Nn(v, ["data"]));
        }
    const h = U(i) ? t.columns : i.column ? i.column.length : 1;
    return {
      data: r.data ?? s,
      align: "all",
      ...o,
      columns: h,
      concat: a
    };
  }
  mapFacet(t, n) {
    const { facet: i } = t;
    return Ld(i) && t.columns && (t = Nn(t, ["columns"]), G(R$("facet"))), super.mapFacet(t, n);
  }
  mapUnitWithParentEncodingOrProjection(t, n) {
    const { encoding: i, projection: r } = t, { parentEncoding: s, parentProjection: o, config: a } = n, l = rM({ parentProjection: o, projection: r }), u = iM({
      parentEncoding: s,
      encoding: iy(i, n.repeater)
    });
    return this.mapUnit({
      ...t,
      ...l ? { projection: l } : {},
      ...u ? { encoding: u } : {}
    }, { config: a });
  }
  mapFacetedUnit(t, n) {
    const { row: i, column: r, facet: s, ...o } = t.encoding, { mark: a, width: l, projection: u, height: c, view: f, params: d, encoding: h, ...g } = t, { facetMapping: p, layout: m } = this.getFacetMappingAndLayout({ row: i, column: r, facet: s }, n), y = iy(o, n.repeater);
    return this.mapFacet({
      ...g,
      ...m,
      // row / column has higher precedence than facet
      facet: p,
      spec: {
        ...l ? { width: l } : {},
        ...c ? { height: c } : {},
        ...f ? { view: f } : {},
        ...u ? { projection: u } : {},
        mark: a,
        encoding: y,
        ...d ? { params: d } : {}
      }
    }, n);
  }
  getFacetMappingAndLayout(t, n) {
    const { row: i, column: r, facet: s } = t;
    if (i || r) {
      s && G($oe([...i ? [ms] : [], ...r ? [ys] : []]));
      const o = {}, a = {};
      for (const l of [ms, ys]) {
        const u = t[l];
        if (u) {
          const { align: c, center: f, spacing: d, columns: h, ...g } = u;
          o[l] = g;
          for (const p of ["align", "center", "spacing"])
            u[p] !== void 0 && (a[p] ?? (a[p] = {}), a[p][l] = u[p]);
        }
      }
      return { facetMapping: o, layout: a };
    } else {
      const { align: o, center: a, spacing: l, columns: u, ...c } = s;
      return {
        facetMapping: $ue(c, n.repeater),
        layout: {
          ...o ? { align: o } : {},
          ...a ? { center: a } : {},
          ...l ? { spacing: l } : {},
          ...u ? { columns: u } : {}
        }
      };
    }
  }
  mapLayer(t, { parentEncoding: n, parentProjection: i, ...r }) {
    const { encoding: s, projection: o, ...a } = t, l = {
      ...r,
      parentEncoding: iM({ parentEncoding: n, encoding: s, layer: !0 }),
      parentProjection: rM({ parentProjection: i, projection: o })
    };
    return super.mapLayer({
      ...a,
      ...t.name ? { name: [l.repeaterPrefix, t.name].filter((u) => u).join("_") } : {}
    }, l);
  }
}
function iM({ parentEncoding: e, encoding: t = {}, layer: n }) {
  let i = {};
  if (e) {
    const r = /* @__PURE__ */ new Set([...q(e), ...q(t)]);
    for (const s of r) {
      const o = t[s], a = e[s];
      if (be(o)) {
        const l = {
          ...a,
          ...o
        };
        i[s] = l;
      } else
        Pd(o) ? i[s] = {
          ...o,
          condition: {
            ...a,
            ...o.condition
          }
        } : o || o === null ? i[s] = o : (n || er(a) || oe(a) || be(a) || U(a)) && (i[s] = a);
    }
  } else
    i = t;
  return !i || Ge(i) ? void 0 : i;
}
function rM(e) {
  const { parentProjection: t, projection: n } = e;
  return t && n && G(yoe({ parentProjection: t, projection: n })), n ?? t;
}
function BE(e) {
  return "filter" in e;
}
function Tue(e) {
  return (e == null ? void 0 : e.stop) !== void 0;
}
function WL(e) {
  return "lookup" in e;
}
function Oue(e) {
  return "data" in e;
}
function Nue(e) {
  return "param" in e;
}
function Due(e) {
  return "pivot" in e;
}
function Rue(e) {
  return "density" in e;
}
function Lue(e) {
  return "quantile" in e;
}
function Pue(e) {
  return "regression" in e;
}
function Iue(e) {
  return "loess" in e;
}
function zue(e) {
  return "sample" in e;
}
function Bue(e) {
  return "window" in e;
}
function jue(e) {
  return "joinaggregate" in e;
}
function Uue(e) {
  return "flatten" in e;
}
function que(e) {
  return "calculate" in e;
}
function HL(e) {
  return "bin" in e;
}
function Wue(e) {
  return "impute" in e;
}
function Hue(e) {
  return "timeUnit" in e;
}
function Gue(e) {
  return "aggregate" in e;
}
function Vue(e) {
  return "stack" in e;
}
function Yue(e) {
  return "fold" in e;
}
function Xue(e) {
  return "extent" in e && !("density" in e);
}
function Kue(e) {
  return e.map((t) => BE(t) ? {
    filter: Gl(t.filter, Eae)
  } : t);
}
class Jue extends zE {
  map(t, n) {
    return n.emptySelections ?? (n.emptySelections = {}), n.selectionPredicates ?? (n.selectionPredicates = {}), t = sM(t, n), super.map(t, n);
  }
  mapLayerOrUnit(t, n) {
    if (t = sM(t, n), t.encoding) {
      const i = {};
      for (const [r, s] of So(t.encoding))
        i[r] = GL(s, n);
      t = { ...t, encoding: i };
    }
    return super.mapLayerOrUnit(t, n);
  }
  mapUnit(t, n) {
    const { selection: i, ...r } = t;
    return i ? {
      ...r,
      params: So(i).map(([s, o]) => {
        const { init: a, bind: l, empty: u, ...c } = o;
        c.type === "single" ? (c.type = "point", c.toggle = !1) : c.type === "multi" && (c.type = "point"), n.emptySelections[s] = u !== "none";
        for (const f of Wt(n.selectionPredicates[s] ?? {}))
          f.empty = u !== "none";
        return { name: s, value: a, select: c, bind: l };
      })
    } : t;
  }
}
function sM(e, t) {
  const { transform: n, ...i } = e;
  if (n) {
    const r = n.map((s) => {
      if (BE(s))
        return { filter: xv(s, t) };
      if (HL(s) && ul(s.bin))
        return {
          ...s,
          bin: VL(s.bin)
        };
      if (WL(s)) {
        const { selection: o, ...a } = s.from;
        return o ? {
          ...s,
          from: { param: o, ...a }
        } : s;
      }
      return s;
    });
    return { ...i, transform: r };
  }
  return e;
}
function GL(e, t) {
  var i, r;
  const n = me(e);
  if (H(n) && ul(n.bin) && (n.bin = VL(n.bin)), dl(n) && ((r = (i = n.scale) == null ? void 0 : i.domain) != null && r.selection)) {
    const { selection: s, ...o } = n.scale.domain;
    n.scale.domain = { ...o, ...s ? { param: s } : {} };
  }
  if (b0(n))
    if (U(n.condition))
      n.condition = n.condition.map((s) => {
        const { selection: o, param: a, test: l, ...u } = s;
        return a ? s : { ...u, test: xv(s, t) };
      });
    else {
      const { selection: s, param: o, test: a, ...l } = GL(n.condition, t);
      n.condition = o ? n.condition : {
        ...l,
        test: xv(n.condition, t)
      };
    }
  return n;
}
function VL(e) {
  const t = e.extent;
  if (t != null && t.selection) {
    const { selection: n, ...i } = t;
    return { ...e, extent: { ...i, param: n } };
  }
  return e;
}
function xv(e, t) {
  const n = (i) => Gl(i, (r) => {
    var s;
    const o = t.emptySelections[r] ?? !0, a = { param: r, empty: o };
    return (s = t.selectionPredicates)[r] ?? (s[r] = []), t.selectionPredicates[r].push(a), a;
  });
  return e.selection ? n(e.selection) : Gl(e.test || e.filter, (i) => i.selection ? n(i.selection) : i);
}
class wv extends zE {
  map(t, n) {
    const i = n.selections ?? [];
    if (t.params && !Ps(t)) {
      const r = [];
      for (const s of t.params)
        LE(s) ? i.push(s) : r.push(s);
      t.params = r;
    }
    return n.selections = i, super.map(t, n);
  }
  mapUnit(t, n) {
    const i = n.selections;
    if (!i || !i.length)
      return t;
    const r = (n.path ?? []).concat(t.name), s = [];
    for (const o of i)
      if (!o.views || !o.views.length)
        s.push(o);
      else
        for (const a of o.views)
          (te(a) && (a === t.name || r.includes(a)) || U(a) && // logic for backwards compatibility with view paths before we had unique names
          // @ts-ignore
          a.map((l) => r.indexOf(l)).every((l, u, c) => l !== -1 && (u === 0 || l > c[u - 1]))) && s.push(o);
    return s.length && (t.params = s), t;
  }
}
for (const e of ["mapFacet", "mapRepeat", "mapHConcat", "mapVConcat", "mapLayer"]) {
  const t = wv.prototype[e];
  wv.prototype[e] = function(n, i) {
    return t.call(this, n, Que(n, i));
  };
}
function Que(e, t) {
  return e.name ? {
    ...t,
    path: (t.path ?? []).concat(e.name)
  } : t;
}
function YL(e, t) {
  t === void 0 && (t = zL(e.config));
  const n = nce(e, t), { width: i, height: r } = e, s = ice(n, { width: i, height: r, autosize: e.autosize }, t);
  return {
    ...n,
    ...s ? { autosize: s } : {}
  };
}
const Zue = new Fue(), ece = new Jue(), tce = new wv();
function nce(e, t = {}) {
  const n = { config: t };
  return tce.map(Zue.map(ece.map(e, n), n), n);
}
function oM(e) {
  return te(e) ? { type: e } : e ?? {};
}
function ice(e, t, n) {
  let { width: i, height: r } = t;
  const s = Ps(e) || k0(e), o = {};
  s ? i == "container" && r == "container" ? (o.type = "fit", o.contains = "padding") : i == "container" ? (o.type = "fit-x", o.contains = "padding") : r == "container" && (o.type = "fit-y", o.contains = "padding") : (i == "container" && (G(T$("width")), i = void 0), r == "container" && (G(T$("height")), r = void 0));
  const a = {
    type: "pad",
    ...o,
    ...n ? oM(n.autosize) : {},
    ...oM(e.autosize)
  };
  if (a.type === "fit" && !s && (G(toe), a.type = "pad"), i == "container" && !(a.type == "fit" || a.type == "fit-x") && G(O$("width")), r == "container" && !(a.type == "fit" || a.type == "fit-y") && G(O$("height")), !Qn(a, { type: "pad" }))
    return a;
}
function rce(e) {
  return e === "fit" || e === "fit-x" || e === "fit-y";
}
function sce(e) {
  return e ? `fit-${a0(e)}` : "fit";
}
const oce = [
  "background",
  "padding"
  // We do not include "autosize" here as it is supported by only unit and layer specs and thus need to be normalized
];
function aM(e, t) {
  const n = {};
  for (const i of oce)
    e && e[i] !== void 0 && (n[i] = Xn(e[i]));
  return t && (n.params = e.params), n;
}
class Is {
  constructor(t = {}, n = {}) {
    this.explicit = t, this.implicit = n;
  }
  clone() {
    return new Is(me(this.explicit), me(this.implicit));
  }
  combine() {
    return {
      ...this.explicit,
      ...this.implicit
    };
  }
  get(t) {
    return dt(this.explicit[t], this.implicit[t]);
  }
  getWithExplicit(t) {
    return this.explicit[t] !== void 0 ? { explicit: !0, value: this.explicit[t] } : this.implicit[t] !== void 0 ? { explicit: !1, value: this.implicit[t] } : { explicit: !1, value: void 0 };
  }
  setWithExplicit(t, { value: n, explicit: i }) {
    n !== void 0 && this.set(t, n, i);
  }
  set(t, n, i) {
    return delete this[i ? "implicit" : "explicit"][t], this[i ? "explicit" : "implicit"][t] = n, this;
  }
  copyKeyFromSplit(t, { explicit: n, implicit: i }) {
    n[t] !== void 0 ? this.set(t, n[t], !0) : i[t] !== void 0 && this.set(t, i[t], !1);
  }
  copyKeyFromObject(t, n) {
    n[t] !== void 0 && this.set(t, n[t], !0);
  }
  /**
   * Merge split object into this split object. Properties from the other split
   * overwrite properties from this split.
   */
  copyAll(t) {
    for (const n of q(t.combine())) {
      const i = t.getWithExplicit(n);
      this.setWithExplicit(n, i);
    }
  }
}
function pr(e) {
  return {
    explicit: !0,
    value: e
  };
}
function Gn(e) {
  return {
    explicit: !1,
    value: e
  };
}
function XL(e) {
  return (t, n, i, r) => {
    const s = e(t.value, n.value);
    return s > 0 ? t : s < 0 ? n : A0(t, n, i, r);
  };
}
function A0(e, t, n, i) {
  return e.explicit && t.explicit && G(Boe(n, i, e.value, t.value)), e;
}
function Co(e, t, n, i, r = A0) {
  return e === void 0 || e.value === void 0 ? t : e.explicit && !t.explicit ? e : t.explicit && !e.explicit ? t : Qn(e.value, t.value) ? e : r(e, t, n, i);
}
class ace extends Is {
  constructor(t = {}, n = {}, i = !1) {
    super(t, n), this.explicit = t, this.implicit = n, this.parseNothing = i;
  }
  clone() {
    const t = super.clone();
    return t.parseNothing = this.parseNothing, t;
  }
}
function $u(e) {
  return "url" in e;
}
function Yf(e) {
  return "values" in e;
}
function KL(e) {
  return "name" in e && !$u(e) && !Yf(e) && !co(e);
}
function co(e) {
  return e && (JL(e) || QL(e) || jE(e));
}
function JL(e) {
  return "sequence" in e;
}
function QL(e) {
  return "sphere" in e;
}
function jE(e) {
  return "graticule" in e;
}
var Ke;
(function(e) {
  e[e.Raw = 0] = "Raw", e[e.Main = 1] = "Main", e[e.Row = 2] = "Row", e[e.Column = 3] = "Column", e[e.Lookup = 4] = "Lookup";
})(Ke || (Ke = {}));
function ZL(e) {
  const { signals: t, hasLegend: n, index: i, ...r } = e;
  return r.field = Ci(r.field), r;
}
function Va(e, t = !0, n = an) {
  if (U(e)) {
    const i = e.map((r) => Va(r, t, n));
    return t ? `[${i.join(", ")}]` : i;
  } else if (cl(e))
    return n(t ? qa(e) : fae(e));
  return t ? n(Ve(e)) : e;
}
function lce(e, t) {
  for (const n of Wt(e.component.selection ?? {})) {
    const i = n.name;
    let r = `${i}${Mo}, ${n.resolve === "global" ? "true" : `{unit: ${Aa(e)}}`}`;
    for (const s of F0)
      s.defined(n) && (s.signals && (t = s.signals(e, n, t)), s.modifyExpr && (r = s.modifyExpr(e, n, r)));
    t.push({
      name: i + Bce,
      on: [
        {
          events: { signal: n.name + Mo },
          update: `modify(${X(n.name + Ya)}, ${r})`
        }
      ]
    });
  }
  return UE(t);
}
function uce(e, t) {
  if (e.component.selection && q(e.component.selection).length) {
    const n = X(e.getName("cell"));
    t.unshift({
      name: "facet",
      value: {},
      on: [
        {
          events: Po("pointermove", "scope"),
          update: `isTuple(facet) ? facet : group(${n}).datum`
        }
      ]
    });
  }
  return UE(t);
}
function cce(e, t) {
  let n = !1;
  for (const i of Wt(e.component.selection ?? {})) {
    const r = i.name, s = X(r + Ya);
    if (t.filter((a) => a.name === r).length === 0) {
      const a = i.resolve === "global" ? "union" : i.resolve, l = i.type === "point" ? ", true, true)" : ")";
      t.push({
        name: i.name,
        update: `${y8}(${s}, ${X(a)}${l}`
      });
    }
    n = !0;
    for (const a of F0)
      a.defined(i) && a.topLevelSignals && (t = a.topLevelSignals(e, i, t));
  }
  return n && t.filter((r) => r.name === "unit").length === 0 && t.unshift({
    name: "unit",
    value: {},
    on: [{ events: "pointermove", update: "isTuple(group()) ? group() : unit" }]
  }), UE(t);
}
function fce(e, t) {
  const n = [...t], i = Aa(e, { escape: !1 });
  for (const r of Wt(e.component.selection ?? {})) {
    const s = { name: r.name + Ya };
    if (r.project.hasSelectionId && (s.transform = [{ type: "collect", sort: { field: tr } }]), r.init) {
      const a = r.project.items.map(ZL);
      s.values = r.project.hasSelectionId ? r.init.map((l) => ({ unit: i, [tr]: Va(l, !1)[0] })) : r.init.map((l) => ({ unit: i, fields: a, values: Va(l, !1) }));
    }
    n.filter((a) => a.name === r.name + Ya).length || n.push(s);
  }
  return n;
}
function e8(e, t) {
  for (const n of Wt(e.component.selection ?? {}))
    for (const i of F0)
      i.defined(n) && i.marks && (t = i.marks(e, n, t));
  return t;
}
function dce(e, t) {
  for (const n of e.children)
    at(n) && (t = e8(n, t));
  return t;
}
function hce(e, t, n, i) {
  const r = _8(e, t.param, t);
  return {
    signal: li(n.get("type")) && U(i) && i[0] > i[1] ? `isValid(${r}) && reverse(${r})` : r
  };
}
function UE(e) {
  return e.map((t) => (t.on && !t.on.length && delete t.on, t));
}
class He {
  constructor(t, n) {
    this.debugName = n, this._children = [], this._parent = null, t && (this.parent = t);
  }
  /**
   * Clone this node with a deep copy but don't clone links to children or parents.
   */
  clone() {
    throw new Error("Cannot clone node");
  }
  get parent() {
    return this._parent;
  }
  /**
   * Set the parent of the node and also add this node to the parent's children.
   */
  set parent(t) {
    this._parent = t, t && t.addChild(this);
  }
  get children() {
    return this._children;
  }
  numChildren() {
    return this._children.length;
  }
  addChild(t, n) {
    if (this._children.includes(t)) {
      G(goe);
      return;
    }
    n !== void 0 ? this._children.splice(n, 0, t) : this._children.push(t);
  }
  removeChild(t) {
    const n = this._children.indexOf(t);
    return this._children.splice(n, 1), n;
  }
  /**
   * Remove node from the dataflow.
   */
  remove() {
    let t = this._parent.removeChild(this);
    for (const n of this._children)
      n._parent = this._parent, this._parent.addChild(n, t++);
  }
  /**
   * Insert another node as a parent of this node.
   */
  insertAsParentOf(t) {
    const n = t.parent;
    n.removeChild(this), this.parent = n, t.parent = this;
  }
  swapWithParent() {
    const t = this._parent, n = t.parent;
    for (const r of this._children)
      r.parent = t;
    this._children = [], t.removeChild(this);
    const i = t.parent.removeChild(t);
    this._parent = n, n.addChild(this, i), t.parent = this;
  }
}
class xn extends He {
  clone() {
    const t = new this.constructor();
    return t.debugName = `clone_${this.debugName}`, t._source = this._source, t._name = `clone_${this._name}`, t.type = this.type, t.refCounts = this.refCounts, t.refCounts[t._name] = 0, t;
  }
  /**
   * @param source The name of the source. Will change in assemble.
   * @param type The type of the output node.
   * @param refCounts A global ref counter map.
   */
  constructor(t, n, i, r) {
    super(t, n), this.type = i, this.refCounts = r, this._source = this._name = n, this.refCounts && !(this._name in this.refCounts) && (this.refCounts[this._name] = 0);
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  hash() {
    return this._hash === void 0 && (this._hash = `Output ${K6()}`), this._hash;
  }
  /**
   * Request the datasource name and increase the ref counter.
   *
   * During the parsing phase, this will return the simple name such as 'main' or 'raw'.
   * It is crucial to request the name from an output node to mark it as a required node.
   * If nobody ever requests the name, this datasource will not be instantiated in the assemble phase.
   *
   * In the assemble phase, this will return the correct name.
   */
  getSource() {
    return this.refCounts[this._name]++, this._source;
  }
  isRequired() {
    return !!this.refCounts[this._name];
  }
  setSource(t) {
    this._source = t;
  }
}
function ry(e) {
  return e.as !== void 0;
}
function lM(e) {
  return `${e}_end`;
}
class kr extends He {
  clone() {
    return new kr(null, me(this.timeUnits));
  }
  constructor(t, n) {
    super(t), this.timeUnits = n;
  }
  static makeFromEncoding(t, n) {
    const i = n.reduceFieldDef((r, s, o) => {
      const { field: a, timeUnit: l } = s;
      if (l) {
        let u;
        if (fl(l)) {
          if (at(n)) {
            const { mark: c, markDef: f, config: d } = n, h = Ao({ fieldDef: s, markDef: f, config: d });
            (Vf(c) || h) && (u = {
              timeUnit: Dt(l),
              field: a
            });
          }
        } else
          u = {
            as: J(s, { forAs: !0 }),
            field: a,
            timeUnit: l
          };
        if (at(n)) {
          const { mark: c, markDef: f, config: d } = n, h = Ao({ fieldDef: s, markDef: f, config: d });
          Vf(c) && ht(o) && h !== 0.5 && (u.rectBandPosition = h);
        }
        u && (r[$e(u)] = u);
      }
      return r;
    }, {});
    return Ge(i) ? null : new kr(t, i);
  }
  static makeFromTransform(t, n) {
    const { timeUnit: i, ...r } = { ...n }, s = Dt(i), o = {
      ...r,
      timeUnit: s
    };
    return new kr(t, {
      [$e(o)]: o
    });
  }
  /**
   * Merge together TimeUnitNodes assigning the children of `other` to `this`
   * and removing `other`.
   */
  merge(t) {
    this.timeUnits = { ...this.timeUnits };
    for (const n in t.timeUnits)
      this.timeUnits[n] || (this.timeUnits[n] = t.timeUnits[n]);
    for (const n of t.children)
      t.removeChild(n), n.parent = this;
    t.remove();
  }
  /**
   * Remove time units coming from the other node.
   */
  removeFormulas(t) {
    const n = {};
    for (const [i, r] of So(this.timeUnits)) {
      const s = ry(r) ? r.as : `${r.field}_end`;
      t.has(s) || (n[i] = r);
    }
    this.timeUnits = n;
  }
  producedFields() {
    return new Set(Wt(this.timeUnits).map((t) => ry(t) ? t.as : lM(t.field)));
  }
  dependentFields() {
    return new Set(Wt(this.timeUnits).map((t) => t.field));
  }
  hash() {
    return `TimeUnit ${$e(this.timeUnits)}`;
  }
  assemble() {
    const t = [];
    for (const n of Wt(this.timeUnits)) {
      const { rectBandPosition: i } = n, r = Dt(n.timeUnit);
      if (ry(n)) {
        const { field: s, as: o } = n, { unit: a, utc: l, ...u } = r, c = [o, `${o}_end`];
        t.push({
          field: Ci(s),
          type: "timeunit",
          ...a ? { units: f0(a) } : {},
          ...l ? { timezone: "utc" } : {},
          ...u,
          as: c
        }), t.push(...uM(c, i, r));
      } else if (n) {
        const { field: s } = n, o = s.replaceAll("\\.", "."), a = t8({ timeUnit: r, field: o }), l = lM(o);
        t.push({
          type: "formula",
          expr: a,
          as: l
        }), t.push(...uM([o, l], i, r));
      }
    }
    return t;
  }
}
const C0 = "offsetted_rect_start", $0 = "offsetted_rect_end";
function t8({ timeUnit: e, field: t, reverse: n }) {
  const { unit: i, utc: r } = e, s = O4(i), { part: o, step: a } = L4(s, e.step);
  return `${r ? "utcOffset" : "timeOffset"}('${o}', datum['${t}'], ${n ? -a : a})`;
}
function uM([e, t], n, i) {
  if (n !== void 0 && n !== 0.5) {
    const r = `datum['${e}']`, s = `datum['${t}']`;
    return [
      {
        type: "formula",
        expr: cM([
          t8({
            timeUnit: i,
            field: e,
            reverse: !0
          }),
          r
        ], n + 0.5),
        as: `${e}_${C0}`
      },
      {
        type: "formula",
        expr: cM([r, s], n + 0.5),
        as: `${e}_${$0}`
      }
    ];
  }
  return [];
}
function cM([e, t], n) {
  return `${1 - n} * ${e} + ${n} * ${t}`;
}
const Bd = "_tuple_fields";
class gce {
  constructor(...t) {
    this.items = t, this.hasChannel = {}, this.hasField = {}, this.hasSelectionId = !1;
  }
}
const pce = {
  defined: () => !0,
  parse: (e, t, n) => {
    const i = t.name, r = t.project ?? (t.project = new gce()), s = {}, o = {}, a = /* @__PURE__ */ new Set(), l = (g, p) => {
      const m = p === "visual" ? g.channel : g.field;
      let y = tt(`${i}_${m}`);
      for (let b = 1; a.has(y); b++)
        y = tt(`${i}_${m}_${b}`);
      return a.add(y), { [p]: y };
    }, u = t.type, c = e.config.selection[u], f = n.value !== void 0 ? ee(n.value) : null;
    let { fields: d, encodings: h } = ne(n.select) ? n.select : {};
    if (!d && !h && f) {
      for (const g of f)
        if (ne(g))
          for (const p of q(g))
            Fse(p) ? (h || (h = [])).push(p) : u === "interval" ? (G(coe), h = c.encodings) : (d ?? (d = [])).push(p);
    }
    !d && !h && (h = c.encodings, "fields" in c && (d = c.fields));
    for (const g of h ?? []) {
      const p = e.fieldDef(g);
      if (p) {
        let m = p.field;
        if (p.aggregate) {
          G(noe(g, p.aggregate));
          continue;
        } else if (!m) {
          G(D$(g));
          continue;
        }
        if (p.timeUnit && !fl(p.timeUnit)) {
          m = e.vgField(g);
          const y = {
            timeUnit: p.timeUnit,
            as: m,
            field: p.field
          };
          o[$e(y)] = y;
        }
        if (!s[m]) {
          const y = u === "interval" && Ls(g) && li(e.getScaleComponent(g).get("type")) ? "R" : p.bin ? "R-RE" : "E", b = { field: m, channel: g, type: y, index: r.items.length };
          b.signals = { ...l(b, "data"), ...l(b, "visual") }, r.items.push(s[m] = b), r.hasField[m] = s[m], r.hasSelectionId = r.hasSelectionId || m === tr, n4(g) ? (b.geoChannel = g, b.channel = t4(g), r.hasChannel[b.channel] = s[m]) : r.hasChannel[g] = s[m];
        }
      } else
        G(D$(g));
    }
    for (const g of d ?? []) {
      if (r.hasField[g])
        continue;
      const p = { type: "E", field: g, index: r.items.length };
      p.signals = { ...l(p, "data") }, r.items.push(p), r.hasField[g] = p, r.hasSelectionId = r.hasSelectionId || g === tr;
    }
    f && (t.init = f.map((g) => r.items.map((p) => ne(g) ? g[p.geoChannel || p.channel] !== void 0 ? g[p.geoChannel || p.channel] : g[p.field] : g))), Ge(o) || (r.timeUnit = new kr(null, o));
  },
  signals: (e, t, n) => {
    const i = t.name + Bd;
    return n.filter((s) => s.name === i).length > 0 || t.project.hasSelectionId ? n : n.concat({
      name: i,
      value: t.project.items.map(ZL)
    });
  }
}, bs = {
  defined: (e) => e.type === "interval" && e.resolve === "global" && e.bind && e.bind === "scales",
  parse: (e, t) => {
    const n = t.scales = [];
    for (const i of t.project.items) {
      const r = i.channel;
      if (!Ls(r))
        continue;
      const s = e.getScaleComponent(r), o = s ? s.get("type") : void 0;
      if (!s || !li(o)) {
        G(soe);
        continue;
      }
      s.set("selectionExtent", { param: t.name, field: i.field }, !0), n.push(i);
    }
  },
  topLevelSignals: (e, t, n) => {
    const i = t.scales.filter((o) => n.filter((a) => a.name === o.signals.data).length === 0);
    if (!e.parent || fM(e) || i.length === 0)
      return n;
    const r = n.filter((o) => o.name === t.name)[0];
    let s = r.update;
    if (s.indexOf(y8) >= 0)
      r.update = `{${i.map((o) => `${X(Ci(o.field))}: ${o.signals.data}`).join(", ")}}`;
    else {
      for (const o of i) {
        const a = `${X(Ci(o.field))}: ${o.signals.data}`;
        s.includes(a) || (s = `${s.substring(0, s.length - 1)}, ${a}}`);
      }
      r.update = s;
    }
    return n.concat(i.map((o) => ({ name: o.signals.data })));
  },
  signals: (e, t, n) => {
    if (e.parent && !fM(e))
      for (const i of t.scales) {
        const r = n.filter((s) => s.name === i.signals.data)[0];
        r.push = "outer", delete r.value, delete r.update;
      }
    return n;
  }
};
function _v(e, t) {
  return `domain(${X(e.scaleName(t))})`;
}
function fM(e) {
  return e.parent && nc(e.parent) && !e.parent.parent;
}
const Xl = "_brush", n8 = "_scale_trigger", Sc = "geo_interval_init_tick", i8 = "_init", mce = "_center", yce = {
  defined: (e) => e.type === "interval",
  parse: (e, t, n) => {
    var i;
    if (e.hasProjection) {
      const r = { ...ne(n.select) ? n.select : {} };
      r.fields = [tr], r.encodings || (r.encodings = n.value ? q(n.value) : [lr, ar]), n.select = { type: "interval", ...r };
    }
    if (t.translate && !bs.defined(t)) {
      const r = `!event.item || event.item.mark.name !== ${X(t.name + Xl)}`;
      for (const s of t.events) {
        if (!s.between) {
          G(`${s} is not an ordered event stream for interval selections.`);
          continue;
        }
        const o = ee((i = s.between[0]).filter ?? (i.filter = []));
        o.indexOf(r) < 0 && o.push(r);
      }
    }
  },
  signals: (e, t, n) => {
    const i = t.name, r = i + Mo, s = Wt(t.project.hasChannel).filter((a) => a.channel === nt || a.channel === Pt), o = t.init ? t.init[0] : null;
    if (n.push(...s.reduce((a, l) => a.concat(bce(e, t, l, o && o[l.index])), [])), e.hasProjection) {
      const a = X(e.projectionName()), l = e.projectionName() + mce, { x: u, y: c } = t.project.hasChannel, f = u && u.signals.visual, d = c && c.signals.visual, h = u ? o && o[u.index] : `${l}[0]`, g = c ? o && o[c.index] : `${l}[1]`, p = (x) => e.getSizeSignalRef(x).signal, m = `[[${f ? f + "[0]" : "0"}, ${d ? d + "[0]" : "0"}],[${f ? f + "[1]" : p("width")}, ${d ? d + "[1]" : p("height")}]]`;
      o && (n.unshift({
        name: i + i8,
        init: `[scale(${a}, [${u ? h[0] : h}, ${c ? g[0] : g}]), scale(${a}, [${u ? h[1] : h}, ${c ? g[1] : g}])]`
      }), (!u || !c) && (n.find((S) => S.name === l) || n.unshift({
        name: l,
        update: `invert(${a}, [${p("width")}/2, ${p("height")}/2])`
      })));
      const y = `intersect(${m}, {markname: ${X(e.getName("marks"))}}, unit.mark)`, b = `{unit: ${Aa(e)}}`, v = `vlSelectionTuples(${y}, ${b})`, _ = s.map((x) => x.signals.visual);
      return n.concat({
        name: r,
        on: [
          {
            events: [
              ..._.length ? [{ signal: _.join(" || ") }] : [],
              ...o ? [{ signal: Sc }] : []
            ],
            update: v
          }
        ]
      });
    } else {
      if (!bs.defined(t)) {
        const u = i + n8, c = s.map((f) => {
          const d = f.channel, { data: h, visual: g } = f.signals, p = X(e.scaleName(d)), m = e.getScaleComponent(d).get("type"), y = li(m) ? "+" : "";
          return `(!isArray(${h}) || (${y}invert(${p}, ${g})[0] === ${y}${h}[0] && ${y}invert(${p}, ${g})[1] === ${y}${h}[1]))`;
        });
        c.length && n.push({
          name: u,
          value: {},
          on: [
            {
              events: s.map((f) => ({ scale: e.scaleName(f.channel) })),
              update: c.join(" && ") + ` ? ${u} : {}`
            }
          ]
        });
      }
      const a = s.map((u) => u.signals.data), l = `unit: ${Aa(e)}, fields: ${i + Bd}, values`;
      return n.concat({
        name: r,
        ...o ? { init: `{${l}: ${Va(o)}}` } : {},
        ...a.length ? {
          on: [
            {
              events: [{ signal: a.join(" || ") }],
              update: `${a.join(" && ")} ? {${l}: [${a}]} : null`
            }
          ]
        } : {}
      });
    }
  },
  topLevelSignals: (e, t, n) => (at(e) && e.hasProjection && t.init && (n.filter((r) => r.name === Sc).length || n.unshift({
    name: Sc,
    value: null,
    on: [
      {
        events: "timer{1}",
        update: `${Sc} === null ? {} : ${Sc}`
      }
    ]
  })), n),
  marks: (e, t, n) => {
    const i = t.name, { x: r, y: s } = t.project.hasChannel, o = r == null ? void 0 : r.signals.visual, a = s == null ? void 0 : s.signals.visual, l = `data(${X(t.name + Ya)})`;
    if (bs.defined(t) || !r && !s)
      return n;
    const u = {
      x: r !== void 0 ? { signal: `${o}[0]` } : { value: 0 },
      y: s !== void 0 ? { signal: `${a}[0]` } : { value: 0 },
      x2: r !== void 0 ? { signal: `${o}[1]` } : { field: { group: "width" } },
      y2: s !== void 0 ? { signal: `${a}[1]` } : { field: { group: "height" } }
    };
    if (t.resolve === "global")
      for (const p of q(u))
        u[p] = [
          {
            test: `${l}.length && ${l}[0].unit === ${Aa(e)}`,
            ...u[p]
          },
          { value: 0 }
        ];
    const { fill: c, fillOpacity: f, cursor: d, ...h } = t.mark, g = q(h).reduce((p, m) => (p[m] = [
      {
        test: [r !== void 0 && `${o}[0] !== ${o}[1]`, s !== void 0 && `${a}[0] !== ${a}[1]`].filter((y) => y).join(" && "),
        value: h[m]
      },
      { value: null }
    ], p), {});
    return [
      {
        name: `${i + Xl}_bg`,
        type: "rect",
        clip: !0,
        encode: {
          enter: {
            fill: { value: c },
            fillOpacity: { value: f }
          },
          update: u
        }
      },
      ...n,
      {
        name: i + Xl,
        type: "rect",
        clip: !0,
        encode: {
          enter: {
            ...d ? { cursor: { value: d } } : {},
            fill: { value: "transparent" }
          },
          update: { ...u, ...g }
        }
      }
    ];
  }
};
function bce(e, t, n, i) {
  const r = !e.hasProjection, s = n.channel, o = n.signals.visual, a = X(r ? e.scaleName(s) : e.projectionName()), l = (d) => `scale(${a}, ${d})`, u = e.getSizeSignalRef(s === nt ? "width" : "height").signal, c = `${s}(unit)`, f = t.events.reduce((d, h) => [
    ...d,
    { events: h.between[0], update: `[${c}, ${c}]` },
    { events: h, update: `[${o}[0], clamp(${c}, 0, ${u})]` }
    // Brush End
  ], []);
  if (r) {
    const d = n.signals.data, h = bs.defined(t), g = e.getScaleComponent(s), p = g ? g.get("type") : void 0, m = i ? { init: Va(i, !0, l) } : { value: [] };
    return f.push({
      events: { signal: t.name + n8 },
      update: li(p) ? `[${l(`${d}[0]`)}, ${l(`${d}[1]`)}]` : "[0, 0]"
    }), h ? [{ name: d, on: [] }] : [
      { name: o, ...m, on: f },
      {
        name: d,
        ...i ? { init: Va(i) } : {},
        on: [
          {
            events: { signal: o },
            update: `${o}[0] === ${o}[1] ? null : invert(${a}, ${o})`
          }
        ]
      }
    ];
  } else {
    const d = s === nt ? 0 : 1, h = t.name + i8, g = i ? { init: `[${h}[0][${d}], ${h}[1][${d}]]` } : { value: [] };
    return [{ name: o, ...g, on: f }];
  }
}
const vce = {
  defined: (e) => e.type === "point",
  signals: (e, t, n) => {
    const i = t.name, r = i + Bd, s = t.project, o = "(item().isVoronoi ? datum.datum : datum)", a = Wt(e.component.selection ?? {}).reduce((f, d) => d.type === "interval" ? f.concat(d.name + Xl) : f, []).map((f) => `indexof(item().mark.name, '${f}') < 0`).join(" && "), l = `datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${a ? ` && ${a}` : ""}`;
    let u = `unit: ${Aa(e)}, `;
    if (t.project.hasSelectionId)
      u += `${tr}: ${o}[${X(tr)}]`;
    else {
      const f = s.items.map((d) => {
        const h = e.fieldDef(d.channel);
        return h != null && h.bin ? `[${o}[${X(e.vgField(d.channel, {}))}], ${o}[${X(e.vgField(d.channel, { binSuffix: "end" }))}]]` : `${o}[${X(d.field)}]`;
      }).join(", ");
      u += `fields: ${r}, values: [${f}]`;
    }
    const c = t.events;
    return n.concat([
      {
        name: i + Mo,
        on: c ? [
          {
            events: c,
            update: `${l} ? {${u}} : null`,
            force: !0
          }
        ] : []
      }
    ]);
  }
};
function Qu(e, t, n, i) {
  const r = b0(t) && t.condition, s = i(t);
  if (r) {
    const a = ee(r).map((l) => {
      const u = i(l);
      if (ule(l)) {
        const { param: c, empty: f } = l;
        return { test: w8(e, { param: c, empty: f }), ...u };
      } else
        return { test: Dp(e, l.test), ...u };
    });
    return {
      [n]: [...a, ...s !== void 0 ? [s] : []]
    };
  } else
    return s !== void 0 ? { [n]: s } : {};
}
function qE(e, t = "text") {
  const n = e.encoding[t];
  return Qu(e, n, t, (i) => M0(i, e.config));
}
function M0(e, t, n = "datum") {
  if (e) {
    if (er(e))
      return Ze(e.value);
    if (be(e)) {
      const { format: i, formatType: r } = Cp(e);
      return _E({ fieldOrDatumDef: e, format: i, formatType: r, expr: n, config: t });
    }
  }
}
function r8(e, t = {}) {
  const { encoding: n, markDef: i, config: r, stack: s } = e, o = n.tooltip;
  if (U(o))
    return { tooltip: dM({ tooltip: o }, s, r, t) };
  {
    const a = t.reactiveGeom ? "datum.datum" : "datum";
    return Qu(e, o, "tooltip", (l) => {
      const u = M0(l, r, a);
      if (u)
        return u;
      if (l === null)
        return;
      let c = qe("tooltip", i, r);
      if (c === !0 && (c = { content: "encoding" }), te(c))
        return { value: c };
      if (ne(c))
        return oe(c) ? c : c.content === "encoding" ? dM(n, s, r, t) : { signal: a };
    });
  }
}
function s8(e, t, n, { reactiveGeom: i } = {}) {
  const r = { ...n, ...n.tooltipFormat }, s = {}, o = i ? "datum.datum" : "datum", a = [];
  function l(c, f) {
    const d = ll(f), h = En(c) ? c : {
      ...c,
      type: e[d].type
      // for secondary field def, copy type from main channel
    }, g = h.title || AE(h, r), p = ee(g).join(", ").replaceAll(/"/g, '\\"');
    let m;
    if (ht(f)) {
      const y = f === "x" ? "x2" : "y2", b = Rr(e[y]);
      if (Bt(h.bin) && b) {
        const v = J(h, { expr: o }), _ = J(b, { expr: o }), { format: x, formatType: S } = Cp(h);
        m = Rd(v, _, x, S, r), s[y] = !0;
      }
    }
    if ((ht(f) || f === Fi || f === or) && t && t.fieldChannel === f && t.offset === "normalize") {
      const { format: y, formatType: b } = Cp(h);
      m = _E({
        fieldOrDatumDef: h,
        format: y,
        formatType: b,
        expr: o,
        config: r,
        normalizeStack: !0
      }).signal;
    }
    m ?? (m = M0(h, r, o).signal), a.push({ channel: f, key: p, value: m });
  }
  ME(e, (c, f) => {
    H(c) ? l(c, f) : v0(c) && l(c.condition, f);
  });
  const u = {};
  for (const { channel: c, key: f, value: d } of a)
    !s[c] && !u[f] && (u[f] = d);
  return u;
}
function dM(e, t, n, { reactiveGeom: i } = {}) {
  const r = s8(e, t, n, { reactiveGeom: i }), s = So(r).map(([o, a]) => `"${o}": ${a}`);
  return s.length > 0 ? { signal: `{${s.join(", ")}}` } : void 0;
}
function xce(e) {
  const { markDef: t, config: n } = e, i = qe("aria", t, n);
  return i === !1 ? {} : {
    ...i ? { aria: i } : {},
    ...wce(e),
    ..._ce(e)
  };
}
function wce(e) {
  const { mark: t, markDef: n, config: i } = e;
  if (i.aria === !1)
    return {};
  const r = qe("ariaRoleDescription", n, i);
  return r != null ? { ariaRoleDescription: { value: r } } : t in Qse ? {} : { ariaRoleDescription: { value: t } };
}
function _ce(e) {
  const { encoding: t, markDef: n, config: i, stack: r } = e, s = t.description;
  if (s)
    return Qu(e, s, "description", (l) => M0(l, e.config));
  const o = qe("description", n, i);
  if (o != null)
    return {
      description: Ze(o)
    };
  if (i.aria === !1)
    return {};
  const a = s8(t, r, i);
  if (!Ge(a))
    return {
      description: {
        signal: So(a).map(([l, u], c) => `"${c > 0 ? "; " : ""}${l}: " + (${u})`).join(" + ")
      }
    };
}
function $t(e, t, n = {}) {
  const { markDef: i, encoding: r, config: s } = t, { vgChannel: o } = n;
  let { defaultRef: a, defaultValue: l } = n;
  a === void 0 && (l ?? (l = qe(e, i, s, { vgChannel: o, ignoreVgConfig: !0 })), l !== void 0 && (a = Ze(l)));
  const u = r[e];
  return Qu(t, u, o ?? e, (c) => wE({
    channel: e,
    channelDef: c,
    markDef: i,
    config: s,
    scaleName: t.scaleName(e),
    scale: t.getScaleComponent(e),
    stack: null,
    defaultRef: a
  }));
}
function o8(e, t = { filled: void 0 }) {
  const { markDef: n, encoding: i, config: r } = e, { type: s } = n, o = t.filled ?? qe("filled", n, r), a = Me(["bar", "point", "circle", "square", "geoshape"], s) ? "transparent" : void 0, l = qe(o === !0 ? "color" : void 0, n, r, { vgChannel: "fill" }) ?? // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified
  r.mark[o === !0 && "color"] ?? // If there is no fill, always fill symbols, bar, geoshape
  // with transparent fills https://github.com/vega/vega-lite/issues/1316
  a, u = qe(o === !1 ? "color" : void 0, n, r, { vgChannel: "stroke" }) ?? // need to add this manually as getMarkConfig normally drops config.mark[channel] if vgChannel is specified
  r.mark[o === !1 && "color"], c = o ? "fill" : "stroke", f = {
    ...l ? { fill: Ze(l) } : {},
    ...u ? { stroke: Ze(u) } : {}
  };
  return n.color && (o ? n.fill : n.stroke) && G(E4("property", { fill: "fill" in n, stroke: "stroke" in n })), {
    ...f,
    ...$t("color", e, {
      vgChannel: c,
      defaultValue: o ? l : u
    }),
    ...$t("fill", e, {
      // if there is encoding.fill, include default fill just in case we have conditional-only fill encoding
      defaultValue: i.fill ? l : void 0
    }),
    ...$t("stroke", e, {
      // if there is encoding.stroke, include default fill just in case we have conditional-only stroke encoding
      defaultValue: i.stroke ? u : void 0
    })
  };
}
function Ece(e) {
  const { encoding: t, mark: n } = e, i = t.order;
  return !Ho(n) && er(i) ? Qu(e, i, "zindex", (r) => Ze(r.value)) : {};
}
function Mu({ channel: e, markDef: t, encoding: n = {}, model: i, bandPosition: r }) {
  const s = `${e}Offset`, o = t[s], a = n[s];
  if ((s === "xOffset" || s === "yOffset") && a)
    return { offsetType: "encoding", offset: wE({
      channel: s,
      channelDef: a,
      markDef: t,
      config: i == null ? void 0 : i.config,
      scaleName: i.scaleName(s),
      scale: i.getScaleComponent(s),
      stack: null,
      defaultRef: Ze(o),
      bandPosition: r
    }) };
  const l = t[s];
  return l ? { offsetType: "visual", offset: l } : {};
}
function en(e, t, { defaultPos: n, vgChannel: i }) {
  const { encoding: r, markDef: s, config: o, stack: a } = t, l = r[e], u = r[Gr(e)], c = t.scaleName(e), f = t.getScaleComponent(e), { offset: d, offsetType: h } = Mu({
    channel: e,
    markDef: s,
    encoding: r,
    model: t,
    bandPosition: 0.5
  }), g = WE({
    model: t,
    defaultPos: n,
    channel: e,
    scaleName: c,
    scale: f
  }), p = !l && ht(e) && (r.latitude || r.longitude) ? (
    // use geopoint output if there are lat/long and there is no point position overriding lat/long.
    { field: t.getName(e) }
  ) : Sce({
    channel: e,
    channelDef: l,
    channel2Def: u,
    markDef: s,
    config: o,
    scaleName: c,
    scale: f,
    stack: a,
    offset: d,
    defaultRef: g,
    bandPosition: h === "encoding" ? 0 : void 0
  });
  return p ? { [i || e]: p } : void 0;
}
function Sce(e) {
  const { channel: t, channelDef: n, scaleName: i, stack: r, offset: s, markDef: o } = e;
  if (be(n) && r && t === r.fieldChannel) {
    if (H(n)) {
      let a = n.bandPosition;
      if (a === void 0 && o.type === "text" && (t === "radius" || t === "theta") && (a = 0.5), a !== void 0)
        return Sp({
          scaleName: i,
          fieldOrDatumDef: n,
          startSuffix: "start",
          bandPosition: a,
          offset: s
        });
    }
    return Sa(n, i, { suffix: "end" }, { offset: s });
  }
  return vE(e);
}
function WE({ model: e, defaultPos: t, channel: n, scaleName: i, scale: r }) {
  const { markDef: s, config: o } = e;
  return () => {
    const a = ll(n), l = ko(n), u = qe(n, s, o, { vgChannel: l });
    if (u !== void 0)
      return gf(n, u);
    switch (t) {
      case "zeroOrMin":
      case "zeroOrMax":
        if (i) {
          const c = r.get("type");
          if (!Me([Dn.LOG, Dn.TIME, Dn.UTC], c)) {
            if (r.domainDefinitelyIncludesZero())
              return {
                scale: i,
                value: 0
              };
          }
        }
        if (t === "zeroOrMin")
          return a === "y" ? { field: { group: "height" } } : { value: 0 };
        switch (a) {
          case "radius":
            return {
              signal: `min(${e.width.signal},${e.height.signal})/2`
            };
          case "theta":
            return { signal: "2*PI" };
          case "x":
            return { field: { group: "width" } };
          case "y":
            return { value: 0 };
        }
        break;
      case "mid":
        return { ...e[qn(n)], mult: 0.5 };
    }
  };
}
const kce = {
  left: "x",
  center: "xc",
  right: "x2"
}, Ace = {
  top: "y",
  middle: "yc",
  bottom: "y2"
};
function a8(e, t, n, i = "middle") {
  if (e === "radius" || e === "theta")
    return ko(e);
  const r = e === "x" ? "align" : "baseline", s = qe(r, t, n);
  let o;
  return oe(s) ? (G(Moe(r)), o = void 0) : o = s, e === "x" ? kce[o || (i === "top" ? "left" : "center")] : Ace[o || i];
}
function Op(e, t, { defaultPos: n, defaultPos2: i, range: r }) {
  return r ? l8(e, t, { defaultPos: n, defaultPos2: i }) : en(e, t, { defaultPos: n });
}
function l8(e, t, { defaultPos: n, defaultPos2: i }) {
  const { markDef: r, config: s } = t, o = Gr(e), a = qn(e), l = Cce(t, i, o), u = l[a] ? (
    // If there is width/height, we need to position the marks based on the alignment.
    a8(e, r, s)
  ) : (
    // Otherwise, make sure to apply to the right Vg Channel (for arc mark)
    ko(e)
  );
  return {
    ...en(e, t, { defaultPos: n, vgChannel: u }),
    ...l
  };
}
function Cce(e, t, n) {
  const { encoding: i, mark: r, markDef: s, stack: o, config: a } = e, l = ll(n), u = qn(n), c = ko(n), f = i[l], d = e.scaleName(l), h = e.getScaleComponent(l), { offset: g } = n in i || n in s ? Mu({ channel: n, markDef: s, encoding: i, model: e }) : Mu({ channel: l, markDef: s, encoding: i, model: e });
  if (!f && (n === "x2" || n === "y2") && (i.latitude || i.longitude)) {
    const m = qn(n), y = e.markDef[m];
    return y != null ? {
      [m]: { value: y }
    } : {
      [c]: { field: e.getName(n) }
    };
  }
  const p = $ce({
    channel: n,
    channelDef: f,
    channel2Def: i[n],
    markDef: s,
    config: a,
    scaleName: d,
    scale: h,
    stack: o,
    offset: g,
    defaultRef: void 0
  });
  return p !== void 0 ? { [c]: p } : xh(n, s) || xh(n, {
    [n]: wp(n, s, a.style),
    [u]: wp(u, s, a.style)
  }) || xh(n, a[r]) || xh(n, a.mark) || {
    [c]: WE({
      model: e,
      defaultPos: t,
      channel: n,
      scaleName: d,
      scale: h
    })()
  };
}
function $ce({ channel: e, channelDef: t, channel2Def: n, markDef: i, config: r, scaleName: s, scale: o, stack: a, offset: l, defaultRef: u }) {
  return be(t) && a && // If fieldChannel is X and channel is X2 (or Y and Y2)
  e.charAt(0) === a.fieldChannel.charAt(0) ? Sa(t, s, { suffix: "start" }, { offset: l }) : vE({
    channel: e,
    channelDef: n,
    scaleName: s,
    scale: o,
    stack: a,
    markDef: i,
    config: r,
    offset: l,
    defaultRef: u
  });
}
function xh(e, t) {
  const n = qn(e), i = ko(e);
  if (t[i] !== void 0)
    return { [i]: gf(e, t[i]) };
  if (t[e] !== void 0)
    return { [i]: gf(e, t[e]) };
  if (t[n]) {
    const r = t[n];
    if (Ha(r))
      G(Eoe(n));
    else
      return { [n]: gf(e, r) };
  }
}
function $o(e, t) {
  const { config: n, encoding: i, markDef: r } = e, s = r.type, o = Gr(t), a = qn(t), l = i[t], u = i[o], c = e.getScaleComponent(t), f = c ? c.get("type") : void 0, d = r.orient, h = i[a] ?? i.size ?? qe("size", r, n, { vgChannel: a }), g = o4(t), p = s === "bar" && (t === "x" ? d === "vertical" : d === "horizontal");
  return H(l) && (Je(l.bin) || Bt(l.bin) || l.timeUnit && !u) && !(h && !Ha(h)) && !i[g] && !Rt(f) ? Tce({
    fieldDef: l,
    fieldDef2: u,
    channel: t,
    model: e
  }) : (be(l) && Rt(f) || p) && !u ? Fce(l, t, e) : l8(t, e, { defaultPos: "zeroOrMax", defaultPos2: "zeroOrMin" });
}
function Mce(e, t, n, i, r, s, o) {
  if (Ha(r))
    if (n) {
      const l = n.get("type");
      if (l === "band") {
        let u = `bandwidth('${t}')`;
        r.band !== 1 && (u = `${r.band} * ${u}`);
        const c = ks("minBandSize", { type: o }, i);
        return { signal: c ? `max(${Hi(c)}, ${u})` : u };
      } else
        r.band !== 1 && (G(Noe(l)), r = void 0);
    } else
      return {
        mult: r.band,
        field: { group: e }
      };
  else {
    if (oe(r))
      return r;
    if (r)
      return { value: r };
  }
  if (n) {
    const l = n.get("range");
    if (Wo(l) && Re(l.step))
      return { value: l.step - 2 };
  }
  if (!s) {
    const { bandPaddingInner: l, barBandPaddingInner: u, rectBandPaddingInner: c } = i.scale, f = dt(l, o === "bar" ? u : c);
    if (oe(f))
      return { signal: `(1 - (${f.signal})) * ${e}` };
    if (Re(f))
      return { signal: `${1 - f} * ${e}` };
  }
  return { value: Fp(i.view, e) - 2 };
}
function Fce(e, t, n) {
  var $, N;
  const { markDef: i, encoding: r, config: s, stack: o } = n, a = i.orient, l = n.scaleName(t), u = n.getScaleComponent(t), c = qn(t), f = Gr(t), d = o4(t), h = n.scaleName(d), g = n.getScaleComponent(K_(t)), p = a === "horizontal" && t === "y" || a === "vertical" && t === "x";
  let m;
  (r.size || i.size) && (p ? m = $t("size", n, {
    vgChannel: c,
    defaultRef: Ze(i.size)
  }) : G(Poe(i.type)));
  const y = !!m, b = rL({
    channel: t,
    fieldDef: e,
    markDef: i,
    config: s,
    scaleType: ($ = u || g) == null ? void 0 : $.get("type"),
    useVlSizeChannel: p
  });
  m = m || {
    [c]: Mce(c, h || l, g || u, s, b, !!e, i.type)
  };
  const v = ((N = u || g) == null ? void 0 : N.get("type")) === "band" && Ha(b) && !y ? "top" : "middle", _ = a8(t, i, s, v), x = _ === "xc" || _ === "yc", { offset: S, offsetType: E } = Mu({ channel: t, markDef: i, encoding: r, model: n, bandPosition: x ? 0.5 : 0 }), C = vE({
    channel: t,
    channelDef: e,
    markDef: i,
    config: s,
    scaleName: l,
    scale: u,
    stack: o,
    offset: S,
    defaultRef: WE({ model: n, defaultPos: "mid", channel: t, scaleName: l, scale: u }),
    bandPosition: x ? E === "encoding" ? 0 : 0.5 : oe(b) ? { signal: `(1-${b})/2` } : Ha(b) ? (1 - b.band) / 2 : 0
  });
  if (c)
    return { [_]: C, ...m };
  {
    const O = ko(f), P = m[c], T = S ? { ...P, offset: S } : P;
    return {
      [_]: C,
      // posRef might be an array that wraps position invalid test
      [O]: U(C) ? [C[0], { ...C[1], offset: T }] : {
        ...C,
        offset: T
      }
    };
  }
}
function hM(e, t, n, i, r, s, o) {
  if (e4(e))
    return 0;
  const a = e === "x" || e === "y2", l = a ? -t / 2 : t / 2;
  if (oe(n) || oe(r) || oe(i) || s) {
    const u = Hi(n), c = Hi(r), f = Hi(i), d = Hi(s), g = s ? `(${o} < ${d} ? ${a ? "" : "-"}0.5 * (${d} - (${o})) : ${l})` : l, p = f ? `${f} + ` : "", m = u ? `(${u} ? -1 : 1) * ` : "", y = c ? `(${c} + ${g})` : g;
    return {
      signal: p + m + y
    };
  } else
    return r = r || 0, i + (n ? -r - l : +r + l);
}
function Tce({ fieldDef: e, fieldDef2: t, channel: n, model: i }) {
  var N;
  const { config: r, markDef: s, encoding: o } = i, a = i.getScaleComponent(n), l = i.scaleName(n), u = a ? a.get("type") : void 0, c = a.get("reverse"), f = rL({ channel: n, fieldDef: e, markDef: s, config: r, scaleType: u }), d = (N = i.component.axes[n]) == null ? void 0 : N[0], h = (d == null ? void 0 : d.get("translate")) ?? 0.5, g = ht(n) ? qe("binSpacing", s, r) ?? 0 : 0, p = Gr(n), m = ko(n), y = ko(p), b = ks("minBandSize", s, r), { offset: v } = Mu({ channel: n, markDef: s, encoding: o, model: i, bandPosition: 0 }), { offset: _ } = Mu({ channel: p, markDef: s, encoding: o, model: i, bandPosition: 0 }), x = rle({ fieldDef: e, scaleName: l }), S = hM(n, g, c, h, v, b, x), E = hM(p, g, c, h, _ ?? v, b, x), C = oe(f) ? { signal: `(1-${f.signal})/2` } : Ha(f) ? (1 - f.band) / 2 : 0.5, $ = Ao({ fieldDef: e, fieldDef2: t, markDef: s, config: r });
  if (Je(e.bin) || e.timeUnit) {
    const O = e.timeUnit && $ !== 0.5;
    return {
      [y]: gM({
        fieldDef: e,
        scaleName: l,
        bandPosition: C,
        offset: E,
        useRectOffsetField: O
      }),
      [m]: gM({
        fieldDef: e,
        scaleName: l,
        bandPosition: oe(C) ? { signal: `1-${C.signal}` } : 1 - C,
        offset: S,
        useRectOffsetField: O
      })
    };
  } else if (Bt(e.bin)) {
    const O = Sa(e, l, {}, { offset: E });
    if (H(t))
      return {
        [y]: O,
        [m]: Sa(t, l, {}, { offset: S })
      };
    if (ul(e.bin) && e.bin.step)
      return {
        [y]: O,
        [m]: {
          signal: `scale("${l}", ${J(e, { expr: "datum" })} + ${e.bin.step})`,
          offset: S
        }
      };
  }
  G(A4(p));
}
function gM({ fieldDef: e, scaleName: t, bandPosition: n, offset: i, useRectOffsetField: r }) {
  return Sp({
    scaleName: t,
    fieldOrDatumDef: e,
    bandPosition: n,
    offset: i,
    ...r ? {
      startSuffix: C0,
      endSuffix: $0
    } : {}
  });
}
const Oce = /* @__PURE__ */ new Set(["aria", "width", "height"]);
function Ti(e, t) {
  const { fill: n = void 0, stroke: i = void 0 } = t.color === "include" ? o8(e) : {};
  return {
    ...Nce(e.markDef, t),
    ...pM(e, "fill", n),
    ...pM(e, "stroke", i),
    ...$t("opacity", e),
    ...$t("fillOpacity", e),
    ...$t("strokeOpacity", e),
    ...$t("strokeWidth", e),
    ...$t("strokeDash", e),
    ...Ece(e),
    ...r8(e),
    ...qE(e, "href"),
    ...xce(e)
  };
}
function pM(e, t, n) {
  const { config: i, mark: r, markDef: s } = e;
  if (qe("invalid", s, i) === "hide" && n && !Ho(r)) {
    const a = Dce(e, { invalid: !0, channels: l0 });
    if (a)
      return {
        [t]: [
          // prepend the invalid case
          // TODO: support custom value
          { test: a, value: null },
          ...ee(n)
        ]
      };
  }
  return n ? { [t]: n } : {};
}
function Nce(e, t) {
  return Jse.reduce((n, i) => (!Oce.has(i) && e[i] !== void 0 && t[i] !== "ignore" && (n[i] = Ze(e[i])), n), {});
}
function Dce(e, { invalid: t = !1, channels: n }) {
  const i = n.reduce((s, o) => {
    const a = e.getScaleComponent(o);
    if (a) {
      const l = a.get("type"), u = e.vgField(o, { expr: "datum" });
      u && li(l) && (s[u] = !0);
    }
    return s;
  }, {}), r = q(i);
  if (r.length > 0) {
    const s = t ? "||" : "&&";
    return r.map((o) => xE(o, t)).join(` ${s} `);
  }
}
function HE(e) {
  const { config: t, markDef: n } = e;
  if (qe("invalid", n, t)) {
    const r = Rce(e, { channels: Vr });
    if (r)
      return { defined: { signal: r } };
  }
  return {};
}
function Rce(e, { invalid: t = !1, channels: n }) {
  const i = n.reduce((s, o) => {
    var l;
    const a = e.getScaleComponent(o);
    if (a) {
      const u = a.get("type"), c = e.vgField(o, { expr: "datum", binSuffix: (l = e.stack) != null && l.impute ? "mid" : void 0 });
      c && li(u) && (s[c] = !0);
    }
    return s;
  }, {}), r = q(i);
  if (r.length > 0) {
    const s = t ? "||" : "&&";
    return r.map((o) => xE(o, t)).join(` ${s} `);
  }
}
function mM(e, t) {
  if (t !== void 0)
    return { [e]: Ze(t) };
}
const sy = "voronoi", u8 = {
  defined: (e) => e.type === "point" && e.nearest,
  parse: (e, t) => {
    if (t.events)
      for (const n of t.events)
        n.markname = e.getName(sy);
  },
  marks: (e, t, n) => {
    const { x: i, y: r } = t.project.hasChannel, s = e.mark;
    if (Ho(s))
      return G(ioe(s)), n;
    const o = {
      name: e.getName(sy),
      type: "path",
      interactive: !0,
      from: { data: e.getName("marks") },
      encode: {
        update: {
          fill: { value: "transparent" },
          strokeWidth: { value: 0.35 },
          stroke: { value: "transparent" },
          isVoronoi: { value: !0 },
          ...r8(e, { reactiveGeom: !0 })
        }
      },
      transform: [
        {
          type: "voronoi",
          x: { expr: i || !r ? "datum.datum.x || 0" : "0" },
          y: { expr: r || !i ? "datum.datum.y || 0" : "0" },
          size: [e.getSizeSignalRef("width"), e.getSizeSignalRef("height")]
        }
      ]
    };
    let a = 0, l = !1;
    return n.forEach((u, c) => {
      const f = u.name ?? "";
      f === e.component.mark[0].name ? a = c : f.indexOf(sy) >= 0 && (l = !0);
    }), l || n.splice(a + 1, 0, o), n;
  }
}, c8 = {
  defined: (e) => e.type === "point" && e.resolve === "global" && e.bind && e.bind !== "scales" && !RE(e.bind),
  parse: (e, t, n) => b8(t, n),
  topLevelSignals: (e, t, n) => {
    const i = t.name, r = t.project, s = t.bind, o = t.init && t.init[0], a = u8.defined(t) ? "(item().isVoronoi ? datum.datum : datum)" : "datum";
    return r.items.forEach((l, u) => {
      const c = tt(`${i}_${l.field}`);
      n.filter((d) => d.name === c).length || n.unshift({
        name: c,
        ...o ? { init: Va(o[u]) } : { value: null },
        on: t.events ? [
          {
            events: t.events,
            update: `datum && item().mark.marktype !== 'group' ? ${a}[${X(l.field)}] : null`
          }
        ] : [],
        bind: s[l.field] ?? s[l.channel] ?? s
      });
    }), n;
  },
  signals: (e, t, n) => {
    const i = t.name, r = t.project, s = n.filter((u) => u.name === i + Mo)[0], o = i + Bd, a = r.items.map((u) => tt(`${i}_${u.field}`)), l = a.map((u) => `${u} !== null`).join(" && ");
    return a.length && (s.update = `${l} ? {fields: ${o}, values: [${a.join(", ")}]} : null`), delete s.value, delete s.on, n;
  }
}, Np = "_toggle", f8 = {
  defined: (e) => e.type === "point" && !!e.toggle,
  signals: (e, t, n) => n.concat({
    name: t.name + Np,
    value: !1,
    on: [{ events: t.events, update: t.toggle }]
  }),
  modifyExpr: (e, t) => {
    const n = t.name + Mo, i = t.name + Np;
    return `${i} ? null : ${n}, ` + (t.resolve === "global" ? `${i} ? null : true, ` : `${i} ? null : {unit: ${Aa(e)}}, `) + `${i} ? ${n} : null`;
  }
}, Lce = {
  defined: (e) => e.clear !== void 0 && e.clear !== !1,
  parse: (e, t) => {
    t.clear && (t.clear = te(t.clear) ? Po(t.clear, "view") : t.clear);
  },
  topLevelSignals: (e, t, n) => {
    if (c8.defined(t))
      for (const i of t.project.items) {
        const r = n.findIndex((s) => s.name === tt(`${t.name}_${i.field}`));
        r !== -1 && n[r].on.push({ events: t.clear, update: "null" });
      }
    return n;
  },
  signals: (e, t, n) => {
    function i(r, s) {
      r !== -1 && n[r].on && n[r].on.push({ events: t.clear, update: s });
    }
    if (t.type === "interval")
      for (const r of t.project.items) {
        const s = n.findIndex((o) => o.name === r.signals.visual);
        if (i(s, "[0, 0]"), s === -1) {
          const o = n.findIndex((a) => a.name === r.signals.data);
          i(o, "null");
        }
      }
    else {
      let r = n.findIndex((s) => s.name === t.name + Mo);
      i(r, "null"), f8.defined(t) && (r = n.findIndex((s) => s.name === t.name + Np), i(r, "false"));
    }
    return n;
  }
}, d8 = {
  defined: (e) => {
    const t = e.resolve === "global" && e.bind && RE(e.bind), n = e.project.items.length === 1 && e.project.items[0].field !== tr;
    return t && !n && G(ooe), t && n;
  },
  parse: (e, t, n) => {
    const i = me(n);
    if (i.select = te(i.select) ? { type: i.select, toggle: t.toggle } : { ...i.select, toggle: t.toggle }, b8(t, i), ne(n.select) && (n.select.on || n.select.clear)) {
      const o = 'event.item && indexof(event.item.mark.role, "legend") < 0';
      for (const a of t.events)
        a.filter = ee(a.filter ?? []), a.filter.includes(o) || a.filter.push(o);
    }
    const r = ty(t.bind) ? t.bind.legend : "click", s = te(r) ? Po(r, "view") : ee(r);
    t.bind = { legend: { merge: s } };
  },
  topLevelSignals: (e, t, n) => {
    const i = t.name, r = ty(t.bind) && t.bind.legend, s = (o) => (a) => {
      const l = me(a);
      return l.markname = o, l;
    };
    for (const o of t.project.items) {
      if (!o.hasLegend)
        continue;
      const a = `${tt(o.field)}_legend`, l = `${i}_${a}`;
      if (n.filter((c) => c.name === l).length === 0) {
        const c = r.merge.map(s(`${a}_symbols`)).concat(r.merge.map(s(`${a}_labels`))).concat(r.merge.map(s(`${a}_entries`)));
        n.unshift({
          name: l,
          ...t.init ? {} : { value: null },
          on: [
            // Legend entries do not store values, so we need to walk the scenegraph to the symbol datum.
            {
              events: c,
              update: "isDefined(datum.value) ? datum.value : item().items[0].items[0].datum.value",
              force: !0
            },
            { events: r.merge, update: `!event.item || !datum ? null : ${l}`, force: !0 }
          ]
        });
      }
    }
    return n;
  },
  signals: (e, t, n) => {
    const i = t.name, r = t.project, s = n.find((d) => d.name === i + Mo), o = i + Bd, a = r.items.filter((d) => d.hasLegend).map((d) => tt(`${i}_${tt(d.field)}_legend`)), u = `${a.map((d) => `${d} !== null`).join(" && ")} ? {fields: ${o}, values: [${a.join(", ")}]} : null`;
    t.events && a.length > 0 ? s.on.push({
      events: a.map((d) => ({ signal: d })),
      update: u
    }) : a.length > 0 && (s.update = u, delete s.value, delete s.on);
    const c = n.find((d) => d.name === i + Np), f = ty(t.bind) && t.bind.legend;
    return c && (t.events ? c.on.push({ ...c.on[0], events: f }) : c.on[0].events = f), n;
  }
};
function Pce(e, t, n) {
  var r;
  const i = (r = e.fieldDef(t)) == null ? void 0 : r.field;
  for (const s of Wt(e.component.selection ?? {})) {
    const o = s.project.hasField[i] ?? s.project.hasChannel[t];
    if (o && d8.defined(s)) {
      const a = n.get("selections") ?? [];
      a.push(s.name), n.set("selections", a, !1), o.hasLegend = !0;
    }
  }
}
const h8 = "_translate_anchor", g8 = "_translate_delta", Ice = {
  defined: (e) => e.type === "interval" && e.translate,
  signals: (e, t, n) => {
    const i = t.name, r = bs.defined(t), s = i + h8, { x: o, y: a } = t.project.hasChannel;
    let l = Po(t.translate, "scope");
    return r || (l = l.map((u) => (u.between[0].markname = i + Xl, u))), n.push({
      name: s,
      value: {},
      on: [
        {
          events: l.map((u) => u.between[0]),
          update: "{x: x(unit), y: y(unit)" + (o !== void 0 ? `, extent_x: ${r ? _v(e, nt) : `slice(${o.signals.visual})`}` : "") + (a !== void 0 ? `, extent_y: ${r ? _v(e, Pt) : `slice(${a.signals.visual})`}` : "") + "}"
        }
      ]
    }, {
      name: i + g8,
      value: {},
      on: [
        {
          events: l,
          update: `{x: ${s}.x - x(unit), y: ${s}.y - y(unit)}`
        }
      ]
    }), o !== void 0 && yM(e, t, o, "width", n), a !== void 0 && yM(e, t, a, "height", n), n;
  }
};
function yM(e, t, n, i, r) {
  const s = t.name, o = s + h8, a = s + g8, l = n.channel, u = bs.defined(t), c = r.filter((x) => x.name === n.signals[u ? "data" : "visual"])[0], f = e.getSizeSignalRef(i).signal, d = e.getScaleComponent(l), h = d && d.get("type"), g = d && d.get("reverse"), p = u ? l === nt ? g ? "" : "-" : g ? "-" : "" : "", m = `${o}.extent_${l}`, y = `${p}${a}.${l} / ${u ? `${f}` : `span(${m})`}`, b = !u || !d ? "panLinear" : h === "log" ? "panLog" : h === "symlog" ? "panSymlog" : h === "pow" ? "panPow" : "panLinear", v = u ? h === "pow" ? `, ${d.get("exponent") ?? 1}` : h === "symlog" ? `, ${d.get("constant") ?? 1}` : "" : "", _ = `${b}(${m}, ${y}${v})`;
  c.on.push({
    events: { signal: a },
    update: u ? _ : `clampRange(${_}, 0, ${f})`
  });
}
const p8 = "_zoom_anchor", m8 = "_zoom_delta", zce = {
  defined: (e) => e.type === "interval" && e.zoom,
  signals: (e, t, n) => {
    const i = t.name, r = bs.defined(t), s = i + m8, { x: o, y: a } = t.project.hasChannel, l = X(e.scaleName(nt)), u = X(e.scaleName(Pt));
    let c = Po(t.zoom, "scope");
    return r || (c = c.map((f) => (f.markname = i + Xl, f))), n.push({
      name: i + p8,
      on: [
        {
          events: c,
          update: r ? "{" + [l ? `x: invert(${l}, x(unit))` : "", u ? `y: invert(${u}, y(unit))` : ""].filter((f) => f).join(", ") + "}" : "{x: x(unit), y: y(unit)}"
        }
      ]
    }, {
      name: s,
      on: [
        {
          events: c,
          force: !0,
          update: "pow(1.001, event.deltaY * pow(16, event.deltaMode))"
        }
      ]
    }), o !== void 0 && bM(e, t, o, "width", n), a !== void 0 && bM(e, t, a, "height", n), n;
  }
};
function bM(e, t, n, i, r) {
  const s = t.name, o = n.channel, a = bs.defined(t), l = r.filter((b) => b.name === n.signals[a ? "data" : "visual"])[0], u = e.getSizeSignalRef(i).signal, c = e.getScaleComponent(o), f = c && c.get("type"), d = a ? _v(e, o) : l.name, h = s + m8, g = `${s}${p8}.${o}`, p = !a || !c ? "zoomLinear" : f === "log" ? "zoomLog" : f === "symlog" ? "zoomSymlog" : f === "pow" ? "zoomPow" : "zoomLinear", m = a ? f === "pow" ? `, ${c.get("exponent") ?? 1}` : f === "symlog" ? `, ${c.get("constant") ?? 1}` : "" : "", y = `${p}(${d}, ${g}, ${h}${m})`;
  l.on.push({
    events: { signal: h },
    update: a ? y : `clampRange(${y}, 0, ${u})`
  });
}
const Ya = "_store", Mo = "_tuple", Bce = "_modify", y8 = "vlSelectionResolve", F0 = [
  vce,
  yce,
  pce,
  f8,
  // Bindings may disable direct manipulation.
  c8,
  bs,
  d8,
  Lce,
  Ice,
  zce,
  u8
];
function jce(e) {
  let t = e.parent;
  for (; t && !Ki(t); )
    t = t.parent;
  return t;
}
function Aa(e, { escape: t } = { escape: !0 }) {
  let n = t ? X(e.name) : e.name;
  const i = jce(e);
  if (i) {
    const { facet: r } = i;
    for (const s of yi)
      r[s] && (n += ` + '__facet_${s}_' + (facet[${X(i.vgField(s))}])`);
  }
  return n;
}
function GE(e) {
  return Wt(e.component.selection ?? {}).reduce((t, n) => t || n.project.hasSelectionId, !1);
}
function b8(e, t) {
  (te(t.select) || !t.select.on) && delete e.events, (te(t.select) || !t.select.clear) && delete e.clear, (te(t.select) || !t.select.toggle) && delete e.toggle;
}
function Ev(e) {
  const t = [];
  return e.type === "Identifier" ? [e.name] : e.type === "Literal" ? [e.value] : (e.type === "MemberExpression" && (t.push(...Ev(e.object)), t.push(...Ev(e.property))), t);
}
function v8(e) {
  return e.object.type === "MemberExpression" ? v8(e.object) : e.object.name === "datum";
}
function x8(e) {
  const t = f_(e), n = /* @__PURE__ */ new Set();
  return t.visit((i) => {
    i.type === "MemberExpression" && v8(i) && n.add(Ev(i).slice(1).join("."));
  }), n;
}
class Zu extends He {
  clone() {
    return new Zu(null, this.model, me(this.filter));
  }
  constructor(t, n, i) {
    super(t), this.model = n, this.filter = i, this.expr = Dp(this.model, this.filter, this), this._dependentFields = x8(this.expr);
  }
  dependentFields() {
    return this._dependentFields;
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  assemble() {
    return {
      type: "filter",
      expr: this.expr
    };
  }
  hash() {
    return `Filter ${this.expr}`;
  }
}
function Uce(e, t) {
  const n = {}, i = e.config.selection;
  if (!t || !t.length)
    return n;
  for (const r of t) {
    const s = tt(r.name), o = r.select, a = te(o) ? o : o.type, l = ne(o) ? me(o) : { type: a }, u = i[a];
    for (const d in u)
      d === "fields" || d === "encodings" || (d === "mark" && (l[d] = { ...u[d], ...l[d] }), (l[d] === void 0 || l[d] === !0) && (l[d] = me(u[d] ?? l[d])));
    const c = n[s] = {
      ...l,
      name: s,
      type: a,
      init: r.value,
      bind: r.bind,
      events: te(l.on) ? Po(l.on, "scope") : ee(me(l.on))
    }, f = me(r);
    for (const d of F0)
      d.defined(c) && d.parse && d.parse(e, c, f);
  }
  return n;
}
function w8(e, t, n, i = "datum") {
  const r = te(t) ? t : t.param, s = tt(r), o = X(s + Ya);
  let a;
  try {
    a = e.getSelectionComponent(s, r);
  } catch {
    return `!!${s}`;
  }
  if (a.project.timeUnit) {
    const d = n ?? e.component.data.raw, h = a.project.timeUnit.clone();
    d.parent ? h.insertAsParentOf(d) : d.parent = h;
  }
  const l = a.project.hasSelectionId ? "vlSelectionIdTest(" : "vlSelectionTest(", u = a.resolve === "global" ? ")" : `, ${X(a.resolve)})`, c = `${l}${o}, ${i}${u}`, f = `length(data(${o}))`;
  return t.empty === !1 ? `${f} && ${c}` : `!${f} || ${c}`;
}
function _8(e, t, n) {
  const i = tt(t), r = n.encoding;
  let s = n.field, o;
  try {
    o = e.getSelectionComponent(i, t);
  } catch {
    return i;
  }
  if (!r && !s)
    s = o.project.items[0].field, o.project.items.length > 1 && G(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${X(s)}.`);
  else if (r && !s) {
    const a = o.project.items.filter((l) => l.channel === r);
    !a.length || a.length > 1 ? (s = o.project.items[0].field, G((a.length ? "Multiple " : "No ") + `matching ${X(r)} encoding found for selection ${X(n.param)}. Using "field": ${X(s)}.`)) : s = a[0].field;
  }
  return `${o.name}[${X(Ci(s))}]`;
}
function qce(e, t) {
  for (const [n, i] of So(e.component.selection ?? {})) {
    const r = e.getName(`lookup_${n}`);
    e.component.data.outputNodes[r] = i.materialized = new xn(new Zu(t, e, { param: n }), r, Ke.Lookup, e.component.data.outputNodeRefCounts);
  }
}
function Dp(e, t, n) {
  return hf(t, (i) => te(i) ? i : xae(i) ? w8(e, i, n) : I4(i));
}
function Wce(e, t) {
  if (e)
    return U(e) && !Ys(e) ? e.map((n) => AE(n, t)).join(", ") : e;
}
function oy(e, t, n, i) {
  var r, s;
  e.encode ?? (e.encode = {}), (r = e.encode)[t] ?? (r[t] = {}), (s = e.encode[t]).update ?? (s.update = {}), e.encode[t].update[n] = i;
}
function Jc(e, t, n, i = { header: !1 }) {
  var f, d;
  const { disable: r, orient: s, scale: o, labelExpr: a, title: l, zindex: u, ...c } = e.combine();
  if (!r) {
    for (const h in c) {
      const g = Ele[h], p = c[h];
      if (g && g !== t && g !== "both")
        delete c[h];
      else if (zd(p)) {
        const { condition: m, ...y } = p, b = ee(m), v = G$[h];
        if (v) {
          const { vgProp: _, part: x } = v, S = [
            ...b.map((E) => {
              const { test: C, ...$ } = E;
              return {
                test: Dp(null, C),
                ...$
              };
            }),
            y
          ];
          oy(c, x, _, S), delete c[h];
        } else if (v === null) {
          const _ = {
            signal: b.map((x) => {
              const { test: S, ...E } = x;
              return `${Dp(null, S)} ? ${F$(E)} : `;
            }).join("") + F$(y)
          };
          c[h] = _;
        }
      } else if (oe(p)) {
        const m = G$[h];
        if (m) {
          const { vgProp: y, part: b } = m;
          oy(c, b, y, p), delete c[h];
        }
      }
      Me(["labelAlign", "labelBaseline"], h) && c[h] === null && delete c[h];
    }
    if (t === "grid") {
      if (!c.grid)
        return;
      if (c.encode) {
        const { grid: h } = c.encode;
        c.encode = {
          ...h ? { grid: h } : {}
        }, Ge(c.encode) && delete c.encode;
      }
      return {
        scale: o,
        orient: s,
        ...c,
        domain: !1,
        labels: !1,
        aria: !1,
        // Always set min/maxExtent to 0 to ensure that `config.axis*.minExtent` and `config.axis*.maxExtent`
        // would not affect gridAxis
        maxExtent: 0,
        minExtent: 0,
        ticks: !1,
        zindex: dt(u, 0)
        // put grid behind marks by default
      };
    } else {
      if (!i.header && e.mainExtracted)
        return;
      if (a !== void 0) {
        let g = a;
        (d = (f = c.encode) == null ? void 0 : f.labels) != null && d.update && oe(c.encode.labels.update.text) && (g = ja(a, "datum.label", c.encode.labels.update.text.signal)), oy(c, "labels", "text", { signal: g });
      }
      if (c.labelAlign === null && delete c.labelAlign, c.encode) {
        for (const g of gL)
          e.hasAxisPart(g) || delete c.encode[g];
        Ge(c.encode) && delete c.encode;
      }
      const h = Wce(l, n);
      return {
        scale: o,
        orient: s,
        grid: !1,
        ...h ? { title: h } : {},
        ...c,
        ...n.aria === !1 ? { aria: !1 } : {},
        zindex: dt(u, 0)
        // put axis line above marks by default
      };
    }
  }
}
function E8(e) {
  const { axes: t } = e.component, n = [];
  for (const i of Vr)
    if (t[i]) {
      for (const r of t[i])
        if (!r.get("disable") && !r.get("gridScale")) {
          const s = i === "x" ? "height" : "width", o = e.getSizeSignalRef(s).signal;
          s !== o && n.push({
            name: s,
            update: o
          });
        }
    }
  return n;
}
function Hce(e, t) {
  const { x: n = [], y: i = [] } = e;
  return [
    ...n.map((r) => Jc(r, "grid", t)),
    ...i.map((r) => Jc(r, "grid", t)),
    ...n.map((r) => Jc(r, "main", t)),
    ...i.map((r) => Jc(r, "main", t))
  ].filter((r) => r);
}
function vM(e, t, n, i) {
  return Object.assign.apply(null, [
    {},
    ...e.map((r) => {
      if (r === "axisOrient") {
        const s = n === "x" ? "bottom" : "left", o = t[n === "x" ? "axisBottom" : "axisLeft"] || {}, a = t[n === "x" ? "axisTop" : "axisRight"] || {}, l = /* @__PURE__ */ new Set([...q(o), ...q(a)]), u = {};
        for (const c of l.values())
          u[c] = {
            // orient is surely signal in this case
            signal: `${i.signal} === "${s}" ? ${Hi(o[c])} : ${Hi(a[c])}`
          };
        return u;
      }
      return t[r];
    })
  ]);
}
function Gce(e, t, n, i) {
  const r = t === "band" ? ["axisDiscrete", "axisBand"] : t === "point" ? ["axisDiscrete", "axisPoint"] : U4(t) ? ["axisQuantitative"] : t === "time" || t === "utc" ? ["axisTemporal"] : [], s = e === "x" ? "axisX" : "axisY", o = oe(n) ? "axisOrient" : `axis${Md(n)}`, a = [
    // technically Vega does have axisBand, but if we make another separation here,
    // it will further introduce complexity in the code
    ...r,
    ...r.map((u) => s + u.substr(4))
  ], l = ["axis", o, s];
  return {
    vlOnlyAxisConfig: vM(a, i, e, n),
    vgAxisConfig: vM(l, i, e, n),
    axisConfigStyle: Vce([...l, ...a], i)
  };
}
function Vce(e, t) {
  var i;
  const n = [{}];
  for (const r of e) {
    let s = (i = t[r]) == null ? void 0 : i.style;
    if (s) {
      s = ee(s);
      for (const o of s)
        n.push(t.style[o]);
    }
  }
  return Object.assign.apply(null, n);
}
function Sv(e, t, n, i = {}) {
  var s;
  const r = m4(e, n, t);
  if (r !== void 0)
    return {
      configFrom: "style",
      configValue: r
    };
  for (const o of ["vlOnlyAxisConfig", "vgAxisConfig", "axisConfigStyle"])
    if (((s = i[o]) == null ? void 0 : s[e]) !== void 0)
      return { configFrom: o, configValue: i[o][e] };
  return {};
}
const xM = {
  scale: ({ model: e, channel: t }) => e.scaleName(t),
  format: ({ format: e }) => e,
  formatType: ({ formatType: e }) => e,
  grid: ({ fieldOrDatumDef: e, axis: t, scaleType: n }) => t.grid ?? Yce(n, e),
  gridScale: ({ model: e, channel: t }) => Xce(e, t),
  labelAlign: ({ axis: e, labelAngle: t, orient: n, channel: i }) => e.labelAlign || k8(t, n, i),
  labelAngle: ({ labelAngle: e }) => e,
  labelBaseline: ({ axis: e, labelAngle: t, orient: n, channel: i }) => e.labelBaseline || S8(t, n, i),
  labelFlush: ({ axis: e, fieldOrDatumDef: t, channel: n }) => e.labelFlush ?? Jce(t.type, n),
  labelOverlap: ({ axis: e, fieldOrDatumDef: t, scaleType: n }) => e.labelOverlap ?? Qce(t.type, n, H(t) && !!t.timeUnit, H(t) ? t.sort : void 0),
  // we already calculate orient in parse
  orient: ({ orient: e }) => e,
  tickCount: ({ channel: e, model: t, axis: n, fieldOrDatumDef: i, scaleType: r }) => {
    const s = e === "x" ? "width" : e === "y" ? "height" : void 0, o = s ? t.getSizeSignalRef(s) : void 0;
    return n.tickCount ?? efe({ fieldOrDatumDef: i, scaleType: r, size: o, values: n.values });
  },
  tickMinStep: tfe,
  title: ({ axis: e, model: t, channel: n }) => {
    if (e.title !== void 0)
      return e.title;
    const i = A8(t, n);
    if (i !== void 0)
      return i;
    const r = t.typedFieldDef(n), s = n === "x" ? "x2" : "y2", o = t.fieldDef(s);
    return b4(r ? [W$(r)] : [], H(o) ? [W$(o)] : []);
  },
  values: ({ axis: e, fieldOrDatumDef: t }) => nfe(e, t),
  zindex: ({ axis: e, fieldOrDatumDef: t, mark: n }) => e.zindex ?? ife(n, t)
};
function Yce(e, t) {
  return !Rt(e) && H(t) && !Je(t == null ? void 0 : t.bin) && !Bt(t == null ? void 0 : t.bin);
}
function Xce(e, t) {
  const n = t === "x" ? "y" : "x";
  if (e.getScaleComponent(n))
    return e.scaleName(n);
}
function Kce(e, t, n, i, r) {
  const s = t == null ? void 0 : t.labelAngle;
  if (s !== void 0)
    return oe(s) ? s : Gf(s);
  {
    const { configValue: o } = Sv("labelAngle", i, t == null ? void 0 : t.style, r);
    return o !== void 0 ? Gf(o) : n === nt && Me([pE, gE], e.type) && !(H(e) && e.timeUnit) ? 270 : void 0;
  }
}
function kv(e) {
  return `(((${e.signal} % 360) + 360) % 360)`;
}
function S8(e, t, n, i) {
  if (e !== void 0)
    if (n === "x") {
      if (oe(e)) {
        const r = kv(e), s = oe(t) ? `(${t.signal} === "top")` : t === "top";
        return {
          signal: `(45 < ${r} && ${r} < 135) || (225 < ${r} && ${r} < 315) ? "middle" :(${r} <= 45 || 315 <= ${r}) === ${s} ? "bottom" : "top"`
        };
      }
      if (45 < e && e < 135 || 225 < e && e < 315)
        return "middle";
      if (oe(t)) {
        const r = e <= 45 || 315 <= e ? "===" : "!==";
        return { signal: `${t.signal} ${r} "top" ? "bottom" : "top"` };
      }
      return (e <= 45 || 315 <= e) == (t === "top") ? "bottom" : "top";
    } else {
      if (oe(e)) {
        const r = kv(e), s = oe(t) ? `(${t.signal} === "left")` : t === "left";
        return {
          signal: `${r} <= 45 || 315 <= ${r} || (135 <= ${r} && ${r} <= 225) ? ${i ? '"middle"' : "null"} : (45 <= ${r} && ${r} <= 135) === ${s} ? "top" : "bottom"`
        };
      }
      if (e <= 45 || 315 <= e || 135 <= e && e <= 225)
        return i ? "middle" : null;
      if (oe(t)) {
        const r = 45 <= e && e <= 135 ? "===" : "!==";
        return { signal: `${t.signal} ${r} "left" ? "top" : "bottom"` };
      }
      return (45 <= e && e <= 135) == (t === "left") ? "top" : "bottom";
    }
}
function k8(e, t, n) {
  if (e === void 0)
    return;
  const i = n === "x", r = i ? 0 : 90, s = i ? "bottom" : "left";
  if (oe(e)) {
    const o = kv(e), a = oe(t) ? `(${t.signal} === "${s}")` : t === s;
    return {
      signal: `(${r ? `(${o} + 90)` : o} % 180 === 0) ? ${i ? null : '"center"'} :(${r} < ${o} && ${o} < ${180 + r}) === ${a} ? "left" : "right"`
    };
  }
  if ((e + r) % 180 === 0)
    return i ? null : "center";
  if (oe(t)) {
    const o = r < e && e < 180 + r ? "===" : "!==";
    return {
      signal: `${`${t.signal} ${o} "${s}"`} ? "left" : "right"`
    };
  }
  return (r < e && e < 180 + r) == (t === s) ? "left" : "right";
}
function Jce(e, t) {
  if (t === "x" && Me(["quantitative", "temporal"], e))
    return !0;
}
function Qce(e, t, n, i) {
  if (n && !ne(i) || e !== "nominal" && e !== "ordinal")
    return t === "log" || t === "symlog" ? "greedy" : !0;
}
function Zce(e) {
  return e === "x" ? "bottom" : "left";
}
function efe({ fieldOrDatumDef: e, scaleType: t, size: n, values: i }) {
  var r;
  if (!i && !Rt(t) && t !== "log") {
    if (H(e)) {
      if (Je(e.bin))
        return { signal: `ceil(${n.signal}/10)` };
      if (e.timeUnit && Me(["month", "hours", "day", "quarter"], (r = Dt(e.timeUnit)) == null ? void 0 : r.unit))
        return;
    }
    return { signal: `ceil(${n.signal}/40)` };
  }
}
function tfe({ format: e, fieldOrDatumDef: t }) {
  if (e === "d")
    return 1;
  if (H(t)) {
    const { timeUnit: n } = t;
    if (n) {
      const i = R4(n);
      if (i)
        return { signal: i };
    }
  }
}
function A8(e, t) {
  const n = t === "x" ? "x2" : "y2", i = e.fieldDef(t), r = e.fieldDef(n), s = i ? i.title : void 0, o = r ? r.title : void 0;
  if (s && o)
    return v4(s, o);
  if (s)
    return s;
  if (o)
    return o;
  if (s !== void 0)
    return s;
  if (o !== void 0)
    return o;
}
function nfe(e, t) {
  const n = e.values;
  if (U(n))
    return hL(t, n);
  if (oe(n))
    return n;
}
function ife(e, t) {
  return e === "rect" && Ap(t) ? 1 : 0;
}
class Fu extends He {
  clone() {
    return new Fu(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this._dependentFields = x8(this.transform.calculate);
  }
  static parseAllForSortIndex(t, n) {
    return n.forEachFieldDef((i, r) => {
      if (dl(i) && iL(i.sort)) {
        const { field: s, timeUnit: o } = i, a = i.sort, l = a.map((u, c) => `${I4({ field: s, timeUnit: o, equal: u })} ? ${c} : `).join("") + a.length;
        t = new Fu(t, {
          calculate: l,
          as: Tu(i, r, { forAs: !0 })
        });
      }
    }), t;
  }
  producedFields() {
    return /* @__PURE__ */ new Set([this.transform.as]);
  }
  dependentFields() {
    return this._dependentFields;
  }
  assemble() {
    return {
      type: "formula",
      expr: this.transform.calculate,
      as: this.transform.as
    };
  }
  hash() {
    return `Calculate ${$e(this.transform)}`;
  }
}
function Tu(e, t, n) {
  return J(e, { prefix: t, suffix: "sort_index", ...n ?? {} });
}
function T0(e, t) {
  return Me(["top", "bottom"], t) ? "column" : Me(["left", "right"], t) || e === "row" ? "row" : "column";
}
function Ou(e, t, n, i) {
  const r = i === "row" ? n.headerRow : i === "column" ? n.headerColumn : n.headerFacet;
  return dt((t || {})[e], r[e], n.header[e]);
}
function O0(e, t, n, i) {
  const r = {};
  for (const s of e) {
    const o = Ou(s, t || {}, n, i);
    o !== void 0 && (r[s] = o);
  }
  return r;
}
const VE = ["row", "column"], YE = ["header", "footer"];
function rfe(e, t) {
  const n = e.component.layoutHeaders[t].title, i = e.config ? e.config : void 0, r = e.component.layoutHeaders[t].facetFieldDef ? e.component.layoutHeaders[t].facetFieldDef : void 0, { titleAnchor: s, titleAngle: o, titleOrient: a } = O0(["titleAnchor", "titleAngle", "titleOrient"], r.header, i, t), l = T0(t, a), u = Gf(o);
  return {
    name: `${t}-title`,
    type: "group",
    role: `${l}-title`,
    title: {
      text: n,
      ...t === "row" ? { orient: "left" } : {},
      style: "guide-title",
      ...$8(u, l),
      ...C8(l, u, s),
      ...M8(i, r, t, Hle, TL)
    }
  };
}
function C8(e, t, n = "middle") {
  switch (n) {
    case "start":
      return { align: "left" };
    case "end":
      return { align: "right" };
  }
  const i = k8(t, e === "row" ? "left" : "top", e === "row" ? "y" : "x");
  return i ? { align: i } : {};
}
function $8(e, t) {
  const n = S8(e, t === "row" ? "left" : "top", t === "row" ? "y" : "x", !0);
  return n ? { baseline: n } : {};
}
function sfe(e, t) {
  const n = e.component.layoutHeaders[t], i = [];
  for (const r of YE)
    if (n[r])
      for (const s of n[r]) {
        const o = afe(e, t, r, n, s);
        o != null && i.push(o);
      }
  return i;
}
function ofe(e, t) {
  const { sort: n } = e;
  return Sr(n) ? {
    field: J(n, { expr: "datum" }),
    order: n.order ?? "ascending"
  } : U(n) ? {
    field: Tu(e, t, { expr: "datum" }),
    order: "ascending"
  } : {
    field: J(e, { expr: "datum" }),
    order: n ?? "ascending"
  };
}
function Av(e, t, n) {
  const { format: i, formatType: r, labelAngle: s, labelAnchor: o, labelOrient: a, labelExpr: l } = O0(["format", "formatType", "labelAngle", "labelAnchor", "labelOrient", "labelExpr"], e.header, n, t), u = _E({
    fieldOrDatumDef: e,
    format: i,
    formatType: r,
    expr: "parent",
    config: n
  }).signal, c = T0(t, a);
  return {
    text: {
      signal: l ? ja(ja(l, "datum.label", u), "datum.value", J(e, { expr: "parent" })) : u
    },
    ...t === "row" ? { orient: "left" } : {},
    style: "guide-label",
    frame: "group",
    ...$8(s, c),
    ...C8(c, s, o),
    ...M8(n, e, t, Gle, OL)
  };
}
function afe(e, t, n, i, r) {
  if (r) {
    let s = null;
    const { facetFieldDef: o } = i, a = e.config ? e.config : void 0;
    if (o && r.labels) {
      const { labelOrient: f } = O0(["labelOrient"], o.header, a, t);
      (t === "row" && !Me(["top", "bottom"], f) || t === "column" && !Me(["left", "right"], f)) && (s = Av(o, t, a));
    }
    const l = Ki(e) && !Ld(e.facet), u = r.axes, c = (u == null ? void 0 : u.length) > 0;
    if (s || c) {
      const f = t === "row" ? "height" : "width";
      return {
        name: e.getName(`${t}_${n}`),
        type: "group",
        role: `${t}-${n}`,
        ...i.facetFieldDef ? {
          from: { data: e.getName(`${t}_domain`) },
          sort: ofe(o, t)
        } : {},
        ...c && l ? {
          from: { data: e.getName(`facet_domain_${t}`) }
        } : {},
        ...s ? { title: s } : {},
        ...r.sizeSignal ? {
          encode: {
            update: {
              [f]: r.sizeSignal
            }
          }
        } : {},
        ...c ? { axes: u } : {}
      };
    }
  }
  return null;
}
const lfe = {
  column: {
    start: 0,
    end: 1
  },
  row: {
    start: 1,
    end: 0
  }
};
function ufe(e, t) {
  return lfe[t][e];
}
function cfe(e, t) {
  const n = {};
  for (const i of yi) {
    const r = e[i];
    if (r != null && r.facetFieldDef) {
      const { titleAnchor: s, titleOrient: o } = O0(["titleAnchor", "titleOrient"], r.facetFieldDef.header, t, i), a = T0(i, o), l = ufe(s, a);
      l !== void 0 && (n[a] = l);
    }
  }
  return Ge(n) ? void 0 : n;
}
function M8(e, t, n, i, r) {
  const s = {};
  for (const o of i) {
    if (!r[o])
      continue;
    const a = Ou(o, t == null ? void 0 : t.header, e, n);
    a !== void 0 && (s[r[o]] = a);
  }
  return s;
}
function XE(e) {
  return [
    ...wh(e, "width"),
    ...wh(e, "height"),
    ...wh(e, "childWidth"),
    ...wh(e, "childHeight")
  ];
}
function wh(e, t) {
  const n = t === "width" ? "x" : "y", i = e.component.layoutSize.get(t);
  if (!i || i === "merged")
    return [];
  const r = e.getSizeSignalRef(t).signal;
  if (i === "step") {
    const s = e.getScaleComponent(n);
    if (s) {
      const o = s.get("type"), a = s.get("range");
      if (Rt(o) && Wo(a)) {
        const l = e.scaleName(n);
        return Ki(e.parent) && e.parent.component.resolve.scale[n] === "independent" ? [wM(l, a)] : [
          wM(l, a),
          {
            name: r,
            update: F8(l, s, `domain('${l}').length`)
          }
        ];
      }
    }
    throw new Error("layout size is step although width/height is not step.");
  } else if (i == "container") {
    const s = r.endsWith("width"), o = s ? "containerSize()[0]" : "containerSize()[1]", a = bv(e.config.view, s ? "width" : "height"), l = `isFinite(${o}) ? ${o} : ${a}`;
    return [{ name: r, init: l, on: [{ update: l, events: "window:resize" }] }];
  } else
    return [
      {
        name: r,
        value: i
      }
    ];
}
function wM(e, t) {
  const n = `${e}_step`;
  return oe(t.step) ? { name: n, update: t.step.signal } : { name: n, value: t.step };
}
function F8(e, t, n) {
  const i = t.get("type"), r = t.get("padding"), s = dt(t.get("paddingOuter"), r);
  let o = t.get("paddingInner");
  return o = i === "band" ? (
    // only band has real paddingInner
    o !== void 0 ? o : r
  ) : (
    // For point, as calculated in https://github.com/vega/vega-scale/blob/master/src/band.js#L128,
    // it's equivalent to have paddingInner = 1 since there is only n-1 steps between n points.
    1
  ), `bandspace(${n}, ${Hi(o)}, ${Hi(s)}) * ${e}_step`;
}
function T8(e) {
  return e === "childWidth" ? "width" : e === "childHeight" ? "height" : e;
}
function O8(e, t) {
  return q(e).reduce((n, i) => {
    const r = e[i];
    return {
      ...n,
      ...Qu(t, r, i, (s) => Ze(s.value))
    };
  }, {});
}
function N8(e, t) {
  if (Ki(t))
    return e === "theta" ? "independent" : "shared";
  if (nc(t))
    return "shared";
  if (nS(t))
    return ht(e) || e === "theta" || e === "radius" ? "independent" : "shared";
  throw new Error("invalid model type for resolve");
}
function KE(e, t) {
  const n = e.scale[t], i = ht(t) ? "axis" : "legend";
  return n === "independent" ? (e[i][t] === "shared" && G(Uoe(t)), "independent") : e[i][t] || "shared";
}
const ffe = {
  ...Xle,
  disable: 1,
  labelExpr: 1,
  selections: 1,
  // channel scales
  opacity: 1,
  shape: 1,
  stroke: 1,
  fill: 1,
  size: 1,
  strokeWidth: 1,
  strokeDash: 1,
  // encode
  encode: 1
}, D8 = q(ffe);
class dfe extends Is {
}
const _M = {
  symbols: hfe,
  gradient: gfe,
  labels: pfe,
  entries: mfe
};
function hfe(e, { fieldOrDatumDef: t, model: n, channel: i, legendCmpt: r, legendType: s }) {
  if (s !== "symbol")
    return;
  const { markDef: o, encoding: a, config: l, mark: u } = n, c = o.filled && u !== "trail";
  let f = {
    ...eoe({}, n, Hae),
    ...o8(n, { filled: c })
  };
  const d = r.get("symbolOpacity") ?? l.legend.symbolOpacity, h = r.get("symbolFillColor") ?? l.legend.symbolFillColor, g = r.get("symbolStrokeColor") ?? l.legend.symbolStrokeColor, p = d === void 0 ? R8(a.opacity) ?? o.opacity : void 0;
  if (f.fill) {
    if (i === "fill" || c && i === jn)
      delete f.fill;
    else if (f.fill.field)
      h ? delete f.fill : (f.fill = Ze(l.legend.symbolBaseFillColor ?? "black"), f.fillOpacity = Ze(p ?? 1));
    else if (U(f.fill)) {
      const m = Cv(a.fill ?? a.color) ?? o.fill ?? (c && o.color);
      m && (f.fill = Ze(m));
    }
  }
  if (f.stroke) {
    if (i === "stroke" || !c && i === jn)
      delete f.stroke;
    else if (f.stroke.field || g)
      delete f.stroke;
    else if (U(f.stroke)) {
      const m = dt(Cv(a.stroke || a.color), o.stroke, c ? o.color : void 0);
      m && (f.stroke = { value: m });
    }
  }
  if (i !== Rs) {
    const m = H(t) && P8(n, r, t);
    m ? f.opacity = [
      { test: m, ...Ze(p ?? 1) },
      Ze(l.legend.unselectedOpacity)
    ] : p && (f.opacity = Ze(p));
  }
  return f = { ...f, ...e }, Ge(f) ? void 0 : f;
}
function gfe(e, { model: t, legendType: n, legendCmpt: i }) {
  if (n !== "gradient")
    return;
  const { config: r, markDef: s, encoding: o } = t;
  let a = {};
  const u = (i.get("gradientOpacity") ?? r.legend.gradientOpacity) === void 0 ? R8(o.opacity) || s.opacity : void 0;
  return u && (a.opacity = Ze(u)), a = { ...a, ...e }, Ge(a) ? void 0 : a;
}
function pfe(e, { fieldOrDatumDef: t, model: n, channel: i, legendCmpt: r }) {
  const s = n.legend(i) || {}, o = n.config, a = H(t) ? P8(n, r, t) : void 0, l = a ? [{ test: a, value: 1 }, { value: o.legend.unselectedOpacity }] : void 0, { format: u, formatType: c } = s;
  let f;
  Ga(c) ? f = Vi({
    fieldOrDatumDef: t,
    field: "datum.value",
    format: u,
    formatType: c,
    config: o
  }) : u === void 0 && c === void 0 && o.customFormatTypes && (t.type === "quantitative" && o.numberFormatType ? f = Vi({
    fieldOrDatumDef: t,
    field: "datum.value",
    format: o.numberFormat,
    formatType: o.numberFormatType,
    config: o
  }) : t.type === "temporal" && o.timeFormatType && H(t) && t.timeUnit === void 0 && (f = Vi({
    fieldOrDatumDef: t,
    field: "datum.value",
    format: o.timeFormat,
    formatType: o.timeFormatType,
    config: o
  })));
  const d = {
    ...l ? { opacity: l } : {},
    ...f ? { text: f } : {},
    ...e
  };
  return Ge(d) ? void 0 : d;
}
function mfe(e, { legendCmpt: t }) {
  const n = t.get("selections");
  return n != null && n.length ? { ...e, fill: { value: "transparent" } } : e;
}
function R8(e) {
  return L8(e, (t, n) => Math.max(t, n.value));
}
function Cv(e) {
  return L8(e, (t, n) => dt(t, n.value));
}
function L8(e, t) {
  if (fle(e))
    return ee(e.condition).reduce(t, e.value);
  if (er(e))
    return e.value;
}
function P8(e, t, n) {
  const i = t.get("selections");
  if (!(i != null && i.length))
    return;
  const r = X(n.field);
  return i.map((s) => `(!length(data(${X(tt(s) + Ya)})) || (${s}[${r}] && indexof(${s}[${r}], datum.value) >= 0))`).join(" || ");
}
const EM = {
  direction: ({ direction: e }) => e,
  format: ({ fieldOrDatumDef: e, legend: t, config: n }) => {
    const { format: i, formatType: r } = t;
    return Z4(e, e.type, i, r, n, !1);
  },
  formatType: ({ legend: e, fieldOrDatumDef: t, scaleType: n }) => {
    const { formatType: i } = e;
    return eL(i, t, n);
  },
  gradientLength: (e) => {
    const { legend: t, legendConfig: n } = e;
    return t.gradientLength ?? n.gradientLength ?? Efe(e);
  },
  labelOverlap: ({ legend: e, legendConfig: t, scaleType: n }) => e.labelOverlap ?? t.labelOverlap ?? Sfe(n),
  symbolType: ({ legend: e, markDef: t, channel: n, encoding: i }) => e.symbolType ?? bfe(t.type, n, i.shape, t.shape),
  title: ({ fieldOrDatumDef: e, config: t }) => Yl(e, t, { allowDisabling: !0 }),
  type: ({ legendType: e, scaleType: t, channel: n }) => {
    if (Vl(n) && Gi(t)) {
      if (e === "gradient")
        return;
    } else if (e === "symbol")
      return;
    return e;
  },
  values: ({ fieldOrDatumDef: e, legend: t }) => yfe(t, e)
};
function yfe(e, t) {
  const n = e.values;
  if (U(n))
    return hL(t, n);
  if (oe(n))
    return n;
}
function bfe(e, t, n, i) {
  if (t !== "shape") {
    const r = Cv(n) ?? i;
    if (r)
      return r;
  }
  switch (e) {
    case "bar":
    case "rect":
    case "image":
    case "square":
      return "square";
    case "line":
    case "trail":
    case "rule":
      return "stroke";
    case "arc":
    case "point":
    case "circle":
    case "tick":
    case "geoshape":
    case "area":
    case "text":
      return "circle";
  }
}
function vfe(e) {
  const { legend: t } = e;
  return dt(t.type, xfe(e));
}
function xfe({ channel: e, timeUnit: t, scaleType: n }) {
  if (Vl(e)) {
    if (Me(["quarter", "month", "day"], t))
      return "symbol";
    if (Gi(n))
      return "gradient";
  }
  return "symbol";
}
function wfe({ legendConfig: e, legendType: t, orient: n, legend: i }) {
  return i.direction ?? e[t ? "gradientDirection" : "symbolDirection"] ?? _fe(n, t);
}
function _fe(e, t) {
  switch (e) {
    case "top":
    case "bottom":
      return "horizontal";
    case "left":
    case "right":
    case "none":
    case void 0:
      return;
    default:
      return t === "gradient" ? "horizontal" : void 0;
  }
}
function Efe({ legendConfig: e, model: t, direction: n, orient: i, scaleType: r }) {
  const { gradientHorizontalMaxLength: s, gradientHorizontalMinLength: o, gradientVerticalMaxLength: a, gradientVerticalMinLength: l } = e;
  if (Gi(r))
    return n === "horizontal" ? i === "top" || i === "bottom" ? SM(t, "width", o, s) : o : SM(t, "height", l, a);
}
function SM(e, t, n, i) {
  return { signal: `clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${i})` };
}
function Sfe(e) {
  if (Me(["quantile", "threshold", "log", "symlog"], e))
    return "greedy";
}
function I8(e) {
  const t = at(e) ? kfe(e) : Mfe(e);
  return e.component.legends = t, t;
}
function kfe(e) {
  const { encoding: t } = e, n = {};
  for (const i of [jn, ...DL]) {
    const r = wt(t[i]);
    !r || !e.getScaleComponent(i) || i === Un && H(r) && r.type === Ju || (n[i] = $fe(e, i));
  }
  return n;
}
function Afe(e, t) {
  const n = e.scaleName(t);
  if (e.mark === "trail") {
    if (t === "color")
      return { stroke: n };
    if (t === "size")
      return { strokeWidth: n };
  }
  return t === "color" ? e.markDef.filled ? { fill: n } : { stroke: n } : { [t]: n };
}
function Cfe(e, t, n, i) {
  switch (t) {
    case "disable":
      return n !== void 0;
    case "values":
      return !!(n != null && n.values);
    case "title":
      if (t === "title" && e === (i == null ? void 0 : i.title))
        return !0;
  }
  return e === (n || {})[t];
}
function $fe(e, t) {
  var _;
  let n = e.legend(t);
  const { markDef: i, encoding: r, config: s } = e, o = s.legend, a = new dfe({}, Afe(e, t));
  Pce(e, t, a);
  const l = n !== void 0 ? !n : o.disable;
  if (a.set("disable", l, n !== void 0), l)
    return a;
  n = n || {};
  const u = e.getScaleComponent(t).get("type"), c = wt(r[t]), f = H(c) ? (_ = Dt(c.timeUnit)) == null ? void 0 : _.unit : void 0, d = n.orient || s.legend.orient || "right", h = vfe({ legend: n, channel: t, timeUnit: f, scaleType: u }), g = wfe({ legend: n, legendType: h, orient: d, legendConfig: o }), p = {
    legend: n,
    channel: t,
    model: e,
    markDef: i,
    encoding: r,
    fieldOrDatumDef: c,
    legendConfig: o,
    config: s,
    scaleType: u,
    orient: d,
    legendType: h,
    direction: g
  };
  for (const x of D8) {
    if (h === "gradient" && x.startsWith("symbol") || h === "symbol" && x.startsWith("gradient"))
      continue;
    const S = x in EM ? EM[x](p) : n[x];
    if (S !== void 0) {
      const E = Cfe(S, x, n, e.fieldDef(t));
      (E || s.legend[x] === void 0) && a.set(x, S, E);
    }
  }
  const m = (n == null ? void 0 : n.encoding) ?? {}, y = a.get("selections"), b = {}, v = { fieldOrDatumDef: c, model: e, channel: t, legendCmpt: a, legendType: h };
  for (const x of ["labels", "legend", "title", "symbols", "gradient", "entries"]) {
    const S = O8(m[x] ?? {}, e), E = x in _M ? _M[x](S, v) : S;
    E !== void 0 && !Ge(E) && (b[x] = {
      ...y != null && y.length && H(c) ? { name: `${tt(c.field)}_legend_${x}` } : {},
      ...y != null && y.length ? { interactive: !!y } : {},
      update: E
    });
  }
  return Ge(b) || a.set("encode", b, !!(n != null && n.encoding)), a;
}
function Mfe(e) {
  const { legends: t, resolve: n } = e.component;
  for (const i of e.children) {
    I8(i);
    for (const r of q(i.component.legends))
      n.legend[r] = KE(e.component.resolve, r), n.legend[r] === "shared" && (t[r] = z8(t[r], i.component.legends[r]), t[r] || (n.legend[r] = "independent", delete t[r]));
  }
  for (const i of q(t))
    for (const r of e.children)
      r.component.legends[i] && n.legend[i] === "shared" && delete r.component.legends[i];
  return t;
}
function z8(e, t) {
  var s, o, a, l;
  if (!e)
    return t.clone();
  const n = e.getWithExplicit("orient"), i = t.getWithExplicit("orient");
  if (n.explicit && i.explicit && n.value !== i.value)
    return;
  let r = !1;
  for (const u of D8) {
    const c = Co(
      e.getWithExplicit(u),
      t.getWithExplicit(u),
      u,
      "legend",
      // Tie breaker function
      (f, d) => {
        switch (u) {
          case "symbolType":
            return Ffe(f, d);
          case "title":
            return x4(f, d);
          case "type":
            return r = !0, Gn("symbol");
        }
        return A0(f, d, u, "legend");
      }
    );
    e.setWithExplicit(u, c);
  }
  return r && ((o = (s = e.implicit) == null ? void 0 : s.encode) != null && o.gradient && xp(e.implicit, ["encode", "gradient"]), (l = (a = e.explicit) == null ? void 0 : a.encode) != null && l.gradient && xp(e.explicit, ["encode", "gradient"])), e;
}
function Ffe(e, t) {
  return t.value === "circle" ? t : e;
}
function Tfe(e, t, n, i) {
  var r, s;
  e.encode ?? (e.encode = {}), (r = e.encode)[t] ?? (r[t] = {}), (s = e.encode[t]).update ?? (s.update = {}), e.encode[t].update[n] = i;
}
function B8(e) {
  const t = e.component.legends, n = {};
  for (const r of q(t)) {
    const s = e.getScaleComponent(r), o = Ve(s.get("domains"));
    if (n[o])
      for (const a of n[o])
        z8(a, t[r]) || n[o].push(t[r]);
    else
      n[o] = [t[r].clone()];
  }
  return Wt(n).flat().map((r) => Ofe(r, e.config)).filter((r) => r !== void 0);
}
function Ofe(e, t) {
  var o, a, l;
  const { disable: n, labelExpr: i, selections: r, ...s } = e.combine();
  if (!n) {
    if (t.aria === !1 && s.aria == null && (s.aria = !1), (o = s.encode) != null && o.symbols) {
      const u = s.encode.symbols.update;
      u.fill && u.fill.value !== "transparent" && !u.stroke && !s.stroke && (u.stroke = { value: "transparent" });
      for (const c of DL)
        s[c] && delete u[c];
    }
    if (s.title || delete s.title, i !== void 0) {
      let u = i;
      (l = (a = s.encode) == null ? void 0 : a.labels) != null && l.update && oe(s.encode.labels.update.text) && (u = ja(i, "datum.label", s.encode.labels.update.text.signal)), Tfe(s, "labels", "text", { signal: u });
    }
    return s;
  }
}
function Nfe(e) {
  return nc(e) || nS(e) ? Dfe(e) : j8(e);
}
function Dfe(e) {
  return e.children.reduce((t, n) => t.concat(n.assembleProjections()), j8(e));
}
function j8(e) {
  const t = e.component.projection;
  if (!t || t.merged)
    return [];
  const n = t.combine(), { name: i } = n;
  if (t.data) {
    const r = {
      signal: `[${t.size.map((o) => o.signal).join(", ")}]`
    }, s = t.data.reduce((o, a) => {
      const l = oe(a) ? a.signal : `data('${e.lookupDataSource(a)}')`;
      return Me(o, l) || o.push(l), o;
    }, []);
    if (s.length <= 0)
      throw new Error("Projection's fit didn't find any data sources");
    return [
      {
        name: i,
        size: r,
        fit: {
          signal: s.length > 1 ? `[${s.join(", ")}]` : s[0]
        },
        ...n
      }
    ];
  } else
    return [
      {
        name: i,
        translate: { signal: "[width / 2, height / 2]" },
        // parameters, overwrite default translate if specified
        ...n
      }
    ];
}
const Rfe = [
  "type",
  "clipAngle",
  "clipExtent",
  "center",
  "rotate",
  "precision",
  "reflectX",
  "reflectY",
  "coefficient",
  "distance",
  "fraction",
  "lobes",
  "parallel",
  "radius",
  "ratio",
  "spacing",
  "tilt"
];
class U8 extends Is {
  constructor(t, n, i, r) {
    super(
      { ...n },
      // all explicit properties of projection
      { name: t }
      // name as initial implicit property
    ), this.specifiedProjection = n, this.size = i, this.data = r, this.merged = !1;
  }
  /**
   * Whether the projection parameters should fit provided data.
   */
  get isFit() {
    return !!this.data;
  }
}
function q8(e) {
  e.component.projection = at(e) ? Lfe(e) : zfe(e);
}
function Lfe(e) {
  if (e.hasProjection) {
    const t = Fn(e.specifiedProjection), n = !(t && (t.scale != null || t.translate != null)), i = n ? [e.getSizeSignalRef("width"), e.getSizeSignalRef("height")] : void 0, r = n ? Pfe(e) : void 0, s = new U8(e.projectionName(!0), {
      ...Fn(e.config.projection) ?? {},
      ...t ?? {}
    }, i, r);
    return s.get("type") || s.set("type", "equalEarth", !1), s;
  }
}
function Pfe(e) {
  const t = [], { encoding: n } = e;
  for (const i of [
    [lr, ar],
    [$i, ur]
  ])
    (wt(n[i[0]]) || wt(n[i[1]])) && t.push({
      signal: e.getName(`geojson_${t.length}`)
    });
  return e.channelHasField(Un) && e.typedFieldDef(Un).type === Ju && t.push({
    signal: e.getName(`geojson_${t.length}`)
  }), t.length === 0 && t.push(e.requestDataName(Ke.Main)), t;
}
function Ife(e, t) {
  const n = U_(Rfe, (r) => !!(!ce(e.explicit, r) && !ce(t.explicit, r) || ce(e.explicit, r) && ce(t.explicit, r) && // some properties might be signals or objects and require hashing for comparison
  Qn(e.get(r), t.get(r))));
  if (Qn(e.size, t.size)) {
    if (n)
      return e;
    if (Qn(e.explicit, {}))
      return t;
    if (Qn(t.explicit, {}))
      return e;
  }
  return null;
}
function zfe(e) {
  if (e.children.length === 0)
    return;
  let t;
  for (const i of e.children)
    q8(i);
  const n = U_(e.children, (i) => {
    const r = i.component.projection;
    if (r)
      if (t) {
        const s = Ife(t, r);
        return s && (t = s), !!s;
      } else
        return t = r, !0;
    else
      return !0;
  });
  if (t && n) {
    const i = e.projectionName(!0), r = new U8(i, t.specifiedProjection, t.size, me(t.data));
    for (const s of e.children) {
      const o = s.component.projection;
      o && (o.isFit && r.data.push(...s.component.projection.data), s.renameProjection(o.get("name"), i), o.merged = !0);
    }
    return r;
  }
}
function Bfe(e, t, n, i) {
  if (Id(t, n)) {
    const r = at(e) ? e.axis(n) ?? e.legend(n) ?? {} : {}, s = J(t, { expr: "datum" }), o = J(t, { expr: "datum", binSuffix: "end" });
    return {
      formulaAs: J(t, { binSuffix: "range", forAs: !0 }),
      formula: Rd(s, o, r.format, r.formatType, i)
    };
  }
  return {};
}
function W8(e, t) {
  return `${d4(e)}_${t}`;
}
function jfe(e, t) {
  return {
    signal: e.getName(`${t}_bins`),
    extentSignal: e.getName(`${t}_extent`)
  };
}
function JE(e, t, n) {
  const i = x0(n, void 0) ?? {}, r = W8(i, t);
  return e.getName(`${r}_bins`);
}
function Ufe(e) {
  return "as" in e;
}
function kM(e, t, n) {
  let i, r;
  Ufe(e) ? i = te(e.as) ? [e.as, `${e.as}_end`] : [e.as[0], e.as[1]] : i = [J(e, { forAs: !0 }), J(e, { binSuffix: "end", forAs: !0 })];
  const s = { ...x0(t, void 0) }, o = W8(s, e.field), { signal: a, extentSignal: l } = jfe(n, o);
  if (u0(s.extent)) {
    const c = s.extent;
    r = _8(n, c.param, c), delete s.extent;
  }
  const u = {
    bin: s,
    field: e.field,
    as: [i],
    ...a ? { signal: a } : {},
    ...l ? { extentSignal: l } : {},
    ...r ? { span: r } : {}
  };
  return { key: o, binComponent: u };
}
class Ar extends He {
  clone() {
    return new Ar(null, me(this.bins));
  }
  constructor(t, n) {
    super(t), this.bins = n;
  }
  static makeFromEncoding(t, n) {
    const i = n.reduceFieldDef((r, s, o) => {
      if (En(s) && Je(s.bin)) {
        const { key: a, binComponent: l } = kM(s, s.bin, n);
        r[a] = {
          ...l,
          ...r[a],
          ...Bfe(n, s, o, n.config)
        };
      }
      return r;
    }, {});
    return Ge(i) ? null : new Ar(t, i);
  }
  /**
   * Creates a bin node from BinTransform.
   * The optional parameter should provide
   */
  static makeFromTransform(t, n, i) {
    const { key: r, binComponent: s } = kM(n, n.bin, i);
    return new Ar(t, {
      [r]: s
    });
  }
  /**
   * Merge bin nodes. This method either integrates the bin config from the other node
   * or if this node already has a bin config, renames the corresponding signal in the model.
   */
  merge(t, n) {
    for (const i of q(t.bins))
      i in this.bins ? (n(t.bins[i].signal, this.bins[i].signal), this.bins[i].as = xr([...this.bins[i].as, ...t.bins[i].as], $e)) : this.bins[i] = t.bins[i];
    for (const i of t.children)
      t.removeChild(i), i.parent = this;
    t.remove();
  }
  producedFields() {
    return new Set(Wt(this.bins).map((t) => t.as).flat(2));
  }
  dependentFields() {
    return new Set(Wt(this.bins).map((t) => t.field));
  }
  hash() {
    return `Bin ${$e(this.bins)}`;
  }
  assemble() {
    return Wt(this.bins).flatMap((t) => {
      const n = [], [i, ...r] = t.as, { extent: s, ...o } = t.bin, a = {
        type: "bin",
        field: Ci(t.field),
        as: i,
        signal: t.signal,
        ...u0(s) ? { extent: null } : { extent: s },
        ...t.span ? { span: { signal: `span(${t.span})` } } : {},
        ...o
      };
      !s && t.extentSignal && (n.push({
        type: "extent",
        field: Ci(t.field),
        signal: t.extentSignal
      }), a.extent = { signal: t.extentSignal }), n.push(a);
      for (const l of r)
        for (let u = 0; u < 2; u++)
          n.push({
            type: "formula",
            expr: J({ field: i[u] }, { expr: "datum" }),
            as: l[u]
          });
      return t.formula && n.push({
        type: "formula",
        expr: t.formula,
        as: t.formulaAs
      }), n;
    });
  }
}
function qfe(e, t, n, i) {
  var s;
  const r = at(i) ? i.encoding[Gr(t)] : void 0;
  if (En(n) && at(i) && sL(n, r, i.markDef, i.config)) {
    e.add(J(n, {})), e.add(J(n, { suffix: "end" }));
    const { mark: o, markDef: a, config: l } = i, u = Ao({ fieldDef: n, markDef: a, config: l });
    Vf(o) && u !== 0.5 && ht(t) && (e.add(J(n, { suffix: C0 })), e.add(J(n, { suffix: $0 }))), n.bin && Id(n, t) && e.add(J(n, { binSuffix: "range" }));
  } else if (n4(t)) {
    const o = t4(t);
    e.add(i.getName(o));
  } else
    e.add(J(n));
  return dl(n) && Nae((s = n.scale) == null ? void 0 : s.range) && e.add(n.scale.range.field), e;
}
function Wfe(e, t) {
  for (const n of q(t)) {
    const i = t[n];
    for (const r of q(i))
      n in e ? e[n][r] = /* @__PURE__ */ new Set([...e[n][r] ?? [], ...i[r]]) : e[n] = { [r]: i[r] };
  }
}
class Xi extends He {
  clone() {
    return new Xi(null, new Set(this.dimensions), me(this.measures));
  }
  /**
   * @param dimensions string set for dimensions
   * @param measures dictionary mapping field name => dict of aggregation functions and names to use
   */
  constructor(t, n, i) {
    super(t), this.dimensions = n, this.measures = i;
  }
  get groupBy() {
    return this.dimensions;
  }
  static makeFromEncoding(t, n) {
    let i = !1;
    n.forEachFieldDef((o) => {
      o.aggregate && (i = !0);
    });
    const r = {}, s = /* @__PURE__ */ new Set();
    return !i || (n.forEachFieldDef((o, a) => {
      const { aggregate: l, field: u } = o;
      if (l)
        if (l === "count")
          r["*"] ?? (r["*"] = {}), r["*"].count = /* @__PURE__ */ new Set([J(o, { forAs: !0 })]);
        else {
          if (Ss(l) || qo(l)) {
            const c = Ss(l) ? "argmin" : "argmax", f = l[c];
            r[f] ?? (r[f] = {}), r[f][c] = /* @__PURE__ */ new Set([J({ op: c, field: f }, { forAs: !0 })]);
          } else
            r[u] ?? (r[u] = {}), r[u][l] = /* @__PURE__ */ new Set([J(o, { forAs: !0 })]);
          Ls(a) && n.scaleDomain(a) === "unaggregated" && (r[u] ?? (r[u] = {}), r[u].min = /* @__PURE__ */ new Set([J({ field: u, aggregate: "min" }, { forAs: !0 })]), r[u].max = /* @__PURE__ */ new Set([J({ field: u, aggregate: "max" }, { forAs: !0 })]));
        }
      else
        qfe(s, a, o, n);
    }), s.size + q(r).length === 0) ? null : new Xi(t, s, r);
  }
  static makeFromTransform(t, n) {
    const i = /* @__PURE__ */ new Set(), r = {};
    for (const s of n.aggregate) {
      const { op: o, field: a, as: l } = s;
      o && (o === "count" ? (r["*"] ?? (r["*"] = {}), r["*"].count = /* @__PURE__ */ new Set([l || J(s, { forAs: !0 })])) : (r[a] ?? (r[a] = {}), r[a][o] = /* @__PURE__ */ new Set([l || J(s, { forAs: !0 })])));
    }
    for (const s of n.groupby ?? [])
      i.add(s);
    return i.size + q(r).length === 0 ? null : new Xi(t, i, r);
  }
  merge(t) {
    return V6(this.dimensions, t.dimensions) ? (Wfe(this.measures, t.measures), !0) : (rae("different dimensions, cannot merge"), !1);
  }
  addDimensions(t) {
    t.forEach(this.dimensions.add, this.dimensions);
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([...this.dimensions, ...q(this.measures)]);
  }
  producedFields() {
    const t = /* @__PURE__ */ new Set();
    for (const n of q(this.measures))
      for (const i of q(this.measures[n])) {
        const r = this.measures[n][i];
        r.size === 0 ? t.add(`${i}_${n}`) : r.forEach(t.add, t);
      }
    return t;
  }
  hash() {
    return `Aggregate ${$e({ dimensions: this.dimensions, measures: this.measures })}`;
  }
  assemble() {
    const t = [], n = [], i = [];
    for (const s of q(this.measures))
      for (const o of q(this.measures[s]))
        for (const a of this.measures[s][o])
          i.push(a), t.push(o), n.push(s === "*" ? null : Ci(s));
    return {
      type: "aggregate",
      groupby: [...this.dimensions].map(Ci),
      ops: t,
      fields: n,
      as: i
    };
  }
}
class ec extends He {
  /**
   * @param model The facet model.
   * @param name The name that this facet source will have.
   * @param data The source data for this facet data.
   */
  constructor(t, n, i, r) {
    super(t), this.model = n, this.name = i, this.data = r;
    for (const s of yi) {
      const o = n.facet[s];
      if (o) {
        const { bin: a, sort: l } = o;
        this[s] = {
          name: n.getName(`${s}_domain`),
          fields: [J(o), ...Je(a) ? [J(o, { binSuffix: "end" })] : []],
          ...Sr(l) ? { sortField: l } : U(l) ? { sortIndexField: Tu(o, s) } : {}
        };
      }
    }
    this.childModel = n.child;
  }
  hash() {
    let t = "Facet";
    for (const n of yi)
      this[n] && (t += ` ${n.charAt(0)}:${$e(this[n])}`);
    return t;
  }
  get fields() {
    var n;
    const t = [];
    for (const i of yi)
      (n = this[i]) != null && n.fields && t.push(...this[i].fields);
    return t;
  }
  dependentFields() {
    const t = new Set(this.fields);
    for (const n of yi)
      this[n] && (this[n].sortField && t.add(this[n].sortField.field), this[n].sortIndexField && t.add(this[n].sortIndexField));
    return t;
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  /**
   * The name to reference this source is its name.
   */
  getSource() {
    return this.name;
  }
  getChildIndependentFieldsWithStep() {
    const t = {};
    for (const n of Vr) {
      const i = this.childModel.component.scales[n];
      if (i && !i.merged) {
        const r = i.get("type"), s = i.get("range");
        if (Rt(r) && Wo(s)) {
          const o = N0(this.childModel, n), a = tS(o);
          a ? t[n] = a : G(nE(n));
        }
      }
    }
    return t;
  }
  assembleRowColumnHeaderData(t, n, i) {
    const r = { row: "y", column: "x", facet: void 0 }[t], s = [], o = [], a = [];
    r && i && i[r] && (n ? (s.push(`distinct_${i[r]}`), o.push("max")) : (s.push(i[r]), o.push("distinct")), a.push(`distinct_${i[r]}`));
    const { sortField: l, sortIndexField: u } = this[t];
    if (l) {
      const { op: c = m0, field: f } = l;
      s.push(f), o.push(c), a.push(J(l, { forAs: !0 }));
    } else
      u && (s.push(u), o.push("max"), a.push(u));
    return {
      name: this[t].name,
      // Use data from the crossed one if it exist
      source: n ?? this.data,
      transform: [
        {
          type: "aggregate",
          groupby: this[t].fields,
          ...s.length ? {
            fields: s,
            ops: o,
            as: a
          } : {}
        }
      ]
    };
  }
  assembleFacetHeaderData(t) {
    var l;
    const { columns: n } = this.model.layout, { layoutHeaders: i } = this.model.component, r = [], s = {};
    for (const u of VE) {
      for (const c of YE) {
        const f = (i[u] && i[u][c]) ?? [];
        for (const d of f)
          if (((l = d.axes) == null ? void 0 : l.length) > 0) {
            s[u] = !0;
            break;
          }
      }
      if (s[u]) {
        const c = `length(data("${this.facet.name}"))`, f = u === "row" ? n ? { signal: `ceil(${c} / ${n})` } : 1 : n ? { signal: `min(${c}, ${n})` } : { signal: c };
        r.push({
          name: `${this.facet.name}_${u}`,
          transform: [
            {
              type: "sequence",
              start: 0,
              stop: f
            }
          ]
        });
      }
    }
    const { row: o, column: a } = s;
    return (o || a) && r.unshift(this.assembleRowColumnHeaderData("facet", null, t)), r;
  }
  assemble() {
    const t = [];
    let n = null;
    const i = this.getChildIndependentFieldsWithStep(), { column: r, row: s, facet: o } = this;
    if (r && s && (i.x || i.y)) {
      n = `cross_${this.column.name}_${this.row.name}`;
      const a = [].concat(i.x ?? [], i.y ?? []), l = a.map(() => "distinct");
      t.push({
        name: n,
        source: this.data,
        transform: [
          {
            type: "aggregate",
            groupby: this.fields,
            fields: a,
            ops: l
          }
        ]
      });
    }
    for (const a of [ys, ms])
      this[a] && t.push(this.assembleRowColumnHeaderData(a, n, i));
    if (o) {
      const a = this.assembleFacetHeaderData(i);
      a && t.push(...a);
    }
    return t;
  }
}
function AM(e) {
  return e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e;
}
function Hfe(e, t) {
  const n = H_(e);
  if (t === "number")
    return `toNumber(${n})`;
  if (t === "boolean")
    return `toBoolean(${n})`;
  if (t === "string")
    return `toString(${n})`;
  if (t === "date")
    return `toDate(${n})`;
  if (t === "flatten")
    return n;
  if (t.startsWith("date:")) {
    const i = AM(t.slice(5, t.length));
    return `timeParse(${n},'${i}')`;
  } else if (t.startsWith("utc:")) {
    const i = AM(t.slice(4, t.length));
    return `utcParse(${n},'${i}')`;
  } else
    return G(hoe(t)), null;
}
function Gfe(e) {
  const t = {};
  return tg(e.filter, (n) => {
    if (P4(n)) {
      let i = null;
      oE(n) ? i = Xn(n.equal) : lE(n) ? i = Xn(n.lte) : aE(n) ? i = Xn(n.lt) : uE(n) ? i = Xn(n.gt) : cE(n) ? i = Xn(n.gte) : fE(n) ? i = n.range[0] : dE(n) && (i = (n.oneOf ?? n.in)[0]), i && (cl(i) ? t[n.field] = "date" : Re(i) ? t[n.field] = "number" : te(i) && (t[n.field] = "string")), n.timeUnit && (t[n.field] = "date");
    }
  }), t;
}
function Vfe(e) {
  const t = {};
  function n(i) {
    Cu(i) ? t[i.field] = "date" : i.type === "quantitative" && Hse(i.aggregate) ? t[i.field] = "number" : xu(i.field) > 1 ? i.field in t || (t[i.field] = "flatten") : dl(i) && Sr(i.sort) && xu(i.sort.field) > 1 && (i.sort.field in t || (t[i.sort.field] = "flatten"));
  }
  if ((at(e) || Ki(e)) && e.forEachFieldDef((i, r) => {
    if (En(i))
      n(i);
    else {
      const s = ll(r), o = e.fieldDef(s);
      n({
        ...i,
        type: o.type
      });
    }
  }), at(e)) {
    const { mark: i, markDef: r, encoding: s } = e;
    if (Ho(i) && // No need to sort by dimension if we have a connected scatterplot (order channel is present)
    !e.encoding.order) {
      const o = r.orient === "horizontal" ? "y" : "x", a = s[o];
      H(a) && a.type === "quantitative" && !(a.field in t) && (t[a.field] = "number");
    }
  }
  return t;
}
function Yfe(e) {
  const t = {};
  if (at(e) && e.component.selection)
    for (const n of q(e.component.selection)) {
      const i = e.component.selection[n];
      for (const r of i.project.items)
        !r.channel && xu(r.field) > 1 && (t[r.field] = "flatten");
    }
  return t;
}
class tn extends He {
  clone() {
    return new tn(null, me(this._parse));
  }
  constructor(t, n) {
    super(t), this._parse = n;
  }
  hash() {
    return `Parse ${$e(this._parse)}`;
  }
  /**
   * Creates a parse node from a data.format.parse and updates ancestorParse.
   */
  static makeExplicit(t, n, i) {
    var o;
    let r = {};
    const s = n.data;
    return !co(s) && ((o = s == null ? void 0 : s.format) != null && o.parse) && (r = s.format.parse), this.makeWithAncestors(t, r, {}, i);
  }
  /**
   * Creates a parse node from "explicit" parse and "implicit" parse and updates ancestorParse.
   */
  static makeWithAncestors(t, n, i, r) {
    for (const a of q(i)) {
      const l = r.getWithExplicit(a);
      l.value !== void 0 && (l.explicit || l.value === i[a] || l.value === "derived" || i[a] === "flatten" ? delete i[a] : G(L$(a, i[a], l.value)));
    }
    for (const a of q(n)) {
      const l = r.get(a);
      l !== void 0 && (l === n[a] ? delete n[a] : G(L$(a, n[a], l)));
    }
    const s = new Is(n, i);
    r.copyAll(s);
    const o = {};
    for (const a of q(s.combine())) {
      const l = s.get(a);
      l !== null && (o[a] = l);
    }
    return q(o).length === 0 || r.parseNothing ? null : new tn(t, o);
  }
  get parse() {
    return this._parse;
  }
  merge(t) {
    this._parse = { ...this._parse, ...t.parse }, t.remove();
  }
  /**
   * Assemble an object for Vega's format.parse property.
   */
  assembleFormatParse() {
    const t = {};
    for (const n of q(this._parse)) {
      const i = this._parse[n];
      xu(n) === 1 && (t[n] = i);
    }
    return t;
  }
  // format parse depends and produces all fields in its parse
  producedFields() {
    return new Set(q(this._parse));
  }
  dependentFields() {
    return new Set(q(this._parse));
  }
  assembleTransforms(t = !1) {
    return q(this._parse).filter((n) => t ? xu(n) > 1 : !0).map((n) => {
      const i = Hfe(n, this._parse[n]);
      return i ? {
        type: "formula",
        expr: i,
        as: G_(n)
        // Vega output is always flattened
      } : null;
    }).filter((n) => n !== null);
  }
}
class Fo extends He {
  clone() {
    return new Fo(null);
  }
  constructor(t) {
    super(t);
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
    return /* @__PURE__ */ new Set([tr]);
  }
  hash() {
    return "Identifier";
  }
  assemble() {
    return { type: "identifier", as: tr };
  }
}
class jd extends He {
  clone() {
    return new jd(null, this.params);
  }
  constructor(t, n) {
    super(t), this.params = n;
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
  }
  hash() {
    return `Graticule ${$e(this.params)}`;
  }
  assemble() {
    return {
      type: "graticule",
      ...this.params === !0 ? {} : this.params
    };
  }
}
class Ud extends He {
  clone() {
    return new Ud(null, this.params);
  }
  constructor(t, n) {
    super(t), this.params = n;
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
    return /* @__PURE__ */ new Set([this.params.as ?? "data"]);
  }
  hash() {
    return `Hash ${$e(this.params)}`;
  }
  assemble() {
    return {
      type: "sequence",
      ...this.params
    };
  }
}
class Xa extends He {
  constructor(t) {
    super(null), t ?? (t = { name: "source" });
    let n;
    if (co(t) || (n = t.format ? { ...Nn(t.format, ["parse"]) } : {}), Yf(t))
      this._data = { values: t.values };
    else if ($u(t)) {
      if (this._data = { url: t.url }, !n.type) {
        let i = /(?:\.([^.]+))?$/.exec(t.url)[1];
        Me(["json", "csv", "tsv", "dsv", "topojson"], i) || (i = "json"), n.type = i;
      }
    } else
      QL(t) ? this._data = { values: [{ type: "Sphere" }] } : (KL(t) || co(t)) && (this._data = {});
    this._generator = co(t), t.name && (this._name = t.name), n && !Ge(n) && (this._data.format = n);
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
  }
  get data() {
    return this._data;
  }
  hasName() {
    return !!this._name;
  }
  get isGenerator() {
    return this._generator;
  }
  get dataName() {
    return this._name;
  }
  set dataName(t) {
    this._name = t;
  }
  set parent(t) {
    throw new Error("Source nodes have to be roots.");
  }
  remove() {
    throw new Error("Source nodes are roots and cannot be removed.");
  }
  hash() {
    throw new Error("Cannot hash sources");
  }
  assemble() {
    return {
      name: this._name,
      ...this._data,
      transform: []
    };
  }
}
var CM = function(e, t, n, i, r) {
  if (i === "m")
    throw new TypeError("Private method is not writable");
  if (i === "a" && !r)
    throw new TypeError("Private accessor was defined without a setter");
  if (typeof t == "function" ? e !== t || !r : !t.has(e))
    throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return i === "a" ? r.call(e, n) : r ? r.value = n : t.set(e, n), n;
}, Xfe = function(e, t, n, i) {
  if (n === "a" && !i)
    throw new TypeError("Private accessor was defined without a getter");
  if (typeof t == "function" ? e !== t || !i : !t.has(e))
    throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return n === "m" ? i : n === "a" ? i.call(e) : i ? i.value : t.get(e);
}, Qc;
function QE(e) {
  return e instanceof Xa || e instanceof jd || e instanceof Ud;
}
class ZE {
  constructor() {
    Qc.set(this, void 0), CM(this, Qc, !1, "f");
  }
  // Once true, #modified is never set to false
  setModified() {
    CM(this, Qc, !0, "f");
  }
  get modifiedFlag() {
    return Xfe(this, Qc, "f");
  }
}
Qc = /* @__PURE__ */ new WeakMap();
class hl extends ZE {
  /**
   * Compute a map of node depths that we can use to determine a topological sort order.
   */
  getNodeDepths(t, n, i) {
    i.set(t, n);
    for (const r of t.children)
      this.getNodeDepths(r, n + 1, i);
    return i;
  }
  /**
   * Run the optimizer on all nodes starting from the leaves.
   */
  optimize(t) {
    const i = [...this.getNodeDepths(t, 0, /* @__PURE__ */ new Map()).entries()].sort((r, s) => s[1] - r[1]);
    for (const r of i)
      this.run(r[0]);
    return this.modifiedFlag;
  }
}
class eS extends ZE {
  /**
   * Run the optimizer depth first on all nodes starting from the roots.
   */
  optimize(t) {
    this.run(t);
    for (const n of t.children)
      this.optimize(n);
    return this.modifiedFlag;
  }
}
class Kfe extends eS {
  mergeNodes(t, n) {
    const i = n.shift();
    for (const r of n)
      t.removeChild(r), r.parent = i, r.remove();
  }
  run(t) {
    const n = t.children.map((r) => r.hash()), i = {};
    for (let r = 0; r < n.length; r++)
      i[n[r]] === void 0 ? i[n[r]] = [t.children[r]] : i[n[r]].push(t.children[r]);
    for (const r of q(i))
      i[r].length > 1 && (this.setModified(), this.mergeNodes(t, i[r]));
  }
}
class Jfe extends eS {
  constructor(t) {
    super(), this.requiresSelectionId = t && GE(t);
  }
  run(t) {
    t instanceof Fo && (this.requiresSelectionId && (QE(t.parent) || t.parent instanceof Xi || t.parent instanceof tn) || (this.setModified(), t.remove()));
  }
}
class Qfe extends ZE {
  optimize(t) {
    return this.run(t, /* @__PURE__ */ new Set()), this.modifiedFlag;
  }
  run(t, n) {
    let i = /* @__PURE__ */ new Set();
    t instanceof kr && (i = t.producedFields(), q_(i, n) && (this.setModified(), t.removeFormulas(n), t.producedFields.length === 0 && t.remove()));
    for (const r of t.children)
      this.run(r, /* @__PURE__ */ new Set([...n, ...i]));
  }
}
class Zfe extends eS {
  constructor() {
    super();
  }
  run(t) {
    t instanceof xn && !t.isRequired() && (this.setModified(), t.remove());
  }
}
class ede extends hl {
  run(t) {
    if (!QE(t) && !(t.numChildren() > 1)) {
      for (const n of t.children)
        if (n instanceof tn)
          if (t instanceof tn)
            this.setModified(), t.merge(n);
          else {
            if (W_(t.producedFields(), n.dependentFields()))
              continue;
            this.setModified(), n.swapWithParent();
          }
    }
  }
}
class tde extends hl {
  run(t) {
    const n = [...t.children], i = t.children.filter((r) => r instanceof tn);
    if (t.numChildren() > 1 && i.length >= 1) {
      const r = {}, s = /* @__PURE__ */ new Set();
      for (const o of i) {
        const a = o.parse;
        for (const l of q(a))
          l in r ? r[l] !== a[l] && s.add(l) : r[l] = a[l];
      }
      for (const o of s)
        delete r[o];
      if (!Ge(r)) {
        this.setModified();
        const o = new tn(t, r);
        for (const a of n) {
          if (a instanceof tn)
            for (const l of q(r))
              delete a.parse[l];
          t.removeChild(a), a.parent = o, a instanceof tn && q(a.parse).length === 0 && a.remove();
        }
      }
    }
  }
}
class nde extends hl {
  run(t) {
    t instanceof xn || t.numChildren() > 0 || t instanceof ec || t instanceof Xa || (this.setModified(), t.remove());
  }
}
class ide extends hl {
  run(t) {
    const n = t.children.filter((r) => r instanceof kr), i = n.pop();
    for (const r of n)
      this.setModified(), i.merge(r);
  }
}
class rde extends hl {
  run(t) {
    const n = t.children.filter((r) => r instanceof Xi), i = {};
    for (const r of n) {
      const s = $e(r.groupBy);
      s in i || (i[s] = []), i[s].push(r);
    }
    for (const r of q(i)) {
      const s = i[r];
      if (s.length > 1) {
        const o = s.pop();
        for (const a of s)
          o.merge(a) && (t.removeChild(a), a.parent = o, a.remove(), this.setModified());
      }
    }
  }
}
class sde extends hl {
  constructor(t) {
    super(), this.model = t;
  }
  run(t) {
    const n = !(QE(t) || t instanceof Zu || t instanceof tn || t instanceof Fo), i = [], r = [];
    for (const s of t.children)
      s instanceof Ar && (n && !W_(t.producedFields(), s.dependentFields()) ? i.push(s) : r.push(s));
    if (i.length > 0) {
      const s = i.pop();
      for (const o of i)
        s.merge(o, this.model.renameSignal.bind(this.model));
      this.setModified(), t instanceof Ar ? t.merge(s, this.model.renameSignal.bind(this.model)) : s.swapWithParent();
    }
    if (r.length > 1) {
      const s = r.pop();
      for (const o of r)
        s.merge(o, this.model.renameSignal.bind(this.model));
      this.setModified();
    }
  }
}
class ode extends hl {
  run(t) {
    const n = [...t.children];
    if (!Ba(n, (o) => o instanceof xn) || t.numChildren() <= 1)
      return;
    const r = [];
    let s;
    for (const o of n)
      if (o instanceof xn) {
        let a = o;
        for (; a.numChildren() === 1; ) {
          const [l] = a.children;
          if (l instanceof xn)
            a = l;
          else
            break;
        }
        r.push(...a.children), s ? (t.removeChild(o), o.parent = s.parent, s.parent.removeChild(s), s.parent = a, this.setModified()) : s = a;
      } else
        r.push(o);
    if (r.length) {
      this.setModified();
      for (const o of r)
        o.parent.removeChild(o), o.parent = s;
    }
  }
}
class gl extends He {
  clone() {
    return new gl(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n;
  }
  addDimensions(t) {
    this.transform.groupby = xr(this.transform.groupby.concat(t), (n) => n);
  }
  dependentFields() {
    const t = /* @__PURE__ */ new Set();
    return this.transform.groupby && this.transform.groupby.forEach(t.add, t), this.transform.joinaggregate.map((n) => n.field).filter((n) => n !== void 0).forEach(t.add, t), t;
  }
  producedFields() {
    return new Set(this.transform.joinaggregate.map(this.getDefaultName));
  }
  getDefaultName(t) {
    return t.as ?? J(t);
  }
  hash() {
    return `JoinAggregateTransform ${$e(this.transform)}`;
  }
  assemble() {
    const t = [], n = [], i = [];
    for (const s of this.transform.joinaggregate)
      n.push(s.op), i.push(this.getDefaultName(s)), t.push(s.field === void 0 ? null : s.field);
    const r = this.transform.groupby;
    return {
      type: "joinaggregate",
      as: i,
      ops: n,
      fields: t,
      ...r !== void 0 ? { groupby: r } : {}
    };
  }
}
function ade(e) {
  return e.stack.stackBy.reduce((t, n) => {
    const i = n.fieldDef, r = J(i);
    return r && t.push(r), t;
  }, []);
}
function lde(e) {
  return U(e) && e.every((t) => te(t)) && e.length > 1;
}
class vs extends He {
  clone() {
    return new vs(null, me(this._stack));
  }
  constructor(t, n) {
    super(t), this._stack = n;
  }
  static makeFromTransform(t, n) {
    const { stack: i, groupby: r, as: s, offset: o = "zero" } = n, a = [], l = [];
    if (n.sort !== void 0)
      for (const f of n.sort)
        a.push(f.field), l.push(dt(f.order, "ascending"));
    const u = {
      field: a,
      order: l
    };
    let c;
    return lde(s) ? c = s : te(s) ? c = [s, `${s}_end`] : c = [`${n.stack}_start`, `${n.stack}_end`], new vs(t, {
      dimensionFieldDefs: [],
      stackField: i,
      groupby: r,
      offset: o,
      sort: u,
      facetby: [],
      as: c
    });
  }
  static makeFromEncoding(t, n) {
    const i = n.stack, { encoding: r } = n;
    if (!i)
      return null;
    const { groupbyChannels: s, fieldChannel: o, offset: a, impute: l } = i, u = s.map((h) => {
      const g = r[h];
      return Rr(g);
    }).filter((h) => !!h), c = ade(n), f = n.encoding.order;
    let d;
    if (U(f) || H(f))
      d = y4(f);
    else {
      const h = oL(f) ? f.sort : o === "y" ? "descending" : "ascending";
      d = c.reduce((g, p) => (g.field.push(p), g.order.push(h), g), { field: [], order: [] });
    }
    return new vs(t, {
      dimensionFieldDefs: u,
      stackField: n.vgField(o),
      facetby: [],
      stackby: c,
      sort: d,
      offset: a,
      impute: l,
      as: [
        n.vgField(o, { suffix: "start", forAs: !0 }),
        n.vgField(o, { suffix: "end", forAs: !0 })
      ]
    });
  }
  get stack() {
    return this._stack;
  }
  addDimensions(t) {
    this._stack.facetby.push(...t);
  }
  dependentFields() {
    const t = /* @__PURE__ */ new Set();
    return t.add(this._stack.stackField), this.getGroupbyFields().forEach(t.add, t), this._stack.facetby.forEach(t.add, t), this._stack.sort.field.forEach(t.add, t), t;
  }
  producedFields() {
    return new Set(this._stack.as);
  }
  hash() {
    return `Stack ${$e(this._stack)}`;
  }
  getGroupbyFields() {
    const { dimensionFieldDefs: t, impute: n, groupby: i } = this._stack;
    return t.length > 0 ? t.map((r) => r.bin ? n ? [J(r, { binSuffix: "mid" })] : [
      // For binned group by field without impute, we need both bin (start) and bin_end
      J(r, {}),
      J(r, { binSuffix: "end" })
    ] : [J(r)]).flat() : i ?? [];
  }
  assemble() {
    const t = [], { facetby: n, dimensionFieldDefs: i, stackField: r, stackby: s, sort: o, offset: a, impute: l, as: u } = this._stack;
    if (l)
      for (const c of i) {
        const { bandPosition: f = 0.5, bin: d } = c;
        if (d) {
          const h = J(c, { expr: "datum" }), g = J(c, { expr: "datum", binSuffix: "end" });
          t.push({
            type: "formula",
            expr: `${f}*${h}+${1 - f}*${g}`,
            as: J(c, { binSuffix: "mid", forAs: !0 })
          });
        }
        t.push({
          type: "impute",
          field: r,
          groupby: [...s, ...n],
          key: J(c, { binSuffix: "mid" }),
          method: "value",
          value: 0
        });
      }
    return t.push({
      type: "stack",
      groupby: [...this.getGroupbyFields(), ...n],
      field: r,
      sort: o,
      as: u,
      offset: a
    }), t;
  }
}
class tc extends He {
  clone() {
    return new tc(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n;
  }
  addDimensions(t) {
    this.transform.groupby = xr(this.transform.groupby.concat(t), (n) => n);
  }
  dependentFields() {
    const t = /* @__PURE__ */ new Set();
    return (this.transform.groupby ?? []).forEach(t.add, t), (this.transform.sort ?? []).forEach((n) => t.add(n.field)), this.transform.window.map((n) => n.field).filter((n) => n !== void 0).forEach(t.add, t), t;
  }
  producedFields() {
    return new Set(this.transform.window.map(this.getDefaultName));
  }
  getDefaultName(t) {
    return t.as ?? J(t);
  }
  hash() {
    return `WindowTransform ${$e(this.transform)}`;
  }
  assemble() {
    const t = [], n = [], i = [], r = [];
    for (const f of this.transform.window)
      n.push(f.op), i.push(this.getDefaultName(f)), r.push(f.param === void 0 ? null : f.param), t.push(f.field === void 0 ? null : f.field);
    const s = this.transform.frame, o = this.transform.groupby;
    if (s && s[0] === null && s[1] === null && n.every((f) => eE(f)))
      return {
        type: "joinaggregate",
        as: i,
        ops: n,
        fields: t,
        ...o !== void 0 ? { groupby: o } : {}
      };
    const a = [], l = [];
    if (this.transform.sort !== void 0)
      for (const f of this.transform.sort)
        a.push(f.field), l.push(f.order ?? "ascending");
    const u = {
      field: a,
      order: l
    }, c = this.transform.ignorePeers;
    return {
      type: "window",
      params: r,
      as: i,
      ops: n,
      fields: t,
      sort: u,
      ...c !== void 0 ? { ignorePeers: c } : {},
      ...o !== void 0 ? { groupby: o } : {},
      ...s !== void 0 ? { frame: s } : {}
    };
  }
}
function ude(e) {
  function t(n) {
    if (!(n instanceof ec)) {
      const i = n.clone();
      if (i instanceof xn) {
        const r = Mv + i.getSource();
        i.setSource(r), e.model.component.data.outputNodes[r] = i;
      } else
        (i instanceof Xi || i instanceof vs || i instanceof tc || i instanceof gl) && i.addDimensions(e.fields);
      for (const r of n.children.flatMap(t))
        r.parent = i;
      return [i];
    }
    return n.children.flatMap(t);
  }
  return t;
}
function $v(e) {
  if (e instanceof ec)
    if (e.numChildren() === 1 && !(e.children[0] instanceof xn)) {
      const t = e.children[0];
      (t instanceof Xi || t instanceof vs || t instanceof tc || t instanceof gl) && t.addDimensions(e.fields), t.swapWithParent(), $v(e);
    } else {
      const t = e.model.component.data.main;
      H8(t);
      const n = ude(e), i = e.children.map(n).flat();
      for (const r of i)
        r.parent = t;
    }
  else
    e.children.map($v);
}
function H8(e) {
  if (e instanceof xn && e.type === Ke.Main && e.numChildren() === 1) {
    const t = e.children[0];
    t instanceof ec || (t.swapWithParent(), H8(e));
  }
}
const Mv = "scale_", _h = 5;
function Fv(e) {
  for (const t of e) {
    for (const n of t.children)
      if (n.parent !== t)
        return !1;
    if (!Fv(t.children))
      return !1;
  }
  return !0;
}
function Oi(e, t) {
  let n = !1;
  for (const i of t)
    n = e.optimize(i) || n;
  return n;
}
function $M(e, t, n) {
  let i = e.sources, r = !1;
  return r = Oi(new Zfe(), i) || r, r = Oi(new Jfe(t), i) || r, i = i.filter((s) => s.numChildren() > 0), r = Oi(new nde(), i) || r, i = i.filter((s) => s.numChildren() > 0), n || (r = Oi(new ede(), i) || r, r = Oi(new sde(t), i) || r, r = Oi(new Qfe(), i) || r, r = Oi(new tde(), i) || r, r = Oi(new rde(), i) || r, r = Oi(new ide(), i) || r, r = Oi(new Kfe(), i) || r, r = Oi(new ode(), i) || r), e.sources = i, r;
}
function cde(e, t) {
  Fv(e.sources);
  let n = 0, i = 0;
  for (let r = 0; r < _h && $M(e, t, !0); r++)
    n++;
  e.sources.map($v);
  for (let r = 0; r < _h && $M(e, t, !1); r++)
    i++;
  Fv(e.sources), Math.max(n, i) === _h && G(`Maximum optimization runs(${_h}) reached.`);
}
class Ct {
  constructor(t) {
    Object.defineProperty(this, "signal", {
      enumerable: !0,
      get: t
    });
  }
  static fromName(t, n) {
    return new Ct(() => t(n));
  }
}
function G8(e) {
  at(e) ? fde(e) : dde(e);
}
function fde(e) {
  const t = e.component.scales;
  for (const n of q(t)) {
    const i = gde(e, n);
    if (t[n].setWithExplicit("domains", i), mde(e, n), e.component.data.isFaceted) {
      let s = e;
      for (; !Ki(s) && s.parent; )
        s = s.parent;
      if (s.component.resolve.scale[n] === "shared")
        for (const a of i.value)
          ds(a) && (a.data = Mv + a.data.replace(Mv, ""));
    }
  }
}
function dde(e) {
  for (const n of e.children)
    G8(n);
  const t = e.component.scales;
  for (const n of q(t)) {
    let i, r = null;
    for (const s of e.children) {
      const o = s.component.scales[n];
      if (o) {
        i === void 0 ? i = o.getWithExplicit("domains") : i = Co(i, o.getWithExplicit("domains"), "domains", "scale", Tv);
        const a = o.get("selectionExtent");
        r && a && r.param !== a.param && G(uoe), r = a;
      }
    }
    t[n].setWithExplicit("domains", i), r && t[n].set("selectionExtent", r, !0);
  }
}
function hde(e, t, n, i) {
  if (e === "unaggregated") {
    const { valid: r, reason: s } = MM(t, n);
    if (!r) {
      G(s);
      return;
    }
  } else if (e === void 0 && i.useUnaggregatedDomain) {
    const { valid: r } = MM(t, n);
    if (r)
      return "unaggregated";
  }
  return e;
}
function gde(e, t) {
  const n = e.getScaleComponent(t).get("type"), { encoding: i } = e, r = hde(e.scaleDomain(t), e.typedFieldDef(t), n, e.config.scale);
  return r !== e.scaleDomain(t) && (e.specifiedScales[t] = {
    ...e.specifiedScales[t],
    domain: r
  }), t === "x" && wt(i.x2) ? wt(i.x) ? Co(qs(n, r, e, "x"), qs(n, r, e, "x2"), "domain", "scale", Tv) : qs(n, r, e, "x2") : t === "y" && wt(i.y2) ? wt(i.y) ? Co(qs(n, r, e, "y"), qs(n, r, e, "y2"), "domain", "scale", Tv) : qs(n, r, e, "y2") : qs(n, r, e, t);
}
function pde(e, t, n) {
  return e.map((i) => ({ signal: `{data: ${w0(i, { timeUnit: n, type: t })}}` }));
}
function ay(e, t, n) {
  var r;
  const i = (r = Dt(n)) == null ? void 0 : r.unit;
  return t === "temporal" || i ? pde(e, t, i) : [e];
}
function qs(e, t, n, i) {
  const { encoding: r, markDef: s, mark: o, config: a, stack: l } = n, u = wt(r[i]), { type: c } = u, f = u.timeUnit;
  if (Oae(t)) {
    const g = qs(e, void 0, n, i), p = ay(t.unionWith, c, f);
    return pr([...p, ...g.value]);
  } else {
    if (oe(t))
      return pr([t]);
    if (t && t !== "unaggregated" && !W4(t))
      return pr(ay(t, c, f));
  }
  if (l && i === l.fieldChannel) {
    if (l.offset === "normalize")
      return Gn([[0, 1]]);
    const g = n.requestDataName(Ke.Main);
    return Gn([
      {
        data: g,
        field: n.vgField(i, { suffix: "start" })
      },
      {
        data: g,
        field: n.vgField(i, { suffix: "end" })
      }
    ]);
  }
  const d = Ls(i) && H(u) ? yde(n, i, e) : void 0;
  if (Yr(u)) {
    const g = ay([u.datum], c, f);
    return Gn(g);
  }
  const h = u;
  if (t === "unaggregated") {
    const g = n.requestDataName(Ke.Main), { field: p } = u;
    return Gn([
      {
        data: g,
        field: J({ field: p, aggregate: "min" })
      },
      {
        data: g,
        field: J({ field: p, aggregate: "max" })
      }
    ]);
  } else if (Je(h.bin)) {
    if (Rt(e))
      return Gn(e === "bin-ordinal" ? [] : [
        {
          // If sort by aggregation of a specified sort field, we need to use RAW table,
          // so we can aggregate values for the scale independently from the main aggregation.
          data: Hf(d) ? n.requestDataName(Ke.Main) : n.requestDataName(Ke.Raw),
          // Use range if we added it and the scale does not support computing a range as a signal.
          field: n.vgField(i, Id(h, i) ? { binSuffix: "range" } : {}),
          // we have to use a sort object if sort = true to make the sort correct by bin start
          sort: d === !0 || !ne(d) ? {
            field: n.vgField(i, {}),
            op: "min"
            // min or max doesn't matter since we sort by the start of the bin range
          } : d
        }
      ]);
    {
      const { bin: g } = h;
      if (Je(g)) {
        const p = JE(n, h.field, g);
        return Gn([
          new Ct(() => {
            const m = n.getSignalName(p);
            return `[${m}.start, ${m}.stop]`;
          })
        ]);
      } else
        return Gn([
          {
            data: n.requestDataName(Ke.Main),
            field: n.vgField(i, {})
          }
        ]);
    }
  } else if (h.timeUnit && Me(["time", "utc"], e)) {
    const g = r[Gr(i)];
    if (sL(h, g, s, a)) {
      const p = n.requestDataName(Ke.Main), m = Ao({ fieldDef: h, fieldDef2: g, markDef: s, config: a }), y = Vf(o) && m !== 0.5 && ht(i);
      return Gn([
        {
          data: p,
          field: n.vgField(i, y ? { suffix: C0 } : {})
        },
        {
          data: p,
          field: n.vgField(i, { suffix: y ? $0 : "end" })
        }
      ]);
    }
  }
  return Gn(d ? [
    {
      // If sort by aggregation of a specified sort field, we need to use RAW table,
      // so we can aggregate values for the scale independently from the main aggregation.
      data: Hf(d) ? n.requestDataName(Ke.Main) : n.requestDataName(Ke.Raw),
      field: n.vgField(i),
      sort: d
    }
  ] : [
    {
      data: n.requestDataName(Ke.Main),
      field: n.vgField(i)
    }
  ]);
}
function ly(e, t) {
  const { op: n, field: i, order: r } = e;
  return {
    // Apply default op
    op: n ?? (t ? "sum" : m0),
    // flatten nested fields
    ...i ? { field: Ci(i) } : {},
    ...r ? { order: r } : {}
  };
}
function mde(e, t) {
  var a;
  const n = e.component.scales[t], i = e.specifiedScales[t].domain, r = (a = e.fieldDef(t)) == null ? void 0 : a.bin, s = W4(i) && i, o = ul(r) && u0(r.extent) && r.extent;
  (s || o) && n.set("selectionExtent", s ?? o, !0);
}
function yde(e, t, n) {
  if (!Rt(n))
    return;
  const i = e.fieldDef(t), r = i.sort;
  if (iL(r))
    return {
      op: "min",
      field: Tu(i, t),
      order: "ascending"
    };
  const { stack: s } = e, o = s ? /* @__PURE__ */ new Set([...s.groupbyFields, ...s.stackBy.map((a) => a.fieldDef.field)]) : void 0;
  if (Sr(r)) {
    const a = s && !o.has(r.field);
    return ly(r, a);
  } else if (nL(r)) {
    const { encoding: a, order: l } = r, u = e.fieldDef(a), { aggregate: c, field: f } = u, d = s && !o.has(f);
    if (Ss(c) || qo(c))
      return ly({
        field: J(u),
        order: l
      }, d);
    if (eE(c) || !c)
      return ly({
        op: c,
        field: f,
        order: l
      }, d);
  } else {
    if (r === "descending")
      return {
        op: "min",
        field: e.vgField(t),
        order: "descending"
      };
    if (Me([
      "ascending",
      void 0
      /* default =ascending*/
    ], r))
      return !0;
  }
}
function MM(e, t) {
  const { aggregate: n, type: i } = e;
  return n ? te(n) && !Vse.has(n) ? {
    valid: !1,
    reason: Roe(n)
  } : i === "quantitative" && t === "log" ? {
    valid: !1,
    reason: Loe(e)
  } : { valid: !0 } : {
    valid: !1,
    reason: Doe(e)
  };
}
function Tv(e, t, n, i) {
  return e.explicit && t.explicit && G(joe(n, i, e.value, t.value)), { explicit: e.explicit, value: [...e.value, ...t.value] };
}
function bde(e) {
  const t = xr(e.map((o) => {
    if (ds(o)) {
      const { sort: a, ...l } = o;
      return l;
    }
    return o;
  }), $e), n = xr(e.map((o) => {
    if (ds(o)) {
      const a = o.sort;
      return a !== void 0 && !Hf(a) && ("op" in a && a.op === "count" && delete a.field, a.order === "ascending" && delete a.order), a;
    }
  }).filter((o) => o !== void 0), $e);
  if (t.length === 0)
    return;
  if (t.length === 1) {
    const o = e[0];
    if (ds(o) && n.length > 0) {
      let a = n[0];
      if (n.length > 1) {
        G(I$);
        const l = n.filter((u) => ne(u) && "op" in u && u.op !== "min");
        n.every((u) => ne(u) && "op" in u) && l.length === 1 ? a = l[0] : a = !0;
      } else if (ne(a) && "field" in a) {
        const l = a.field;
        o.field === l && (a = a.order ? { order: a.order } : !0);
      }
      return {
        ...o,
        sort: a
      };
    }
    return o;
  }
  const i = xr(n.map((o) => Hf(o) || !("op" in o) || te(o.op) && o.op in qse ? o : (G(qoe(o)), !0)), $e);
  let r;
  i.length === 1 ? r = i[0] : i.length > 1 && (G(I$), r = !0);
  const s = xr(e.map((o) => ds(o) ? o.data : null), (o) => o);
  return s.length === 1 && s[0] !== null ? {
    data: s[0],
    fields: t.map((a) => a.field),
    ...r ? { sort: r } : {}
  } : { fields: t, ...r ? { sort: r } : {} };
}
function tS(e) {
  if (ds(e) && te(e.field))
    return e.field;
  if (Yse(e)) {
    let t;
    for (const n of e.fields)
      if (ds(n) && te(n.field)) {
        if (!t)
          t = n.field;
        else if (t !== n.field)
          return G(Woe), t;
      }
    return G(Hoe), t;
  } else if (Xse(e)) {
    G(Goe);
    const t = e.fields[0];
    return te(t) ? t : void 0;
  }
}
function N0(e, t) {
  const i = e.component.scales[t].get("domains").map((r) => (ds(r) && (r.data = e.lookupDataSource(r.data)), r));
  return bde(i);
}
function V8(e) {
  return nc(e) || nS(e) ? e.children.reduce((t, n) => t.concat(V8(n)), FM(e)) : FM(e);
}
function FM(e) {
  return q(e.component.scales).reduce((t, n) => {
    const i = e.component.scales[n];
    if (i.merged)
      return t;
    const r = i.combine(), { name: s, type: o, selectionExtent: a, domains: l, range: u, reverse: c, ...f } = r, d = vde(r.range, s, n, e), h = N0(e, n), g = a ? hce(e, a, i, h) : null;
    return t.push({
      name: s,
      type: o,
      ...h ? { domain: h } : {},
      ...g ? { domainRaw: g } : {},
      range: d,
      ...c !== void 0 ? { reverse: c } : {},
      ...f
    }), t;
  }, []);
}
function vde(e, t, n, i) {
  if (ht(n)) {
    if (Wo(e))
      return {
        step: { signal: `${t}_step` }
      };
  } else if (ne(e) && ds(e))
    return {
      ...e,
      data: i.lookupDataSource(e.data)
    };
  return e;
}
class Y8 extends Is {
  constructor(t, n) {
    super(
      {},
      // no initial explicit property
      { name: t }
      // name as initial implicit property
    ), this.merged = !1, this.setWithExplicit("type", n);
  }
  /**
   * Whether the scale definitely includes zero in the domain
   */
  domainDefinitelyIncludesZero() {
    return this.get("zero") !== !1 ? !0 : Ba(this.get("domains"), (t) => U(t) && t.length === 2 && Re(t[0]) && t[0] <= 0 && Re(t[1]) && t[1] >= 0);
  }
}
const xde = ["range", "scheme"];
function wde(e) {
  const t = e.component.scales;
  for (const n of l0) {
    const i = t[n];
    if (!i)
      continue;
    const r = _de(n, e);
    i.setWithExplicit("range", r);
  }
}
function TM(e, t) {
  const n = e.fieldDef(t);
  if (n != null && n.bin) {
    const { bin: i, field: r } = n, s = qn(t), o = e.getName(s);
    if (ne(i) && i.binned && i.step !== void 0)
      return new Ct(() => {
        const a = e.scaleName(t), l = `(domain("${a}")[1] - domain("${a}")[0]) / ${i.step}`;
        return `${e.getSignalName(o)} / (${l})`;
      });
    if (Je(i)) {
      const a = JE(e, r, i);
      return new Ct(() => {
        const l = e.getSignalName(a), u = `(${l}.stop - ${l}.start) / ${l}.step`;
        return `${e.getSignalName(o)} / (${u})`;
      });
    }
  }
}
function _de(e, t) {
  const n = t.specifiedScales[e], { size: i } = t, s = t.getScaleComponent(e).get("type");
  for (const f of xde)
    if (n[f] !== void 0) {
      const d = pv(s, f), h = H4(e, f);
      if (!d)
        G(S4(s, f, e));
      else if (h)
        G(h);
      else
        switch (f) {
          case "range": {
            const g = n.range;
            if (U(g)) {
              if (ht(e))
                return pr(g.map((p) => {
                  if (p === "width" || p === "height") {
                    const m = t.getName(p), y = t.getSignalName.bind(t);
                    return Ct.fromName(y, m);
                  }
                  return p;
                }));
            } else if (ne(g))
              return pr({
                data: t.requestDataName(Ke.Main),
                field: g.field,
                sort: { op: "min", field: t.vgField(e) }
              });
            return pr(g);
          }
          case "scheme":
            return pr(Ede(n[f]));
        }
    }
  const o = e === nt || e === "xOffset" ? "width" : "height", a = i[o];
  if (Lr(a)) {
    if (ht(e))
      if (Rt(s)) {
        const f = K8(a, t, e);
        if (f)
          return pr({ step: f });
      } else
        G(k4(o));
    else if (Od(e)) {
      const f = e === Io ? "x" : "y";
      if (t.getScaleComponent(f).get("type") === "band") {
        const g = J8(a, s);
        if (g)
          return pr(g);
      }
    }
  }
  const { rangeMin: l, rangeMax: u } = n, c = Sde(e, t);
  return (l !== void 0 || u !== void 0) && // it's ok to check just rangeMin's compatibility since rangeMin/rangeMax are the same
  pv(s, "rangeMin") && U(c) && c.length === 2 ? pr([l ?? c[0], u ?? c[1]]) : Gn(c);
}
function Ede(e) {
  return Tae(e) ? {
    scheme: e.name,
    ...Nn(e, ["name"])
  } : { scheme: e };
}
function X8(e, t, n, { center: i } = {}) {
  const r = qn(e), s = t.getName(r), o = t.getSignalName.bind(t);
  return e === Pt && li(n) ? i ? [
    Ct.fromName((a) => `${o(a)}/2`, s),
    Ct.fromName((a) => `-${o(a)}/2`, s)
  ] : [Ct.fromName(o, s), 0] : i ? [
    Ct.fromName((a) => `-${o(a)}/2`, s),
    Ct.fromName((a) => `${o(a)}/2`, s)
  ] : [0, Ct.fromName(o, s)];
}
function Sde(e, t) {
  const { size: n, config: i, mark: r, encoding: s } = t, { type: o } = wt(s[e]), l = t.getScaleComponent(e).get("type"), { domain: u, domainMid: c } = t.specifiedScales[e];
  switch (e) {
    case nt:
    case Pt: {
      if (Me(["point", "band"], l)) {
        const f = Q8(e, n, i.view);
        if (Lr(f))
          return { step: K8(f, t, e) };
      }
      return X8(e, t, l);
    }
    case Io:
    case Ku:
      return kde(e, t, l);
    case Ds: {
      const f = t.component.scales[e].get("zero"), d = Z8(r, f, i), h = $de(r, n, t, i);
      return Su(l) ? Cde(d, h, Ade(l, i, u, e)) : [d, h];
    }
    case Fi:
      return [0, Math.PI * 2];
    case al:
      return [0, 360];
    case or:
      return [
        0,
        new Ct(() => {
          const f = t.getSignalName("width"), d = t.getSignalName("height");
          return `min(${f},${d})/2`;
        })
      ];
    case jo:
      return [i.scale.minStrokeWidth, i.scale.maxStrokeWidth];
    case Uo:
      return [
        // TODO: add this to Vega's config.range?
        [1, 0],
        [4, 2],
        [2, 1],
        [1, 1],
        [1, 2, 4, 2]
      ];
    case Un:
      return "symbol";
    case jn:
    case Wr:
    case Hr:
      return l === "ordinal" ? o === "nominal" ? "category" : "ordinal" : c !== void 0 ? "diverging" : r === "rect" || r === "geoshape" ? "heatmap" : "ramp";
    case Rs:
    case zo:
    case Bo:
      return [i.scale.minOpacity, i.scale.maxOpacity];
  }
}
function K8(e, t, n) {
  const { encoding: i } = t, r = t.getScaleComponent(n), s = K_(n), o = i[s];
  if (LL({ step: e, offsetIsDiscrete: be(o) && z4(o.type) }) === "offset" && yL(i, s)) {
    const l = t.getScaleComponent(s);
    let c = `domain('${t.scaleName(s)}').length`;
    if (l.get("type") === "band") {
      const d = l.get("paddingInner") ?? l.get("padding") ?? 0, h = l.get("paddingOuter") ?? l.get("padding") ?? 0;
      c = `bandspace(${c}, ${d}, ${h})`;
    }
    const f = r.get("paddingInner") ?? r.get("padding");
    return {
      signal: `${e.step} * ${c} / (1-${Zse(f)})`
    };
  } else
    return e.step;
}
function J8(e, t) {
  if (LL({ step: e, offsetIsDiscrete: Rt(t) }) === "offset")
    return { step: e.step };
}
function kde(e, t, n) {
  const i = e === Io ? "x" : "y", r = t.getScaleComponent(i);
  if (!r)
    return X8(i, t, n, { center: !0 });
  const s = r.get("type"), o = t.scaleName(i), { markDef: a, config: l } = t;
  if (s === "band") {
    const u = Q8(i, t.size, t.config.view);
    if (Lr(u)) {
      const c = J8(u, n);
      if (c)
        return c;
    }
    return [0, { signal: `bandwidth('${o}')` }];
  } else {
    const u = t.encoding[i];
    if (H(u) && u.timeUnit) {
      const c = R4(u.timeUnit, (g) => `scale('${o}', ${g})`), f = t.config.scale.bandWithNestedOffsetPaddingInner, d = Ao({
        fieldDef: u,
        markDef: a,
        config: l
      }) - 0.5, h = d !== 0 ? ` + ${d}` : "";
      if (f) {
        const g = oe(f) ? `${f.signal}/2` + h : `${f / 2 + d}`, p = oe(f) ? `(1 - ${f.signal}/2)` + h : `${1 - f / 2 + d}`;
        return [{ signal: `${g} * (${c})` }, { signal: `${p} * (${c})` }];
      }
      return [0, { signal: c }];
    }
    return H6(`Cannot use ${e} scale if ${i} scale is not discrete.`);
  }
}
function Q8(e, t, n) {
  const i = e === nt ? "width" : "height", r = t[i];
  return r || Tp(n, i);
}
function Ade(e, t, n, i) {
  switch (e) {
    case "quantile":
      return t.scale.quantileCount;
    case "quantize":
      return t.scale.quantizeCount;
    case "threshold":
      return n !== void 0 && U(n) ? n.length + 1 : (G(tae(i)), 3);
  }
}
function Cde(e, t, n) {
  const i = () => {
    const r = Hi(t), s = Hi(e), o = `(${r} - ${s}) / (${n} - 1)`;
    return `sequence(${s}, ${r} + ${o}, ${o})`;
  };
  return oe(t) ? new Ct(i) : { signal: i() };
}
function Z8(e, t, n) {
  if (t)
    return oe(t) ? { signal: `${t.signal} ? 0 : ${Z8(e, !1, n)}` } : 0;
  switch (e) {
    case "bar":
    case "tick":
      return n.scale.minBandSize;
    case "line":
    case "trail":
    case "rule":
      return n.scale.minStrokeWidth;
    case "text":
      return n.scale.minFontSize;
    case "point":
    case "square":
    case "circle":
      return n.scale.minSize;
  }
  throw new Error(c0("size", e));
}
const OM = 0.95;
function $de(e, t, n, i) {
  const r = {
    x: TM(n, "x"),
    y: TM(n, "y")
  };
  switch (e) {
    case "bar":
    case "tick": {
      if (i.scale.maxBandSize !== void 0)
        return i.scale.maxBandSize;
      const s = NM(t, r, i.view);
      return Re(s) ? s - 1 : new Ct(() => `${s.signal} - 1`);
    }
    case "line":
    case "trail":
    case "rule":
      return i.scale.maxStrokeWidth;
    case "text":
      return i.scale.maxFontSize;
    case "point":
    case "square":
    case "circle": {
      if (i.scale.maxSize)
        return i.scale.maxSize;
      const s = NM(t, r, i.view);
      return Re(s) ? Math.pow(OM * s, 2) : new Ct(() => `pow(${OM} * ${s.signal}, 2)`);
    }
  }
  throw new Error(c0("size", e));
}
function NM(e, t, n) {
  const i = Lr(e.width) ? e.width.step : Fp(n, "width"), r = Lr(e.height) ? e.height.step : Fp(n, "height");
  return t.x || t.y ? new Ct(() => `min(${[
    t.x ? t.x.signal : i,
    t.y ? t.y.signal : r
  ].join(", ")})`) : Math.min(i, r);
}
function eP(e, t) {
  at(e) ? Mde(e, t) : nP(e, t);
}
function Mde(e, t) {
  const n = e.component.scales, { config: i, encoding: r, markDef: s, specifiedScales: o } = e;
  for (const a of q(n)) {
    const l = o[a], u = n[a], c = e.getScaleComponent(a), f = wt(r[a]), d = l[t], h = c.get("type"), g = c.get("padding"), p = c.get("paddingInner"), m = pv(h, t), y = H4(a, t);
    if (d !== void 0 && (m ? y && G(y) : G(S4(h, t, a))), m && y === void 0)
      if (d !== void 0) {
        const b = f.timeUnit, v = f.type;
        switch (t) {
          case "domainMax":
          case "domainMin":
            cl(l[t]) || v === "temporal" || b ? u.set(t, { signal: w0(l[t], { type: v, timeUnit: b }) }, !0) : u.set(t, l[t], !0);
            break;
          default:
            u.copyKeyFromObject(t, l);
        }
      } else {
        const b = t in DM ? DM[t]({
          model: e,
          channel: a,
          fieldOrDatumDef: f,
          scaleType: h,
          scalePadding: g,
          scalePaddingInner: p,
          domain: l.domain,
          domainMin: l.domainMin,
          domainMax: l.domainMax,
          markDef: s,
          config: i,
          hasNestedOffsetScale: bL(r, a),
          hasSecondaryRangeChannel: !!r[Gr(a)]
        }) : i.scale[t];
        b !== void 0 && u.set(t, b, !1);
      }
  }
}
const DM = {
  bins: ({ model: e, fieldOrDatumDef: t }) => H(t) ? Fde(e, t) : void 0,
  interpolate: ({ channel: e, fieldOrDatumDef: t }) => Tde(e, t.type),
  nice: ({ scaleType: e, channel: t, domain: n, domainMin: i, domainMax: r, fieldOrDatumDef: s }) => Ode(e, t, n, i, r, s),
  padding: ({ channel: e, scaleType: t, fieldOrDatumDef: n, markDef: i, config: r }) => Nde(e, t, r.scale, n, i, r.bar),
  paddingInner: ({ scalePadding: e, channel: t, markDef: n, scaleType: i, config: r, hasNestedOffsetScale: s }) => Dde(e, t, n.type, i, r.scale, s),
  paddingOuter: ({ scalePadding: e, channel: t, scaleType: n, scalePaddingInner: i, config: r, hasNestedOffsetScale: s }) => Rde(e, t, n, i, r.scale, s),
  reverse: ({ fieldOrDatumDef: e, scaleType: t, channel: n, config: i }) => {
    const r = H(e) ? e.sort : void 0;
    return Lde(t, r, n, i.scale);
  },
  zero: ({ channel: e, fieldOrDatumDef: t, domain: n, markDef: i, scaleType: r, config: s, hasSecondaryRangeChannel: o }) => Pde(e, t, n, i, r, s.scale, o)
};
function tP(e) {
  at(e) ? wde(e) : nP(e, "range");
}
function nP(e, t) {
  const n = e.component.scales;
  for (const i of e.children)
    t === "range" ? tP(i) : eP(i, t);
  for (const i of q(n)) {
    let r;
    for (const s of e.children) {
      const o = s.component.scales[i];
      if (o) {
        const a = o.getWithExplicit(t);
        r = Co(r, a, t, "scale", XL((l, u) => {
          switch (t) {
            case "range":
              return l.step && u.step ? l.step - u.step : 0;
          }
          return 0;
        }));
      }
    }
    n[i].setWithExplicit(t, r);
  }
}
function Fde(e, t) {
  const n = t.bin;
  if (Je(n)) {
    const i = JE(e, t.field, n);
    return new Ct(() => e.getSignalName(i));
  } else if (Bt(n) && ul(n) && n.step !== void 0)
    return {
      step: n.step
    };
}
function Tde(e, t) {
  if (Me([jn, Wr, Hr], e) && t !== "nominal")
    return "hcl";
}
function Ode(e, t, n, i, r, s) {
  var o;
  if (!((o = Rr(s)) != null && o.bin || U(n) || r != null || i != null || Me([Dn.TIME, Dn.UTC], e)))
    return ht(t) ? !0 : void 0;
}
function Nde(e, t, n, i, r, s) {
  if (ht(e)) {
    if (Gi(t)) {
      if (n.continuousPadding !== void 0)
        return n.continuousPadding;
      const { type: o, orient: a } = r;
      if (o === "bar" && !(H(i) && (i.bin || i.timeUnit)) && (a === "vertical" && e === "x" || a === "horizontal" && e === "y"))
        return s.continuousBandSize;
    }
    if (t === Dn.POINT)
      return n.pointPadding;
  }
}
function Dde(e, t, n, i, r, s = !1) {
  if (e === void 0) {
    if (ht(t)) {
      const { bandPaddingInner: o, barBandPaddingInner: a, rectBandPaddingInner: l, bandWithNestedOffsetPaddingInner: u } = r;
      return s ? u : dt(o, n === "bar" ? a : l);
    } else if (Od(t) && i === Dn.BAND)
      return r.offsetBandPaddingInner;
  }
}
function Rde(e, t, n, i, r, s = !1) {
  if (e === void 0) {
    if (ht(t)) {
      const { bandPaddingOuter: o, bandWithNestedOffsetPaddingOuter: a } = r;
      if (s)
        return a;
      if (n === Dn.BAND)
        return dt(
          o,
          /* By default, paddingOuter is paddingInner / 2. The reason is that
            size (width/height) = step * (cardinality - paddingInner + 2 * paddingOuter).
            and we want the width/height to be integer by default.
            Note that step (by default) and cardinality are integers.) */
          oe(i) ? { signal: `${i.signal}/2` } : i / 2
        );
    } else if (Od(t)) {
      if (n === Dn.POINT)
        return 0.5;
      if (n === Dn.BAND)
        return r.offsetBandPaddingOuter;
    }
  }
}
function Lde(e, t, n, i) {
  if (n === "x" && i.xReverse !== void 0)
    return li(e) && t === "descending" ? oe(i.xReverse) ? { signal: `!${i.xReverse.signal}` } : !i.xReverse : i.xReverse;
  if (li(e) && t === "descending")
    return !0;
}
function Pde(e, t, n, i, r, s, o) {
  if (!!n && n !== "unaggregated" && li(r)) {
    if (U(n)) {
      const l = n[0], u = n[n.length - 1];
      if (Re(l) && l <= 0 && Re(u) && u >= 0)
        return !0;
    }
    return !1;
  }
  if (e === "size" && t.type === "quantitative" && !Su(r))
    return !0;
  if (!(H(t) && t.bin) && Me([...Vr, ...Rse], e)) {
    const { orient: l, type: u } = i;
    return Me(["bar", "area", "line", "trail"], u) && (l === "horizontal" && e === "y" || l === "vertical" && e === "x") ? !1 : Me(["bar", "area"], u) && !o ? !0 : s == null ? void 0 : s.zero;
  }
  return !1;
}
function Ide(e, t, n, i, r = !1) {
  const s = zde(t, n, i, r), { type: o } = e;
  return Ls(t) ? o !== void 0 ? Iae(t, o) ? H(n) && !Pae(o, n.type) ? (G(zoe(o, s)), s) : o : (G(Ioe(t, o, s)), s) : s : null;
}
function zde(e, t, n, i) {
  var r;
  switch (t.type) {
    case "nominal":
    case "ordinal": {
      if (Vl(e) || Z1(e) === "discrete")
        return e === "shape" && t.type === "ordinal" && G(ey(e, "ordinal")), "ordinal";
      if (ht(e) || Od(e)) {
        if (Me(["rect", "bar", "image", "rule"], n.type) || i)
          return "band";
      } else if (n.type === "arc" && e in Z_)
        return "band";
      const s = n[qn(e)];
      return Ha(s) || Au(t) && ((r = t.axis) != null && r.tickBand) ? "band" : "point";
    }
    case "temporal":
      return Vl(e) ? "time" : Z1(e) === "discrete" ? (G(ey(e, "temporal")), "ordinal") : H(t) && t.timeUnit && Dt(t.timeUnit).utc ? "utc" : "time";
    case "quantitative":
      return Vl(e) ? H(t) && Je(t.bin) ? "bin-ordinal" : "linear" : Z1(e) === "discrete" ? (G(ey(e, "quantitative")), "ordinal") : "linear";
    case "geojson":
      return;
  }
  throw new Error(_4(t.type));
}
function Bde(e, { ignoreRange: t } = {}) {
  iP(e), G8(e);
  for (const n of Lae)
    eP(e, n);
  t || tP(e);
}
function iP(e) {
  at(e) ? e.component.scales = jde(e) : e.component.scales = qde(e);
}
function jde(e) {
  const { encoding: t, mark: n, markDef: i } = e, r = {};
  for (const s of l0) {
    const o = wt(t[s]);
    if (o && n === Y4 && s === Un && o.type === Ju)
      continue;
    let a = o && o.scale;
    if (o && a !== null && a !== !1) {
      a ?? (a = {});
      const l = bL(t, s), u = Ide(a, s, o, i, l);
      r[s] = new Y8(e.scaleName(`${s}`, !0), {
        value: u,
        explicit: a.type === u
      });
    }
  }
  return r;
}
const Ude = XL((e, t) => B$(e) - B$(t));
function qde(e) {
  var t;
  const n = e.component.scales = {}, i = {}, r = e.component.resolve;
  for (const s of e.children) {
    iP(s);
    for (const o of q(s.component.scales))
      if ((t = r.scale)[o] ?? (t[o] = N8(o, e)), r.scale[o] === "shared") {
        const a = i[o], l = s.component.scales[o].getWithExplicit("type");
        a ? Aae(a.value, l.value) ? i[o] = Co(a, l, "type", "scale", Ude) : (r.scale[o] = "independent", delete i[o]) : i[o] = l;
      }
  }
  for (const s of q(i)) {
    const o = e.scaleName(s, !0), a = i[s];
    n[s] = new Y8(o, a);
    for (const l of e.children) {
      const u = l.component.scales[s];
      u && (l.renameScale(u.get("name"), o), u.merged = !0);
    }
  }
  return n;
}
class uy {
  constructor() {
    this.nameMap = {};
  }
  rename(t, n) {
    this.nameMap[t] = n;
  }
  has(t) {
    return this.nameMap[t] !== void 0;
  }
  get(t) {
    for (; this.nameMap[t] && t !== this.nameMap[t]; )
      t = this.nameMap[t];
    return t;
  }
}
function at(e) {
  return (e == null ? void 0 : e.type) === "unit";
}
function Ki(e) {
  return (e == null ? void 0 : e.type) === "facet";
}
function nS(e) {
  return (e == null ? void 0 : e.type) === "concat";
}
function nc(e) {
  return (e == null ? void 0 : e.type) === "layer";
}
class iS {
  constructor(t, n, i, r, s, o, a) {
    this.type = n, this.parent = i, this.config = s, this.correctDataNames = (l) => {
      var u, c, f;
      return (u = l.from) != null && u.data && (l.from.data = this.lookupDataSource(l.from.data)), (f = (c = l.from) == null ? void 0 : c.facet) != null && f.data && (l.from.facet.data = this.lookupDataSource(l.from.facet.data)), l;
    }, this.parent = i, this.config = s, this.view = Fn(a), this.name = t.name ?? r, this.title = Ys(t.title) ? { text: t.title } : t.title ? Fn(t.title) : void 0, this.scaleNameMap = i ? i.scaleNameMap : new uy(), this.projectionNameMap = i ? i.projectionNameMap : new uy(), this.signalNameMap = i ? i.signalNameMap : new uy(), this.data = t.data, this.description = t.description, this.transforms = Kue(t.transform ?? []), this.layout = n === "layer" || n === "unit" ? {} : eue(t, n, s), this.component = {
      data: {
        sources: i ? i.component.data.sources : [],
        outputNodes: i ? i.component.data.outputNodes : {},
        outputNodeRefCounts: i ? i.component.data.outputNodeRefCounts : {},
        // data is faceted if the spec is a facet spec or the parent has faceted data and data is undefined
        isFaceted: y0(t) || (i == null ? void 0 : i.component.data.isFaceted) && t.data === void 0
      },
      layoutSize: new Is(),
      layoutHeaders: { row: {}, column: {}, facet: {} },
      mark: null,
      resolve: {
        scale: {},
        axis: {},
        legend: {},
        ...o ? me(o) : {}
      },
      selection: null,
      scales: null,
      projection: null,
      axes: {},
      legends: {}
    };
  }
  get width() {
    return this.getSizeSignalRef("width");
  }
  get height() {
    return this.getSizeSignalRef("height");
  }
  parse() {
    this.parseScale(), this.parseLayoutSize(), this.renameTopLevelLayoutSizeSignal(), this.parseSelections(), this.parseProjection(), this.parseData(), this.parseAxesAndHeaders(), this.parseLegends(), this.parseMarkGroup();
  }
  parseScale() {
    Bde(this);
  }
  parseProjection() {
    q8(this);
  }
  /**
   * Rename top-level spec's size to be just width / height, ignoring model name.
   * This essentially merges the top-level spec's width/height signals with the width/height signals
   * to help us reduce redundant signals declaration.
   */
  renameTopLevelLayoutSizeSignal() {
    this.getName("width") !== "width" && this.renameSignal(this.getName("width"), "width"), this.getName("height") !== "height" && this.renameSignal(this.getName("height"), "height");
  }
  parseLegends() {
    I8(this);
  }
  assembleEncodeFromView(t) {
    const { style: n, ...i } = t, r = {};
    for (const s of q(i)) {
      const o = i[s];
      o !== void 0 && (r[s] = Ze(o));
    }
    return r;
  }
  assembleGroupEncodeEntry(t) {
    let n = {};
    return this.view && (n = this.assembleEncodeFromView(this.view)), !t && (this.description && (n.description = Ze(this.description)), this.type === "unit" || this.type === "layer") ? {
      width: this.getSizeSignalRef("width"),
      height: this.getSizeSignalRef("height"),
      ...n ?? {}
    } : Ge(n) ? void 0 : n;
  }
  assembleLayout() {
    if (!this.layout)
      return;
    const { spacing: t, ...n } = this.layout, { component: i, config: r } = this, s = cfe(i.layoutHeaders, r);
    return {
      padding: t,
      ...this.assembleDefaultLayout(),
      ...n,
      ...s ? { titleBand: s } : {}
    };
  }
  assembleDefaultLayout() {
    return {};
  }
  assembleHeaderMarks() {
    const { layoutHeaders: t } = this.component;
    let n = [];
    for (const i of yi)
      t[i].title && n.push(rfe(this, i));
    for (const i of VE)
      n = n.concat(sfe(this, i));
    return n;
  }
  assembleAxes() {
    return Hce(this.component.axes, this.config);
  }
  assembleLegends() {
    return B8(this);
  }
  assembleProjections() {
    return Nfe(this);
  }
  assembleTitle() {
    const { encoding: t, ...n } = this.title ?? {}, i = {
      ...h4(this.config.title).nonMarkTitleProperties,
      ...n,
      ...t ? { encode: { update: t } } : {}
    };
    if (i.text)
      return Me(["unit", "layer"], this.type) ? Me(["middle", void 0], i.anchor) && (i.frame ?? (i.frame = "group")) : i.anchor ?? (i.anchor = "start"), Ge(i) ? void 0 : i;
  }
  /**
   * Assemble the mark group for this model. We accept optional `signals` so that we can include concat top-level signals with the top-level model's local signals.
   */
  assembleGroup(t = []) {
    const n = {};
    t = t.concat(this.assembleSignals()), t.length > 0 && (n.signals = t);
    const i = this.assembleLayout();
    i && (n.layout = i), n.marks = [].concat(this.assembleHeaderMarks(), this.assembleMarks());
    const r = !this.parent || Ki(this.parent) ? V8(this) : [];
    r.length > 0 && (n.scales = r);
    const s = this.assembleAxes();
    s.length > 0 && (n.axes = s);
    const o = this.assembleLegends();
    return o.length > 0 && (n.legends = o), n;
  }
  getName(t) {
    return tt((this.name ? `${this.name}_` : "") + t);
  }
  getDataName(t) {
    return this.getName(Ke[t].toLowerCase());
  }
  /**
   * Request a data source name for the given data source type and mark that data source as required.
   * This method should be called in parse, so that all used data source can be correctly instantiated in assembleData().
   * You can lookup the correct dataset name in assemble with `lookupDataSource`.
   */
  requestDataName(t) {
    const n = this.getDataName(t), i = this.component.data.outputNodeRefCounts;
    return i[n] = (i[n] || 0) + 1, n;
  }
  getSizeSignalRef(t) {
    if (Ki(this.parent)) {
      const n = T8(t), i = a0(n), r = this.component.scales[i];
      if (r && !r.merged) {
        const s = r.get("type"), o = r.get("range");
        if (Rt(s) && Wo(o)) {
          const a = r.get("name"), l = N0(this, i), u = tS(l);
          if (u) {
            const c = J({ aggregate: "distinct", field: u }, { expr: "datum" });
            return {
              signal: F8(a, r, c)
            };
          } else
            return G(nE(i)), null;
        }
      }
    }
    return {
      signal: this.signalNameMap.get(this.getName(t))
    };
  }
  /**
   * Lookup the name of the datasource for an output node. You probably want to call this in assemble.
   */
  lookupDataSource(t) {
    const n = this.component.data.outputNodes[t];
    return n ? n.getSource() : t;
  }
  getSignalName(t) {
    return this.signalNameMap.get(t);
  }
  renameSignal(t, n) {
    this.signalNameMap.rename(t, n);
  }
  renameScale(t, n) {
    this.scaleNameMap.rename(t, n);
  }
  renameProjection(t, n) {
    this.projectionNameMap.rename(t, n);
  }
  /**
   * @return scale name for a given channel after the scale has been parsed and named.
   */
  scaleName(t, n) {
    if (n)
      return this.getName(t);
    if (
      // If there is a scale for the channel, there should be a local scale component for it
      r4(t) && Ls(t) && this.component.scales[t] || // in the scale name map (the scale get merged by its parent)
      this.scaleNameMap.has(this.getName(t))
    )
      return this.scaleNameMap.get(this.getName(t));
  }
  /**
   * @return projection name after the projection has been parsed and named.
   */
  projectionName(t) {
    if (t)
      return this.getName("projection");
    if (this.component.projection && !this.component.projection.merged || this.projectionNameMap.has(this.getName("projection")))
      return this.projectionNameMap.get(this.getName("projection"));
  }
  /**
   * Traverse a model's hierarchy to get the scale component for a particular channel.
   */
  getScaleComponent(t) {
    if (!this.component.scales)
      throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");
    const n = this.component.scales[t];
    return n && !n.merged ? n : this.parent ? this.parent.getScaleComponent(t) : void 0;
  }
  /**
   * Traverse a model's hierarchy to get a particular selection component.
   */
  getSelectionComponent(t, n) {
    let i = this.component.selection[t];
    if (!i && this.parent && (i = this.parent.getSelectionComponent(t, n)), !i)
      throw new Error(roe(n));
    return i;
  }
  /**
   * Returns true if the model has a signalRef for an axis orient.
   */
  hasAxisOrientSignalRef() {
    var t, n;
    return ((t = this.component.axes.x) == null ? void 0 : t.some((i) => i.hasOrientSignalRef())) || ((n = this.component.axes.y) == null ? void 0 : n.some((i) => i.hasOrientSignalRef()));
  }
}
class rP extends iS {
  /** Get "field" reference for Vega */
  vgField(t, n = {}) {
    const i = this.fieldDef(t);
    if (i)
      return J(i, n);
  }
  reduceFieldDef(t, n) {
    return Mle(this.getMapping(), (i, r, s) => {
      const o = Rr(r);
      return o ? t(i, o, s) : i;
    }, n);
  }
  forEachFieldDef(t, n) {
    ME(this.getMapping(), (i, r) => {
      const s = Rr(i);
      s && t(s, r);
    }, n);
  }
}
class D0 extends He {
  clone() {
    return new D0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const i = this.transform.as ?? [void 0, void 0];
    this.transform.as = [i[0] ?? "value", i[1] ?? "density"];
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.density, ...this.transform.groupby ?? []]);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `DensityTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { density: t, ...n } = this.transform, i = {
      type: "kde",
      field: t,
      ...n
    };
    return this.transform.groupby && (i.resolve = "shared"), i;
  }
}
class R0 extends He {
  clone() {
    return new R0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.extent]);
  }
  producedFields() {
    return /* @__PURE__ */ new Set([]);
  }
  hash() {
    return `ExtentTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { extent: t, param: n } = this.transform;
    return {
      type: "extent",
      field: t,
      signal: n
    };
  }
}
class Xf extends He {
  clone() {
    return new Xf(null, { ...this.filter });
  }
  constructor(t, n) {
    super(t), this.filter = n;
  }
  static make(t, n) {
    const { config: i, mark: r, markDef: s } = n;
    if (qe("invalid", s, i) !== "filter")
      return null;
    const a = n.reduceFieldDef((l, u, c) => {
      const f = Ls(c) && n.getScaleComponent(c);
      if (f) {
        const d = f.get("type");
        li(d) && u.aggregate !== "count" && !Ho(r) && (l[u.field] = u);
      }
      return l;
    }, {});
    return q(a).length ? new Xf(t, a) : null;
  }
  dependentFields() {
    return new Set(q(this.filter));
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  hash() {
    return `FilterInvalid ${$e(this.filter)}`;
  }
  /**
   * Create the VgTransforms for each of the filtered fields.
   */
  assemble() {
    const t = q(this.filter).reduce((n, i) => {
      const r = this.filter[i], s = J(r, { expr: "datum" });
      return r !== null && (r.type === "temporal" ? n.push(`(isDate(${s}) || (isValid(${s}) && isFinite(+${s})))`) : r.type === "quantitative" && (n.push(`isValid(${s})`), n.push(`isFinite(+${s})`))), n;
    }, []);
    return t.length > 0 ? {
      type: "filter",
      expr: t.join(" && ")
    } : null;
  }
}
class L0 extends He {
  clone() {
    return new L0(this.parent, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const { flatten: i, as: r = [] } = this.transform;
    this.transform.as = i.map((s, o) => r[o] ?? s);
  }
  dependentFields() {
    return new Set(this.transform.flatten);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `FlattenTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { flatten: t, as: n } = this.transform;
    return {
      type: "flatten",
      fields: t,
      as: n
    };
  }
}
class P0 extends He {
  clone() {
    return new P0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const i = this.transform.as ?? [void 0, void 0];
    this.transform.as = [i[0] ?? "key", i[1] ?? "value"];
  }
  dependentFields() {
    return new Set(this.transform.fold);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `FoldTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { fold: t, as: n } = this.transform;
    return {
      type: "fold",
      fields: t,
      as: n
    };
  }
}
class Kl extends He {
  clone() {
    return new Kl(null, me(this.fields), this.geojson, this.signal);
  }
  static parseAll(t, n) {
    if (n.component.projection && !n.component.projection.isFit)
      return t;
    let i = 0;
    for (const r of [
      [lr, ar],
      [$i, ur]
    ]) {
      const s = r.map((o) => {
        const a = wt(n.encoding[o]);
        return H(a) ? a.field : Yr(a) ? { expr: `${a.datum}` } : er(a) ? { expr: `${a.value}` } : void 0;
      });
      (s[0] || s[1]) && (t = new Kl(t, s, null, n.getName(`geojson_${i++}`)));
    }
    if (n.channelHasField(Un)) {
      const r = n.typedFieldDef(Un);
      r.type === Ju && (t = new Kl(t, null, r.field, n.getName(`geojson_${i++}`)));
    }
    return t;
  }
  constructor(t, n, i, r) {
    super(t), this.fields = n, this.geojson = i, this.signal = r;
  }
  dependentFields() {
    const t = (this.fields ?? []).filter(te);
    return /* @__PURE__ */ new Set([...this.geojson ? [this.geojson] : [], ...t]);
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  hash() {
    return `GeoJSON ${this.geojson} ${this.signal} ${$e(this.fields)}`;
  }
  assemble() {
    return [
      ...this.geojson ? [
        {
          type: "filter",
          expr: `isValid(datum["${this.geojson}"])`
        }
      ] : [],
      {
        type: "geojson",
        ...this.fields ? { fields: this.fields } : {},
        ...this.geojson ? { geojson: this.geojson } : {},
        signal: this.signal
      }
    ];
  }
}
class Kf extends He {
  clone() {
    return new Kf(null, this.projection, me(this.fields), me(this.as));
  }
  constructor(t, n, i, r) {
    super(t), this.projection = n, this.fields = i, this.as = r;
  }
  static parseAll(t, n) {
    if (!n.projectionName())
      return t;
    for (const i of [
      [lr, ar],
      [$i, ur]
    ]) {
      const r = i.map((o) => {
        const a = wt(n.encoding[o]);
        return H(a) ? a.field : Yr(a) ? { expr: `${a.datum}` } : er(a) ? { expr: `${a.value}` } : void 0;
      }), s = i[0] === $i ? "2" : "";
      (r[0] || r[1]) && (t = new Kf(t, n.projectionName(), r, [
        n.getName(`x${s}`),
        n.getName(`y${s}`)
      ]));
    }
    return t;
  }
  dependentFields() {
    return new Set(this.fields.filter(te));
  }
  producedFields() {
    return new Set(this.as);
  }
  hash() {
    return `Geopoint ${this.projection} ${$e(this.fields)} ${$e(this.as)}`;
  }
  assemble() {
    return {
      type: "geopoint",
      projection: this.projection,
      fields: this.fields,
      as: this.as
    };
  }
}
class Ca extends He {
  clone() {
    return new Ca(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n;
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.impute, this.transform.key, ...this.transform.groupby ?? []]);
  }
  producedFields() {
    return /* @__PURE__ */ new Set([this.transform.impute]);
  }
  processSequence(t) {
    const { start: n = 0, stop: i, step: r } = t;
    return { signal: `sequence(${[n, i, ...r ? [r] : []].join(",")})` };
  }
  static makeFromTransform(t, n) {
    return new Ca(t, n);
  }
  static makeFromEncoding(t, n) {
    const i = n.encoding, r = i.x, s = i.y;
    if (H(r) && H(s)) {
      const o = r.impute ? r : s.impute ? s : void 0;
      if (o === void 0)
        return;
      const a = r.impute ? s : s.impute ? r : void 0, { method: l, value: u, frame: c, keyvals: f } = o.impute, d = xL(n.mark, i);
      return new Ca(t, {
        impute: o.field,
        key: a.field,
        ...l ? { method: l } : {},
        ...u !== void 0 ? { value: u } : {},
        ...c ? { frame: c } : {},
        ...f !== void 0 ? { keyvals: f } : {},
        ...d.length ? { groupby: d } : {}
      });
    }
    return null;
  }
  hash() {
    return `Impute ${$e(this.transform)}`;
  }
  assemble() {
    const { impute: t, key: n, keyvals: i, method: r, groupby: s, value: o, frame: a = [null, null] } = this.transform, l = {
      type: "impute",
      field: t,
      key: n,
      ...i ? { keyvals: Tue(i) ? this.processSequence(i) : i } : {},
      method: "value",
      ...s ? { groupby: s } : {},
      value: !r || r === "value" ? o : null
    };
    if (r && r !== "value") {
      const u = {
        type: "window",
        as: [`imputed_${t}_value`],
        ops: [r],
        fields: [t],
        frame: a,
        ignorePeers: !1,
        ...s ? { groupby: s } : {}
      }, c = {
        type: "formula",
        expr: `datum.${t} === null ? datum.imputed_${t}_value : datum.${t}`,
        as: t
      };
      return [l, u, c];
    } else
      return [l];
  }
}
class I0 extends He {
  clone() {
    return new I0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const i = this.transform.as ?? [void 0, void 0];
    this.transform.as = [i[0] ?? n.on, i[1] ?? n.loess];
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.loess, this.transform.on, ...this.transform.groupby ?? []]);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `LoessTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { loess: t, on: n, ...i } = this.transform;
    return {
      type: "loess",
      x: n,
      y: t,
      ...i
    };
  }
}
class Jf extends He {
  clone() {
    return new Jf(null, me(this.transform), this.secondary);
  }
  constructor(t, n, i) {
    super(t), this.transform = n, this.secondary = i;
  }
  static make(t, n, i, r) {
    const s = n.component.data.sources, { from: o } = i;
    let a = null;
    if (Oue(o)) {
      let l = aP(o.data, s);
      l || (l = new Xa(o.data), s.push(l));
      const u = n.getName(`lookup_${r}`);
      a = new xn(l, u, Ke.Lookup, n.component.data.outputNodeRefCounts), n.component.data.outputNodes[u] = a;
    } else if (Nue(o)) {
      const l = o.param;
      i = { as: l, ...i };
      let u;
      try {
        u = n.getSelectionComponent(tt(l), l);
      } catch {
        throw new Error(aoe(l));
      }
      if (a = u.materialized, !a)
        throw new Error(loe(l));
    }
    return new Jf(t, i, a.getSource());
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.lookup]);
  }
  producedFields() {
    return new Set(this.transform.as ? ee(this.transform.as) : this.transform.from.fields);
  }
  hash() {
    return `Lookup ${$e({ transform: this.transform, secondary: this.secondary })}`;
  }
  assemble() {
    let t;
    if (this.transform.from.fields)
      t = {
        values: this.transform.from.fields,
        ...this.transform.as ? { as: ee(this.transform.as) } : {}
      };
    else {
      let n = this.transform.as;
      te(n) || (G(moe), n = "_lookup"), t = {
        as: [n]
      };
    }
    return {
      type: "lookup",
      from: this.secondary,
      key: this.transform.from.key,
      fields: [this.transform.lookup],
      ...t,
      ...this.transform.default ? { default: this.transform.default } : {}
    };
  }
}
class z0 extends He {
  clone() {
    return new z0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const i = this.transform.as ?? [void 0, void 0];
    this.transform.as = [i[0] ?? "prob", i[1] ?? "value"];
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.quantile, ...this.transform.groupby ?? []]);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `QuantileTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { quantile: t, ...n } = this.transform;
    return {
      type: "quantile",
      field: t,
      ...n
    };
  }
}
class B0 extends He {
  clone() {
    return new B0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n, this.transform = me(n);
    const i = this.transform.as ?? [void 0, void 0];
    this.transform.as = [i[0] ?? n.on, i[1] ?? n.regression];
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.regression, this.transform.on, ...this.transform.groupby ?? []]);
  }
  producedFields() {
    return new Set(this.transform.as);
  }
  hash() {
    return `RegressionTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { regression: t, on: n, ...i } = this.transform;
    return {
      type: "regression",
      x: n,
      y: t,
      ...i
    };
  }
}
class j0 extends He {
  clone() {
    return new j0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n;
  }
  addDimensions(t) {
    this.transform.groupby = xr((this.transform.groupby ?? []).concat(t), (n) => n);
  }
  producedFields() {
  }
  dependentFields() {
    return /* @__PURE__ */ new Set([this.transform.pivot, this.transform.value, ...this.transform.groupby ?? []]);
  }
  hash() {
    return `PivotTransform ${$e(this.transform)}`;
  }
  assemble() {
    const { pivot: t, value: n, groupby: i, limit: r, op: s } = this.transform;
    return {
      type: "pivot",
      field: t,
      value: n,
      ...r !== void 0 ? { limit: r } : {},
      ...s !== void 0 ? { op: s } : {},
      ...i !== void 0 ? { groupby: i } : {}
    };
  }
}
class U0 extends He {
  clone() {
    return new U0(null, me(this.transform));
  }
  constructor(t, n) {
    super(t), this.transform = n;
  }
  dependentFields() {
    return /* @__PURE__ */ new Set();
  }
  producedFields() {
    return /* @__PURE__ */ new Set();
  }
  hash() {
    return `SampleTransform ${$e(this.transform)}`;
  }
  assemble() {
    return {
      type: "sample",
      size: this.transform.sample
    };
  }
}
function sP(e) {
  let t = 0;
  function n(i, r) {
    if (i instanceof Xa && !i.isGenerator && !$u(i.data) && (e.push(r), r = {
      name: null,
      source: r.name,
      transform: []
    }), i instanceof tn && (i.parent instanceof Xa && !r.source ? (r.format = {
      ...r.format ?? {},
      parse: i.assembleFormatParse()
    }, r.transform.push(...i.assembleTransforms(!0))) : r.transform.push(...i.assembleTransforms())), i instanceof ec) {
      r.name || (r.name = `data_${t++}`), !r.source || r.transform.length > 0 ? (e.push(r), i.data = r.name) : i.data = r.source, e.push(...i.assemble());
      return;
    }
    switch ((i instanceof jd || i instanceof Ud || i instanceof Xf || i instanceof Zu || i instanceof Fu || i instanceof Kf || i instanceof Xi || i instanceof Jf || i instanceof tc || i instanceof gl || i instanceof P0 || i instanceof L0 || i instanceof D0 || i instanceof I0 || i instanceof z0 || i instanceof B0 || i instanceof Fo || i instanceof U0 || i instanceof j0 || i instanceof R0) && r.transform.push(i.assemble()), (i instanceof Ar || i instanceof kr || i instanceof Ca || i instanceof vs || i instanceof Kl) && r.transform.push(...i.assemble()), i instanceof xn && (r.source && r.transform.length === 0 ? i.setSource(r.source) : i.parent instanceof xn ? i.setSource(r.name) : (r.name || (r.name = `data_${t++}`), i.setSource(r.name), i.numChildren() === 1 && (e.push(r), r = {
      name: null,
      source: r.name,
      transform: []
    }))), i.numChildren()) {
      case 0:
        i instanceof xn && (!r.source || r.transform.length > 0) && e.push(r);
        break;
      case 1:
        n(i.children[0], r);
        break;
      default: {
        r.name || (r.name = `data_${t++}`);
        let s = r.name;
        !r.source || r.transform.length > 0 ? e.push(r) : s = r.source;
        for (const o of i.children)
          n(o, {
            name: null,
            source: s,
            transform: []
          });
        break;
      }
    }
  }
  return n;
}
function Wde(e) {
  const t = [], n = sP(t);
  for (const i of e.children)
    n(i, {
      source: e.name,
      name: null,
      transform: []
    });
  return t;
}
function Hde(e, t) {
  const n = [], i = sP(n);
  let r = 0;
  for (const o of e.sources) {
    o.hasName() || (o.dataName = `source_${r++}`);
    const a = o.assemble();
    i(o, a);
  }
  for (const o of n)
    o.transform.length === 0 && delete o.transform;
  let s = 0;
  for (const [o, a] of n.entries())
    (a.transform ?? []).length === 0 && !a.source && n.splice(s++, 0, n.splice(o, 1)[0]);
  for (const o of n)
    for (const a of o.transform ?? [])
      a.type === "lookup" && (a.from = e.outputNodes[a.from].getSource());
  for (const o of n)
    o.name in t && (o.values = t[o.name]);
  return n;
}
function Gde(e) {
  return e === "top" || e === "left" || oe(e) ? "header" : "footer";
}
function Vde(e) {
  for (const t of yi)
    Yde(e, t);
  RM(e, "x"), RM(e, "y");
}
function Yde(e, t) {
  var o;
  const { facet: n, config: i, child: r, component: s } = e;
  if (e.channelHasField(t)) {
    const a = n[t], l = Ou("title", null, i, t);
    let u = Yl(a, i, {
      allowDisabling: !0,
      includeDefault: l === void 0 || !!l
    });
    r.component.layoutHeaders[t].title && (u = U(u) ? u.join(", ") : u, u += ` / ${r.component.layoutHeaders[t].title}`, r.component.layoutHeaders[t].title = null);
    const c = Ou("labelOrient", a.header, i, t), f = a.header !== null ? dt((o = a.header) == null ? void 0 : o.labels, i.header.labels, !0) : !1, d = Me(["bottom", "right"], c) ? "footer" : "header";
    s.layoutHeaders[t] = {
      title: a.header !== null ? u : null,
      facetFieldDef: a,
      [d]: t === "facet" ? [] : [oP(e, t, f)]
    };
  }
}
function oP(e, t, n) {
  const i = t === "row" ? "height" : "width";
  return {
    labels: n,
    sizeSignal: e.child.component.layoutSize.get(i) ? e.child.getSizeSignalRef(i) : void 0,
    axes: []
  };
}
function RM(e, t) {
  const { child: n } = e;
  if (n.component.axes[t]) {
    const { layoutHeaders: i, resolve: r } = e.component;
    if (r.axis[t] = KE(r, t), r.axis[t] === "shared") {
      const s = t === "x" ? "column" : "row", o = i[s];
      for (const a of n.component.axes[t]) {
        const l = Gde(a.get("orient"));
        o[l] ?? (o[l] = [oP(e, s, !1)]);
        const u = Jc(a, "main", e.config, { header: !0 });
        u && o[l][0].axes.push(u), a.mainExtracted = !0;
      }
    }
  }
}
function Xde(e) {
  rS(e), Rp(e, "width"), Rp(e, "height");
}
function Kde(e) {
  rS(e);
  const t = e.layout.columns === 1 ? "width" : "childWidth", n = e.layout.columns === void 0 ? "height" : "childHeight";
  Rp(e, t), Rp(e, n);
}
function rS(e) {
  for (const t of e.children)
    t.parseLayoutSize();
}
function Rp(e, t) {
  const n = T8(t), i = a0(n), r = e.component.resolve, s = e.component.layoutSize;
  let o;
  for (const a of e.children) {
    const l = a.component.layoutSize.getWithExplicit(n), u = r.scale[i] ?? N8(i, e);
    if (u === "independent" && l.value === "step") {
      o = void 0;
      break;
    }
    if (o) {
      if (u === "independent" && o.value !== l.value) {
        o = void 0;
        break;
      }
      o = Co(o, l, n, "");
    } else
      o = l;
  }
  if (o) {
    for (const a of e.children)
      e.renameSignal(a.getName(n), e.getName(t)), a.component.layoutSize.set(n, "merged", !1);
    s.setWithExplicit(t, o);
  } else
    s.setWithExplicit(t, {
      explicit: !1,
      value: void 0
    });
}
function Jde(e) {
  const { size: t, component: n } = e;
  for (const i of Vr) {
    const r = qn(i);
    if (t[r]) {
      const s = t[r];
      n.layoutSize.set(r, Lr(s) ? "step" : s, !0);
    } else {
      const s = Qde(e, r);
      n.layoutSize.set(r, s, !1);
    }
  }
}
function Qde(e, t) {
  const n = t === "width" ? "x" : "y", i = e.config, r = e.getScaleComponent(n);
  if (r) {
    const s = r.get("type"), o = r.get("range");
    if (Rt(s)) {
      const a = Tp(i.view, t);
      return Wo(o) || Lr(a) ? "step" : a;
    } else
      return bv(i.view, t);
  } else {
    if (e.hasProjection || e.mark === "arc")
      return bv(i.view, t);
    {
      const s = Tp(i.view, t);
      return Lr(s) ? s.step : s;
    }
  }
}
function Ov(e, t, n) {
  return J(t, { suffix: `by_${J(e)}`, ...n ?? {} });
}
class pf extends rP {
  constructor(t, n, i, r) {
    super(t, "facet", n, i, r, t.resolve), this.child = uS(t.spec, this, this.getName("child"), void 0, r), this.children = [this.child], this.facet = this.initFacet(t.facet);
  }
  initFacet(t) {
    if (!Ld(t))
      return { facet: this.initFacetFieldDef(t, "facet") };
    const n = q(t), i = {};
    for (const r of n) {
      if (![ms, ys].includes(r)) {
        G(c0(r, "facet"));
        break;
      }
      const s = t[r];
      if (s.field === void 0) {
        G(hv(s, r));
        break;
      }
      i[r] = this.initFacetFieldDef(s, r);
    }
    return i;
  }
  initFacetFieldDef(t, n) {
    const i = CE(t, n);
    return i.header ? i.header = Fn(i.header) : i.header === null && (i.header = null), i;
  }
  channelHasField(t) {
    return !!this.facet[t];
  }
  fieldDef(t) {
    return this.facet[t];
  }
  parseData() {
    this.component.data = q0(this), this.child.parseData();
  }
  parseLayoutSize() {
    rS(this);
  }
  parseSelections() {
    this.child.parseSelections(), this.component.selection = this.child.component.selection;
  }
  parseMarkGroup() {
    this.child.parseMarkGroup();
  }
  parseAxesAndHeaders() {
    this.child.parseAxesAndHeaders(), Vde(this);
  }
  assembleSelectionTopLevelSignals(t) {
    return this.child.assembleSelectionTopLevelSignals(t);
  }
  assembleSignals() {
    return this.child.assembleSignals(), [];
  }
  assembleSelectionData(t) {
    return this.child.assembleSelectionData(t);
  }
  getHeaderLayoutMixins() {
    const t = {};
    for (const n of yi)
      for (const i of YE) {
        const r = this.component.layoutHeaders[n], s = r[i], { facetFieldDef: o } = r;
        if (o) {
          const a = Ou("titleOrient", o.header, this.config, n);
          if (["right", "bottom"].includes(a)) {
            const l = T0(n, a);
            t.titleAnchor ?? (t.titleAnchor = {}), t.titleAnchor[l] = "end";
          }
        }
        if (s != null && s[0]) {
          const a = n === "row" ? "height" : "width", l = i === "header" ? "headerBand" : "footerBand";
          n !== "facet" && !this.child.component.layoutSize.get(a) && (t[l] ?? (t[l] = {}), t[l][n] = 0.5), r.title && (t.offset ?? (t.offset = {}), t.offset[n === "row" ? "rowTitle" : "columnTitle"] = 10);
        }
      }
    return t;
  }
  assembleDefaultLayout() {
    const { column: t, row: n } = this.facet, i = t ? this.columnDistinctSignal() : n ? 1 : void 0;
    let r = "all";
    return (!n && this.component.resolve.scale.x === "independent" || !t && this.component.resolve.scale.y === "independent") && (r = "none"), {
      ...this.getHeaderLayoutMixins(),
      ...i ? { columns: i } : {},
      bounds: "full",
      align: r
    };
  }
  assembleLayoutSignals() {
    return this.child.assembleLayoutSignals();
  }
  columnDistinctSignal() {
    if (!(this.parent && this.parent instanceof pf))
      return { signal: `length(data('${this.getName("column_domain")}'))` };
  }
  assembleGroupStyle() {
  }
  assembleGroup(t) {
    return this.parent && this.parent instanceof pf ? {
      ...this.channelHasField("column") ? {
        encode: {
          update: {
            // TODO(https://github.com/vega/vega-lite/issues/2759):
            // Correct the signal for facet of concat of facet_column
            columns: { field: J(this.facet.column, { prefix: "distinct" }) }
          }
        }
      } : {},
      ...super.assembleGroup(t)
    } : super.assembleGroup(t);
  }
  /**
   * Aggregate cardinality for calculating size
   */
  getCardinalityAggregateForChild() {
    const t = [], n = [], i = [];
    if (this.child instanceof pf) {
      if (this.child.channelHasField("column")) {
        const r = J(this.child.facet.column);
        t.push(r), n.push("distinct"), i.push(`distinct_${r}`);
      }
    } else
      for (const r of Vr) {
        const s = this.child.component.scales[r];
        if (s && !s.merged) {
          const o = s.get("type"), a = s.get("range");
          if (Rt(o) && Wo(a)) {
            const l = N0(this.child, r), u = tS(l);
            u ? (t.push(u), n.push("distinct"), i.push(`distinct_${u}`)) : G(nE(r));
          }
        }
      }
    return { fields: t, ops: n, as: i };
  }
  assembleFacet() {
    const { name: t, data: n } = this.component.data.facetRoot, { row: i, column: r } = this.facet, { fields: s, ops: o, as: a } = this.getCardinalityAggregateForChild(), l = [];
    for (const c of yi) {
      const f = this.facet[c];
      if (f) {
        l.push(J(f));
        const { bin: d, sort: h } = f;
        if (Je(d) && l.push(J(f, { binSuffix: "end" })), Sr(h)) {
          const { field: g, op: p = m0 } = h, m = Ov(f, h);
          i && r ? (s.push(m), o.push("max"), a.push(m)) : (s.push(g), o.push(p), a.push(m));
        } else if (U(h)) {
          const g = Tu(f, c);
          s.push(g), o.push("max"), a.push(g);
        }
      }
    }
    const u = !!i && !!r;
    return {
      name: t,
      data: n,
      groupby: l,
      ...u || s.length > 0 ? {
        aggregate: {
          ...u ? { cross: u } : {},
          ...s.length ? { fields: s, ops: o, as: a } : {}
        }
      } : {}
    };
  }
  facetSortFields(t) {
    const { facet: n } = this, i = n[t];
    return i ? Sr(i.sort) ? [Ov(i, i.sort, { expr: "datum" })] : U(i.sort) ? [Tu(i, t, { expr: "datum" })] : [J(i, { expr: "datum" })] : [];
  }
  facetSortOrder(t) {
    const { facet: n } = this, i = n[t];
    if (i) {
      const { sort: r } = i;
      return [(Sr(r) ? r.order : !U(r) && r) || "ascending"];
    }
    return [];
  }
  assembleLabelTitle() {
    var r;
    const { facet: t, config: n } = this;
    if (t.facet)
      return Av(t.facet, "facet", n);
    const i = {
      row: ["top", "bottom"],
      column: ["left", "right"]
    };
    for (const s of VE)
      if (t[s]) {
        const o = Ou("labelOrient", (r = t[s]) == null ? void 0 : r.header, n, s);
        if (i[s].includes(o))
          return Av(t[s], s, n);
      }
  }
  assembleMarks() {
    const { child: t } = this, n = this.component.data.facetRoot, i = Wde(n), r = t.assembleGroupEncodeEntry(!1), s = this.assembleLabelTitle() || t.assembleTitle(), o = t.assembleGroupStyle();
    return [{
      name: this.getName("cell"),
      type: "group",
      ...s ? { title: s } : {},
      ...o ? { style: o } : {},
      from: {
        facet: this.assembleFacet()
      },
      // TODO: move this to after data
      sort: {
        field: yi.map((l) => this.facetSortFields(l)).flat(),
        order: yi.map((l) => this.facetSortOrder(l)).flat()
      },
      ...i.length > 0 ? { data: i } : {},
      ...r ? { encode: { update: r } } : {},
      ...t.assembleGroup(uce(this, []))
    }];
  }
  getMapping() {
    return this.facet;
  }
}
function Zde(e, t) {
  const { row: n, column: i } = t;
  if (n && i) {
    let r = null;
    for (const s of [n, i])
      if (Sr(s.sort)) {
        const { field: o, op: a = m0 } = s.sort;
        e = r = new gl(e, {
          joinaggregate: [
            {
              op: a,
              field: o,
              as: Ov(s, s.sort, { forAs: !0 })
            }
          ],
          groupby: [J(s)]
        });
      }
    return r;
  }
  return null;
}
function aP(e, t) {
  var n, i, r, s;
  for (const o of t) {
    const a = o.data;
    if (e.name && o.hasName() && e.name !== o.dataName)
      continue;
    const l = (n = e.format) == null ? void 0 : n.mesh, u = (i = a.format) == null ? void 0 : i.feature;
    if (l && u)
      continue;
    const c = (r = e.format) == null ? void 0 : r.feature;
    if ((c || u) && c !== u)
      continue;
    const f = (s = a.format) == null ? void 0 : s.mesh;
    if (!((l || f) && l !== f)) {
      if (Yf(e) && Yf(a)) {
        if (Qn(e.values, a.values))
          return o;
      } else if ($u(e) && $u(a)) {
        if (e.url === a.url)
          return o;
      } else if (KL(e) && e.name === o.dataName)
        return o;
    }
  }
  return null;
}
function ehe(e, t) {
  if (e.data || !e.parent) {
    if (e.data === null) {
      const i = new Xa({ values: [] });
      return t.push(i), i;
    }
    const n = aP(e.data, t);
    if (n)
      return co(e.data) || (n.data.format = G6({}, e.data.format, n.data.format)), !n.hasName() && e.data.name && (n.dataName = e.data.name), n;
    {
      const i = new Xa(e.data);
      return t.push(i), i;
    }
  } else
    return e.parent.component.data.facetRoot ? e.parent.component.data.facetRoot : e.parent.component.data.main;
}
function the(e, t, n) {
  let i = 0;
  for (const r of t.transforms) {
    let s, o;
    if (que(r))
      o = e = new Fu(e, r), s = "derived";
    else if (BE(r)) {
      const a = Gfe(r);
      o = e = tn.makeWithAncestors(e, {}, a, n) ?? e, e = new Zu(e, t, r.filter);
    } else if (HL(r))
      o = e = Ar.makeFromTransform(e, r, t), s = "number";
    else if (Hue(r))
      s = "date", n.getWithExplicit(r.field).value === void 0 && (e = new tn(e, { [r.field]: s }), n.set(r.field, s, !1)), o = e = kr.makeFromTransform(e, r);
    else if (Gue(r))
      o = e = Xi.makeFromTransform(e, r), s = "number", GE(t) && (e = new Fo(e));
    else if (WL(r))
      o = e = Jf.make(e, t, r, i++), s = "derived";
    else if (Bue(r))
      o = e = new tc(e, r), s = "number";
    else if (jue(r))
      o = e = new gl(e, r), s = "number";
    else if (Vue(r))
      o = e = vs.makeFromTransform(e, r), s = "derived";
    else if (Yue(r))
      o = e = new P0(e, r), s = "derived";
    else if (Xue(r))
      o = e = new R0(e, r), s = "derived";
    else if (Uue(r))
      o = e = new L0(e, r), s = "derived";
    else if (Due(r))
      o = e = new j0(e, r), s = "derived";
    else if (zue(r))
      e = new U0(e, r);
    else if (Wue(r))
      o = e = Ca.makeFromTransform(e, r), s = "derived";
    else if (Rue(r))
      o = e = new D0(e, r), s = "derived";
    else if (Lue(r))
      o = e = new z0(e, r), s = "derived";
    else if (Pue(r))
      o = e = new B0(e, r), s = "derived";
    else if (Iue(r))
      o = e = new I0(e, r), s = "derived";
    else {
      G(poe(r));
      continue;
    }
    if (o && s !== void 0)
      for (const a of o.producedFields() ?? [])
        n.set(a, s, !1);
  }
  return e;
}
function q0(e) {
  var p;
  let t = ehe(e, e.component.data.sources);
  const { outputNodes: n, outputNodeRefCounts: i } = e.component.data, r = e.data, o = !(r && (co(r) || $u(r) || Yf(r))) && e.parent ? e.parent.component.data.ancestorParse.clone() : new ace();
  co(r) ? (JL(r) ? t = new Ud(t, r.sequence) : jE(r) && (t = new jd(t, r.graticule)), o.parseNothing = !0) : ((p = r == null ? void 0 : r.format) == null ? void 0 : p.parse) === null && (o.parseNothing = !0), t = tn.makeExplicit(t, e, o) ?? t, t = new Fo(t);
  const a = e.parent && nc(e.parent);
  (at(e) || Ki(e)) && a && (t = Ar.makeFromEncoding(t, e) ?? t), e.transforms.length > 0 && (t = the(t, e, o));
  const l = Yfe(e), u = Vfe(e);
  t = tn.makeWithAncestors(t, {}, { ...l, ...u }, o) ?? t, at(e) && (t = Kl.parseAll(t, e), t = Kf.parseAll(t, e)), (at(e) || Ki(e)) && (a || (t = Ar.makeFromEncoding(t, e) ?? t), t = kr.makeFromEncoding(t, e) ?? t, t = Fu.parseAllForSortIndex(t, e));
  const c = e.getDataName(Ke.Raw), f = new xn(t, c, Ke.Raw, i);
  if (n[c] = f, t = f, at(e)) {
    const m = Xi.makeFromEncoding(t, e);
    m && (t = m, GE(e) && (t = new Fo(t))), t = Ca.makeFromEncoding(t, e) ?? t, t = vs.makeFromEncoding(t, e) ?? t;
  }
  at(e) && (t = Xf.make(t, e) ?? t);
  const d = e.getDataName(Ke.Main), h = new xn(t, d, Ke.Main, i);
  n[d] = h, t = h, at(e) && qce(e, h);
  let g = null;
  if (Ki(e)) {
    const m = e.getName("facet");
    t = Zde(t, e.facet) ?? t, g = new ec(t, e, m, h.getSource()), n[m] = g;
  }
  return {
    ...e.component.data,
    outputNodes: n,
    outputNodeRefCounts: i,
    raw: f,
    main: h,
    facetRoot: g,
    ancestorParse: o
  };
}
class nhe extends iS {
  constructor(t, n, i, r) {
    var s, o, a, l;
    super(t, "concat", n, i, r, t.resolve), (((o = (s = t.resolve) == null ? void 0 : s.axis) == null ? void 0 : o.x) === "shared" || ((l = (a = t.resolve) == null ? void 0 : a.axis) == null ? void 0 : l.y) === "shared") && G(doe), this.children = this.getChildren(t).map((u, c) => uS(u, this, this.getName(`concat_${c}`), void 0, r));
  }
  parseData() {
    this.component.data = q0(this);
    for (const t of this.children)
      t.parseData();
  }
  parseSelections() {
    this.component.selection = {};
    for (const t of this.children) {
      t.parseSelections();
      for (const n of q(t.component.selection))
        this.component.selection[n] = t.component.selection[n];
    }
  }
  parseMarkGroup() {
    for (const t of this.children)
      t.parseMarkGroup();
  }
  parseAxesAndHeaders() {
    for (const t of this.children)
      t.parseAxesAndHeaders();
  }
  getChildren(t) {
    return S0(t) ? t.vconcat : IE(t) ? t.hconcat : t.concat;
  }
  parseLayoutSize() {
    Kde(this);
  }
  parseAxisGroup() {
    return null;
  }
  assembleSelectionTopLevelSignals(t) {
    return this.children.reduce((n, i) => i.assembleSelectionTopLevelSignals(n), t);
  }
  assembleSignals() {
    return this.children.forEach((t) => t.assembleSignals()), [];
  }
  assembleLayoutSignals() {
    const t = XE(this);
    for (const n of this.children)
      t.push(...n.assembleLayoutSignals());
    return t;
  }
  assembleSelectionData(t) {
    return this.children.reduce((n, i) => i.assembleSelectionData(n), t);
  }
  assembleMarks() {
    return this.children.map((t) => {
      const n = t.assembleTitle(), i = t.assembleGroupStyle(), r = t.assembleGroupEncodeEntry(!1);
      return {
        type: "group",
        name: t.getName("group"),
        ...n ? { title: n } : {},
        ...i ? { style: i } : {},
        ...r ? { encode: { update: r } } : {},
        ...t.assembleGroup()
      };
    });
  }
  assembleGroupStyle() {
  }
  assembleDefaultLayout() {
    const t = this.layout.columns;
    return {
      ...t != null ? { columns: t } : {},
      bounds: "full",
      // Use align each so it can work with multiple plots with different size
      align: "each"
    };
  }
}
function ihe(e) {
  return e === !1 || e === null;
}
const rhe = {
  disable: 1,
  gridScale: 1,
  scale: 1,
  ...pL,
  labelExpr: 1,
  encode: 1
}, lP = q(rhe);
class sS extends Is {
  constructor(t = {}, n = {}, i = !1) {
    super(), this.explicit = t, this.implicit = n, this.mainExtracted = i;
  }
  clone() {
    return new sS(me(this.explicit), me(this.implicit), this.mainExtracted);
  }
  hasAxisPart(t) {
    return t === "axis" ? !0 : t === "grid" || t === "title" ? !!this.get(t) : !ihe(this.get(t));
  }
  hasOrientSignalRef() {
    return oe(this.explicit.orient);
  }
}
function she(e, t, n) {
  const { encoding: i, config: r } = e, s = wt(i[t]) ?? wt(i[Gr(t)]), o = e.axis(t) || {}, { format: a, formatType: l } = o;
  if (Ga(l))
    return {
      text: Vi({
        fieldOrDatumDef: s,
        field: "datum.value",
        format: a,
        formatType: l,
        config: r
      }),
      ...n
    };
  if (a === void 0 && l === void 0 && r.customFormatTypes) {
    if (ku(s) === "quantitative") {
      if (Au(s) && s.stack === "normalize" && r.normalizedNumberFormatType)
        return {
          text: Vi({
            fieldOrDatumDef: s,
            field: "datum.value",
            format: r.normalizedNumberFormat,
            formatType: r.normalizedNumberFormatType,
            config: r
          }),
          ...n
        };
      if (r.numberFormatType)
        return {
          text: Vi({
            fieldOrDatumDef: s,
            field: "datum.value",
            format: r.numberFormat,
            formatType: r.numberFormatType,
            config: r
          }),
          ...n
        };
    }
    if (ku(s) === "temporal" && r.timeFormatType && H(s) && !s.timeUnit)
      return {
        text: Vi({
          fieldOrDatumDef: s,
          field: "datum.value",
          format: r.timeFormat,
          formatType: r.timeFormatType,
          config: r
        }),
        ...n
      };
  }
  return n;
}
function ohe(e) {
  return Vr.reduce((t, n) => (e.component.scales[n] && (t[n] = [hhe(n, e)]), t), {});
}
const ahe = {
  bottom: "top",
  top: "bottom",
  left: "right",
  right: "left"
};
function lhe(e) {
  const { axes: t, resolve: n } = e.component, i = { top: 0, bottom: 0, right: 0, left: 0 };
  for (const r of e.children) {
    r.parseAxesAndHeaders();
    for (const s of q(r.component.axes))
      n.axis[s] = KE(e.component.resolve, s), n.axis[s] === "shared" && (t[s] = uhe(t[s], r.component.axes[s]), t[s] || (n.axis[s] = "independent", delete t[s]));
  }
  for (const r of Vr) {
    for (const s of e.children)
      if (s.component.axes[r]) {
        if (n.axis[r] === "independent") {
          t[r] = (t[r] ?? []).concat(s.component.axes[r]);
          for (const o of s.component.axes[r]) {
            const { value: a, explicit: l } = o.getWithExplicit("orient");
            if (!oe(a)) {
              if (i[a] > 0 && !l) {
                const u = ahe[a];
                i[a] > i[u] && o.set("orient", u, !1);
              }
              i[a]++;
            }
          }
        }
        delete s.component.axes[r];
      }
    if (n.axis[r] === "independent" && t[r] && t[r].length > 1)
      for (const [s, o] of (t[r] || []).entries())
        s > 0 && o.get("grid") && !o.explicit.grid && (o.implicit.grid = !1);
  }
}
function uhe(e, t) {
  if (e) {
    if (e.length !== t.length)
      return;
    const n = e.length;
    for (let i = 0; i < n; i++) {
      const r = e[i], s = t[i];
      if (!!r != !!s)
        return;
      if (r && s) {
        const o = r.getWithExplicit("orient"), a = s.getWithExplicit("orient");
        if (o.explicit && a.explicit && o.value !== a.value)
          return;
        e[i] = che(r, s);
      }
    }
  } else
    return t.map((n) => n.clone());
  return e;
}
function che(e, t) {
  for (const n of lP) {
    const i = Co(
      e.getWithExplicit(n),
      t.getWithExplicit(n),
      n,
      "axis",
      // Tie breaker function
      (r, s) => {
        switch (n) {
          case "title":
            return x4(r, s);
          case "gridScale":
            return {
              explicit: r.explicit,
              value: dt(r.value, s.value)
            };
        }
        return A0(r, s, n, "axis");
      }
    );
    e.setWithExplicit(n, i);
  }
  return e;
}
function fhe(e, t, n, i, r) {
  if (t === "disable")
    return n !== void 0;
  switch (n = n || {}, t) {
    case "titleAngle":
    case "labelAngle":
      return e === (oe(n.labelAngle) ? n.labelAngle : Gf(n.labelAngle));
    case "values":
      return !!n.values;
    case "encode":
      return !!n.encoding || !!n.labelAngle;
    case "title":
      if (e === A8(i, r))
        return !0;
  }
  return e === n[t];
}
const dhe = /* @__PURE__ */ new Set([
  "grid",
  "translate",
  // the rest are not axis configs in Vega, but are in VL, so we need to set too.
  "format",
  "formatType",
  "orient",
  "labelExpr",
  "tickCount",
  "position",
  "tickMinStep"
]);
function hhe(e, t) {
  var y, b;
  let n = t.axis(e);
  const i = new sS(), r = wt(t.encoding[e]), { mark: s, config: o } = t, a = (n == null ? void 0 : n.orient) || ((y = o[e === "x" ? "axisX" : "axisY"]) == null ? void 0 : y.orient) || ((b = o.axis) == null ? void 0 : b.orient) || Zce(e), l = t.getScaleComponent(e).get("type"), u = Gce(e, l, a, t.config), c = n !== void 0 ? !n : Sv("disable", o.style, n == null ? void 0 : n.style, u).configValue;
  if (i.set("disable", c, n !== void 0), c)
    return i;
  n = n || {};
  const f = Kce(r, n, e, o.style, u), d = eL(n.formatType, r, l), h = Z4(r, r.type, n.format, n.formatType, o, !0), g = {
    fieldOrDatumDef: r,
    axis: n,
    channel: e,
    model: t,
    scaleType: l,
    orient: a,
    labelAngle: f,
    format: h,
    formatType: d,
    mark: s,
    config: o
  };
  for (const v of lP) {
    const _ = v in xM ? xM[v](g) : V$(v) ? n[v] : void 0, x = _ !== void 0, S = fhe(_, v, n, t, e);
    if (x && S)
      i.set(v, _, S);
    else {
      const { configValue: E = void 0, configFrom: C = void 0 } = V$(v) && v !== "values" ? Sv(v, o.style, n.style, u) : {}, $ = E !== void 0;
      x && !$ ? i.set(v, _, S) : (
        // Cases need implicit values
        // 1. Axis config that aren't available in Vega
        (C !== "vgAxisConfig" || // 2. Certain properties are always included (see `propsToAlwaysIncludeConfig`'s declaration for more details)
        dhe.has(v) && $ || // 3. Conditional axis values and signals
        zd(E) || oe(E)) && i.set(v, E, !1)
      );
    }
  }
  const p = n.encoding ?? {}, m = gL.reduce((v, _) => {
    if (!i.hasAxisPart(_))
      return v;
    const x = O8(p[_] ?? {}, t), S = _ === "labels" ? she(t, e, x) : x;
    return S !== void 0 && !Ge(S) && (v[_] = { update: S }), v;
  }, {});
  return Ge(m) || i.set("encode", m, !!n.encoding || n.labelAngle !== void 0), i;
}
function ghe({ encoding: e, size: t }) {
  for (const n of Vr) {
    const i = qn(n);
    Lr(t[i]) && ro(e[n]) && (delete t[i], G(k4(i)));
  }
  return t;
}
const phe = {
  vgMark: "arc",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      size: "ignore",
      orient: "ignore",
      theta: "ignore"
    }),
    ...en("x", e, { defaultPos: "mid" }),
    ...en("y", e, { defaultPos: "mid" }),
    // arcs are rectangles in polar coordinates
    ...$o(e, "radius"),
    ...$o(e, "theta")
  })
}, mhe = {
  vgMark: "area",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      orient: "include",
      size: "ignore",
      theta: "ignore"
    }),
    ...Op("x", e, {
      defaultPos: "zeroOrMin",
      defaultPos2: "zeroOrMin",
      range: e.markDef.orient === "horizontal"
    }),
    ...Op("y", e, {
      defaultPos: "zeroOrMin",
      defaultPos2: "zeroOrMin",
      range: e.markDef.orient === "vertical"
    }),
    ...HE(e)
  })
}, yhe = {
  vgMark: "rect",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      orient: "ignore",
      size: "ignore",
      theta: "ignore"
    }),
    ...$o(e, "x"),
    ...$o(e, "y")
  })
}, bhe = {
  vgMark: "shape",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      size: "ignore",
      orient: "ignore",
      theta: "ignore"
    })
  }),
  postEncodingTransform: (e) => {
    const { encoding: t } = e, n = t.shape;
    return [{
      type: "geoshape",
      projection: e.projectionName(),
      // as: 'shape',
      ...n && H(n) && n.type === Ju ? { field: J(n, { expr: "datum" }) } : {}
    }];
  }
}, vhe = {
  vgMark: "image",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "ignore",
      orient: "ignore",
      size: "ignore",
      theta: "ignore"
    }),
    ...$o(e, "x"),
    ...$o(e, "y"),
    ...qE(e, "url")
  })
}, xhe = {
  vgMark: "line",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      size: "ignore",
      orient: "ignore",
      theta: "ignore"
    }),
    ...en("x", e, { defaultPos: "mid" }),
    ...en("y", e, { defaultPos: "mid" }),
    ...$t("size", e, {
      vgChannel: "strokeWidth"
      // VL's line size is strokeWidth
    }),
    ...HE(e)
  })
}, whe = {
  vgMark: "trail",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      size: "include",
      orient: "ignore",
      theta: "ignore"
    }),
    ...en("x", e, { defaultPos: "mid" }),
    ...en("y", e, { defaultPos: "mid" }),
    ...$t("size", e),
    ...HE(e)
  })
};
function oS(e, t) {
  const { config: n } = e;
  return {
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      size: "include",
      orient: "ignore",
      theta: "ignore"
    }),
    ...en("x", e, { defaultPos: "mid" }),
    ...en("y", e, { defaultPos: "mid" }),
    ...$t("size", e),
    ...$t("angle", e),
    ..._he(e, n, t)
  };
}
function _he(e, t, n) {
  return n ? { shape: { value: n } } : $t("shape", e);
}
const Ehe = {
  vgMark: "symbol",
  encodeEntry: (e) => oS(e)
}, She = {
  vgMark: "symbol",
  encodeEntry: (e) => oS(e, "circle")
}, khe = {
  vgMark: "symbol",
  encodeEntry: (e) => oS(e, "square")
}, Ahe = {
  vgMark: "rect",
  encodeEntry: (e) => ({
    ...Ti(e, {
      align: "ignore",
      baseline: "ignore",
      color: "include",
      orient: "ignore",
      size: "ignore",
      theta: "ignore"
    }),
    ...$o(e, "x"),
    ...$o(e, "y")
  })
}, Che = {
  vgMark: "rule",
  encodeEntry: (e) => {
    const { markDef: t } = e, n = t.orient;
    return !e.encoding.x && !e.encoding.y && !e.encoding.latitude && !e.encoding.longitude ? {} : {
      ...Ti(e, {
        align: "ignore",
        baseline: "ignore",
        color: "include",
        orient: "ignore",
        size: "ignore",
        theta: "ignore"
      }),
      ...Op("x", e, {
        defaultPos: n === "horizontal" ? "zeroOrMax" : "mid",
        defaultPos2: "zeroOrMin",
        range: n !== "vertical"
        // include x2 for horizontal or line segment rule
      }),
      ...Op("y", e, {
        defaultPos: n === "vertical" ? "zeroOrMax" : "mid",
        defaultPos2: "zeroOrMin",
        range: n !== "horizontal"
        // include y2 for vertical or line segment rule
      }),
      ...$t("size", e, {
        vgChannel: "strokeWidth"
        // VL's rule size is strokeWidth
      })
    };
  }
}, $he = {
  vgMark: "text",
  encodeEntry: (e) => {
    const { config: t, encoding: n } = e;
    return {
      ...Ti(e, {
        align: "include",
        baseline: "include",
        color: "include",
        size: "ignore",
        orient: "ignore",
        theta: "include"
      }),
      ...en("x", e, { defaultPos: "mid" }),
      ...en("y", e, { defaultPos: "mid" }),
      ...qE(e),
      ...$t("size", e, {
        vgChannel: "fontSize"
        // VL's text size is fontSize
      }),
      ...$t("angle", e),
      ...mM("align", Mhe(e.markDef, n, t)),
      ...mM("baseline", Fhe(e.markDef, n, t)),
      ...en("radius", e, { defaultPos: null }),
      ...en("theta", e, { defaultPos: null })
    };
  }
};
function Mhe(e, t, n) {
  if (qe("align", e, n) === void 0)
    return "center";
}
function Fhe(e, t, n) {
  if (qe("baseline", e, n) === void 0)
    return "middle";
}
const The = {
  vgMark: "rect",
  encodeEntry: (e) => {
    const { config: t, markDef: n } = e, i = n.orient, r = i === "horizontal" ? "width" : "height", s = i === "horizontal" ? "height" : "width";
    return {
      ...Ti(e, {
        align: "ignore",
        baseline: "ignore",
        color: "include",
        orient: "ignore",
        size: "ignore",
        theta: "ignore"
      }),
      ...en("x", e, { defaultPos: "mid", vgChannel: "xc" }),
      ...en("y", e, { defaultPos: "mid", vgChannel: "yc" }),
      // size / thickness => width / height
      ...$t("size", e, {
        defaultValue: Ohe(e),
        vgChannel: r
      }),
      [s]: Ze(qe("thickness", n, t))
    };
  }
};
function Ohe(e) {
  const { config: t, markDef: n } = e, { orient: i } = n, r = i === "horizontal" ? "width" : "height", s = e.getScaleComponent(i === "horizontal" ? "x" : "y"), o = qe("size", n, t, { vgChannel: r }) ?? t.tick.bandSize;
  if (o !== void 0)
    return o;
  {
    const a = s ? s.get("range") : void 0;
    return a && Wo(a) && Re(a.step) ? a.step * 3 / 4 : Fp(t.view, r) * 3 / 4;
  }
}
const Eh = {
  arc: phe,
  area: mhe,
  bar: yhe,
  circle: She,
  geoshape: bhe,
  image: vhe,
  line: xhe,
  point: Ehe,
  rect: Ahe,
  rule: Che,
  square: khe,
  text: $he,
  tick: The,
  trail: whe
};
function Nhe(e) {
  if (Me([g0, d0, jae], e.mark)) {
    const t = xL(e.mark, e.encoding);
    if (t.length > 0)
      return Dhe(e, t);
  } else if (e.mark === h0) {
    const t = dv.some((n) => qe(n, e.markDef, e.config));
    if (e.stack && !e.fieldDef("size") && t)
      return Rhe(e);
  }
  return aS(e);
}
const LM = "faceted_path_";
function Dhe(e, t) {
  return [
    {
      name: e.getName("pathgroup"),
      type: "group",
      from: {
        facet: {
          name: LM + e.requestDataName(Ke.Main),
          data: e.requestDataName(Ke.Main),
          groupby: t
        }
      },
      encode: {
        update: {
          width: { field: { group: "width" } },
          height: { field: { group: "height" } }
        }
      },
      // With subfacet for line/area group, need to use faceted data from above.
      marks: aS(e, { fromPrefix: LM })
    }
  ];
}
const PM = "stack_group_";
function Rhe(e) {
  var u;
  const [t] = aS(e, { fromPrefix: PM }), n = e.scaleName(e.stack.fieldChannel), i = (c = {}) => e.vgField(e.stack.fieldChannel, c), r = (c, f) => {
    const d = [
      i({ prefix: "min", suffix: "start", expr: f }),
      i({ prefix: "max", suffix: "start", expr: f }),
      i({ prefix: "min", suffix: "end", expr: f }),
      i({ prefix: "max", suffix: "end", expr: f })
    ];
    return `${c}(${d.map((h) => `scale('${n}',${h})`).join(",")})`;
  };
  let s, o;
  e.stack.fieldChannel === "x" ? (s = {
    ...vu(t.encode.update, ["y", "yc", "y2", "height", ...dv]),
    x: { signal: r("min", "datum") },
    x2: { signal: r("max", "datum") },
    clip: { value: !0 }
  }, o = {
    x: { field: { group: "x" }, mult: -1 },
    height: { field: { group: "height" } }
  }, t.encode.update = {
    ...Nn(t.encode.update, ["y", "yc", "y2"]),
    height: { field: { group: "height" } }
  }) : (s = {
    ...vu(t.encode.update, ["x", "xc", "x2", "width"]),
    y: { signal: r("min", "datum") },
    y2: { signal: r("max", "datum") },
    clip: { value: !0 }
  }, o = {
    y: { field: { group: "y" }, mult: -1 },
    width: { field: { group: "width" } }
  }, t.encode.update = {
    ...Nn(t.encode.update, ["x", "xc", "x2"]),
    width: { field: { group: "width" } }
  });
  for (const c of dv) {
    const f = ks(c, e.markDef, e.config);
    t.encode.update[c] ? (s[c] = t.encode.update[c], delete t.encode.update[c]) : f && (s[c] = Ze(f)), f && (t.encode.update[c] = { value: 0 });
  }
  const a = [];
  if (((u = e.stack.groupbyChannels) == null ? void 0 : u.length) > 0)
    for (const c of e.stack.groupbyChannels) {
      const f = e.fieldDef(c), d = J(f);
      d && a.push(d), (f != null && f.bin || f != null && f.timeUnit) && a.push(J(f, { binSuffix: "end" }));
    }
  return s = [
    "stroke",
    "strokeWidth",
    "strokeJoin",
    "strokeCap",
    "strokeDash",
    "strokeDashOffset",
    "strokeMiterLimit",
    "strokeOpacity"
  ].reduce((c, f) => {
    if (t.encode.update[f])
      return { ...c, [f]: t.encode.update[f] };
    {
      const d = ks(f, e.markDef, e.config);
      return d !== void 0 ? { ...c, [f]: Ze(d) } : c;
    }
  }, s), s.stroke && (s.strokeForeground = { value: !0 }, s.strokeOffset = { value: 0 }), [
    {
      type: "group",
      from: {
        facet: {
          data: e.requestDataName(Ke.Main),
          name: PM + e.requestDataName(Ke.Main),
          groupby: a,
          aggregate: {
            fields: [
              i({ suffix: "start" }),
              i({ suffix: "start" }),
              i({ suffix: "end" }),
              i({ suffix: "end" })
            ],
            ops: ["min", "max", "min", "max"]
          }
        }
      },
      encode: {
        update: s
      },
      marks: [
        {
          type: "group",
          encode: { update: o },
          marks: [t]
        }
      ]
    }
  ];
}
function Lhe(e) {
  var a;
  const { encoding: t, stack: n, mark: i, markDef: r, config: s } = e, o = t.order;
  if (!(!U(o) && er(o) && cv(o.value) || !o && cv(qe("order", r, s)))) {
    if ((U(o) || H(o)) && !n)
      return y4(o, { expr: "datum" });
    if (Ho(i)) {
      const l = r.orient === "horizontal" ? "y" : "x", u = t[l];
      if (H(u)) {
        const c = u.sort;
        if (U(c))
          return {
            field: J(u, { prefix: l, suffix: "sort_index", expr: "datum" })
          };
        if (Sr(c))
          return {
            field: J({
              // FIXME: this op might not already exist?
              // FIXME: what if dimensionChannel (x or y) contains custom domain?
              aggregate: $E(e.encoding) ? c.op : void 0,
              field: c.field
            }, { expr: "datum" })
          };
        if (nL(c)) {
          const f = e.fieldDef(c.encoding);
          return {
            field: J(f, { expr: "datum" }),
            order: c.order
          };
        } else
          return c === null ? void 0 : {
            field: J(u, {
              // For stack with imputation, we only have bin_mid
              binSuffix: (a = e.stack) != null && a.impute ? "mid" : void 0,
              expr: "datum"
            })
          };
      }
      return;
    }
  }
}
function aS(e, t = { fromPrefix: "" }) {
  const { mark: n, markDef: i, encoding: r, config: s } = e, o = dt(i.clip, Phe(e), Ihe(e)), a = p4(i), l = r.key, u = Lhe(e), c = zhe(e), f = qe("aria", i, s), d = Eh[n].postEncodingTransform ? Eh[n].postEncodingTransform(e) : null;
  return [
    {
      name: e.getName("marks"),
      type: Eh[n].vgMark,
      ...o ? { clip: !0 } : {},
      ...a ? { style: a } : {},
      ...l ? { key: l.field } : {},
      ...u ? { sort: u } : {},
      ...c || {},
      ...f === !1 ? { aria: f } : {},
      from: { data: t.fromPrefix + e.requestDataName(Ke.Main) },
      encode: {
        update: Eh[n].encodeEntry(e)
      },
      ...d ? {
        transform: d
      } : {}
    }
  ];
}
function Phe(e) {
  const t = e.getScaleComponent("x"), n = e.getScaleComponent("y");
  return t != null && t.get("selectionExtent") || n != null && n.get("selectionExtent") ? !0 : void 0;
}
function Ihe(e) {
  const t = e.component.projection;
  return t && !t.isFit ? !0 : void 0;
}
function zhe(e) {
  if (!e.component.selection)
    return null;
  const t = q(e.component.selection).length;
  let n = t, i = e.parent;
  for (; i && n === 0; )
    n = q(i.component.selection).length, i = i.parent;
  return n ? {
    interactive: t > 0 || e.mark === "geoshape" || !!e.encoding.tooltip
  } : null;
}
class uP extends rP {
  constructor(t, n, i, r = {}, s) {
    super(t, "unit", n, i, s, void 0, X$(t) ? t.view : void 0), this.specifiedScales = {}, this.specifiedAxes = {}, this.specifiedLegends = {}, this.specifiedProjection = {}, this.selection = [], this.children = [];
    const o = Dr(t.mark) ? { ...t.mark } : { type: t.mark }, a = o.type;
    o.filled === void 0 && (o.filled = Eue(o, s, {
      graticule: t.data && jE(t.data)
    }));
    const l = this.encoding = Cle(t.encoding || {}, a, o.filled, s);
    this.markDef = jL(o, l, s), this.size = ghe({
      encoding: l,
      size: X$(t) ? {
        ...r,
        ...t.width ? { width: t.width } : {},
        ...t.height ? { height: t.height } : {}
      } : r
    }), this.stack = BL(this.markDef, l), this.specifiedScales = this.initScales(a, l), this.specifiedAxes = this.initAxes(l), this.specifiedLegends = this.initLegends(l), this.specifiedProjection = t.projection, this.selection = (t.params ?? []).filter((u) => LE(u));
  }
  get hasProjection() {
    const { encoding: t } = this, n = this.mark === Y4, i = t && Ase.some((r) => be(t[r]));
    return n || i;
  }
  /**
   * Return specified Vega-Lite scale domain for a particular channel
   * @param channel
   */
  scaleDomain(t) {
    const n = this.specifiedScales[t];
    return n ? n.domain : void 0;
  }
  axis(t) {
    return this.specifiedAxes[t];
  }
  legend(t) {
    return this.specifiedLegends[t];
  }
  initScales(t, n) {
    return l0.reduce((i, r) => {
      const s = wt(n[r]);
      return s && (i[r] = this.initScale(s.scale ?? {})), i;
    }, {});
  }
  initScale(t) {
    const { domain: n, range: i } = t, r = Fn(t);
    return U(n) && (r.domain = n.map(Xn)), U(i) && (r.range = i.map(Xn)), r;
  }
  initAxes(t) {
    return Vr.reduce((n, i) => {
      const r = t[i];
      if (be(r) || i === nt && be(t.x2) || i === Pt && be(t.y2)) {
        const s = be(r) ? r.axis : void 0;
        n[i] = s && this.initAxis({ ...s });
      }
      return n;
    }, {});
  }
  initAxis(t) {
    const n = q(t), i = {};
    for (const r of n) {
      const s = t[r];
      i[r] = zd(s) ? g4(s) : Xn(s);
    }
    return i;
  }
  initLegends(t) {
    return Lse.reduce((n, i) => {
      const r = wt(t[i]);
      if (r && Ise(i)) {
        const s = r.legend;
        n[i] = s && Fn(s);
      }
      return n;
    }, {});
  }
  parseData() {
    this.component.data = q0(this);
  }
  parseLayoutSize() {
    Jde(this);
  }
  parseSelections() {
    this.component.selection = Uce(this, this.selection);
  }
  parseMarkGroup() {
    this.component.mark = Nhe(this);
  }
  parseAxesAndHeaders() {
    this.component.axes = ohe(this);
  }
  assembleSelectionTopLevelSignals(t) {
    return cce(this, t);
  }
  assembleSignals() {
    return [...E8(this), ...lce(this, [])];
  }
  assembleSelectionData(t) {
    return fce(this, t);
  }
  assembleLayout() {
    return null;
  }
  assembleLayoutSignals() {
    return XE(this);
  }
  assembleMarks() {
    let t = this.component.mark ?? [];
    return (!this.parent || !nc(this.parent)) && (t = e8(this, t)), t.map(this.correctDataNames);
  }
  assembleGroupStyle() {
    const { style: t } = this.view || {};
    return t !== void 0 ? t : this.encoding.x || this.encoding.y ? "cell" : "view";
  }
  getMapping() {
    return this.encoding;
  }
  get mark() {
    return this.markDef.type;
  }
  channelHasField(t) {
    return ka(this.encoding, t);
  }
  fieldDef(t) {
    const n = this.encoding[t];
    return Rr(n);
  }
  typedFieldDef(t) {
    const n = this.fieldDef(t);
    return En(n) ? n : null;
  }
}
class lS extends iS {
  constructor(t, n, i, r, s) {
    super(t, "layer", n, i, s, t.resolve, t.view);
    const o = {
      ...r,
      ...t.width ? { width: t.width } : {},
      ...t.height ? { height: t.height } : {}
    };
    this.children = t.layer.map((a, l) => {
      if (k0(a))
        return new lS(a, this, this.getName(`layer_${l}`), o, s);
      if (Ps(a))
        return new uP(a, this, this.getName(`layer_${l}`), o, s);
      throw new Error(tE(a));
    });
  }
  parseData() {
    this.component.data = q0(this);
    for (const t of this.children)
      t.parseData();
  }
  parseLayoutSize() {
    Xde(this);
  }
  parseSelections() {
    this.component.selection = {};
    for (const t of this.children) {
      t.parseSelections();
      for (const n of q(t.component.selection))
        this.component.selection[n] = t.component.selection[n];
    }
  }
  parseMarkGroup() {
    for (const t of this.children)
      t.parseMarkGroup();
  }
  parseAxesAndHeaders() {
    lhe(this);
  }
  assembleSelectionTopLevelSignals(t) {
    return this.children.reduce((n, i) => i.assembleSelectionTopLevelSignals(n), t);
  }
  // TODO: Support same named selections across children.
  assembleSignals() {
    return this.children.reduce((t, n) => t.concat(n.assembleSignals()), E8(this));
  }
  assembleLayoutSignals() {
    return this.children.reduce((t, n) => t.concat(n.assembleLayoutSignals()), XE(this));
  }
  assembleSelectionData(t) {
    return this.children.reduce((n, i) => i.assembleSelectionData(n), t);
  }
  assembleGroupStyle() {
    const t = /* @__PURE__ */ new Set();
    for (const i of this.children)
      for (const r of ee(i.assembleGroupStyle()))
        t.add(r);
    const n = Array.from(t);
    return n.length > 1 ? n : n.length === 1 ? n[0] : void 0;
  }
  assembleTitle() {
    let t = super.assembleTitle();
    if (t)
      return t;
    for (const n of this.children)
      if (t = n.assembleTitle(), t)
        return t;
  }
  assembleLayout() {
    return null;
  }
  assembleMarks() {
    return dce(this, this.children.flatMap((t) => t.assembleMarks()));
  }
  assembleLegends() {
    return this.children.reduce((t, n) => t.concat(n.assembleLegends()), B8(this));
  }
}
function uS(e, t, n, i, r) {
  if (y0(e))
    return new pf(e, t, n, r);
  if (k0(e))
    return new lS(e, t, n, i, r);
  if (Ps(e))
    return new uP(e, t, n, i, r);
  if (Jle(e))
    return new nhe(e, t, n, r);
  throw new Error(tE(e));
}
function Bhe(e, t = {}) {
  t.logger && nae(t.logger), t.fieldTitle && fL(t.fieldTitle);
  try {
    const n = zL(Du(t.config, e.config)), i = YL(e, n), r = uS(i, null, "", void 0, n);
    return r.parse(), cde(r.component.data, r), {
      spec: Uhe(r, jhe(e, i.autosize, n, r), e.datasets, e.usermeta),
      normalized: i
    };
  } finally {
    t.logger && iae(), t.fieldTitle && ble();
  }
}
function jhe(e, t, n, i) {
  const r = i.component.layoutSize.get("width"), s = i.component.layoutSize.get("height");
  if (t === void 0 ? (t = { type: "pad" }, i.hasAxisOrientSignalRef() && (t.resize = !0)) : te(t) && (t = { type: t }), r && s && rce(t.type)) {
    if (r === "step" && s === "step")
      G(N$()), t.type = "pad";
    else if (r === "step" || s === "step") {
      const o = r === "step" ? "width" : "height";
      G(N$(a0(o)));
      const a = o === "width" ? "height" : "width";
      t.type = sce(a);
    }
  }
  return {
    ...q(t).length === 1 && t.type ? t.type === "pad" ? {} : { autosize: t.type } : { autosize: t },
    ...aM(n, !1),
    ...aM(e, !0)
  };
}
function Uhe(e, t, n = {}, i) {
  const r = e.config ? fue(e.config) : void 0, s = [].concat(
    e.assembleSelectionData([]),
    // only assemble data in the root
    Hde(e.component.data, n)
  ), o = e.assembleProjections(), a = e.assembleTitle(), l = e.assembleGroupStyle(), u = e.assembleGroupEncodeEntry(!0);
  let c = e.assembleLayoutSignals();
  c = c.filter((h) => (h.name === "width" || h.name === "height") && h.value !== void 0 ? (t[h.name] = +h.value, !1) : !0);
  const { params: f, ...d } = t;
  return {
    $schema: "https://vega.github.io/schema/vega/v5.json",
    ...e.description ? { description: e.description } : {},
    ...d,
    ...a ? { title: a } : {},
    ...l ? { style: l } : {},
    ...u ? { encode: { update: u } } : {},
    data: s,
    ...o.length > 0 ? { projections: o } : {},
    ...e.assembleGroup([
      ...c,
      ...e.assembleSelectionTopLevelSignals([]),
      ...RL(f)
    ]),
    ...r ? { config: r } : {},
    ...i ? { usermeta: i } : {}
  };
}
const qhe = xse.version, Whe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  accessPathDepth: xu,
  accessPathWithDatum: H_,
  compile: Bhe,
  contains: Me,
  deepEqual: Qn,
  deleteNestedProperty: xp,
  duplicate: me,
  entries: So,
  every: U_,
  fieldIntersection: W_,
  flatAccessWithDatum: Y6,
  getFirstDefined: dt,
  hasIntersection: q_,
  hash: $e,
  internalField: J6,
  isBoolean: Hf,
  isEmpty: Ge,
  isEqual: _se,
  isInternalField: Q6,
  isNullOrFalse: cv,
  isNumeric: t0,
  keys: q,
  logicalExpr: hf,
  mergeDeep: G6,
  never: H6,
  normalize: YL,
  normalizeAngle: Gf,
  omit: Nn,
  pick: vu,
  prefixGenerator: fv,
  removePathFromField: G_,
  replaceAll: ja,
  replacePathInField: Ci,
  resetIdCounter: Sse,
  setEqual: V6,
  some: Ba,
  stringify: Ve,
  titleCase: Md,
  unique: xr,
  uniqueId: K6,
  vals: Wt,
  varName: tt,
  version: qhe
}, Symbol.toStringTag, { value: "Module" }));
function cP(e) {
  const [t, n] = /schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1, 3);
  return { library: t, version: n };
}
var Hhe = "vega-themes", Ghe = "2.14.0", Vhe = "Themes for stylized Vega and Vega-Lite visualizations.", Yhe = ["vega", "vega-lite", "themes", "style"], Xhe = "BSD-3-Clause", Khe = {
  name: "UW Interactive Data Lab",
  url: "https://idl.cs.washington.edu"
}, Jhe = [{
  name: "Emily Gu",
  url: "https://github.com/emilygu"
}, {
  name: "Arvind Satyanarayan",
  url: "http://arvindsatya.com"
}, {
  name: "Jeffrey Heer",
  url: "https://idl.cs.washington.edu"
}, {
  name: "Dominik Moritz",
  url: "https://www.domoritz.de"
}], Qhe = "build/vega-themes.js", Zhe = "build/vega-themes.module.js", ege = "build/vega-themes.min.js", tge = "build/vega-themes.min.js", nge = "build/vega-themes.module.d.ts", ige = {
  type: "git",
  url: "https://github.com/vega/vega-themes.git"
}, rge = ["src", "build"], sge = {
  prebuild: "yarn clean",
  build: "rollup -c",
  clean: "rimraf build && rimraf examples/build",
  "copy:data": "rsync -r node_modules/vega-datasets/data/* examples/data",
  "copy:build": "rsync -r build/* examples/build",
  "deploy:gh": "yarn build && mkdir -p examples/build && rsync -r build/* examples/build && gh-pages -d examples",
  preversion: "yarn lint",
  serve: "browser-sync start -s -f build examples --serveStatic examples",
  start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
  format: "eslint . --fix",
  lint: "eslint .",
  release: "release-it"
}, oge = {
  "@babel/core": "^7.22.9",
  "@babel/plugin-proposal-async-generator-functions": "^7.20.7",
  "@babel/plugin-proposal-json-strings": "^7.18.6",
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
  "@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
  "@babel/plugin-transform-runtime": "^7.22.9",
  "@babel/preset-env": "^7.22.9",
  "@babel/preset-typescript": "^7.22.5",
  "@release-it/conventional-changelog": "^7.0.0",
  "@rollup/plugin-json": "^6.0.0",
  "@rollup/plugin-node-resolve": "^15.1.0",
  "@rollup/plugin-terser": "^0.4.3",
  "@typescript-eslint/eslint-plugin": "^6.0.0",
  "@typescript-eslint/parser": "^6.0.0",
  "browser-sync": "^2.29.3",
  concurrently: "^8.2.0",
  eslint: "^8.45.0",
  "eslint-config-prettier": "^8.8.0",
  "eslint-plugin-prettier": "^5.0.0",
  "gh-pages": "^5.0.0",
  prettier: "^3.0.0",
  "release-it": "^16.1.0",
  rollup: "^3.26.2",
  "rollup-plugin-bundle-size": "^1.0.3",
  "rollup-plugin-ts": "^3.2.0",
  typescript: "^5.1.6",
  vega: "^5.25.0",
  "vega-lite": "^5.9.3"
}, age = {
  vega: "*",
  "vega-lite": "*"
}, lge = {}, uge = {
  name: Hhe,
  version: Ghe,
  description: Vhe,
  keywords: Yhe,
  license: Xhe,
  author: Khe,
  contributors: Jhe,
  main: Qhe,
  module: Zhe,
  unpkg: ege,
  jsdelivr: tge,
  types: nge,
  repository: ige,
  files: rge,
  scripts: sge,
  devDependencies: oge,
  peerDependencies: age,
  dependencies: lge
};
const Cl = "#fff", IM = "#888", cge = {
  background: "#333",
  view: {
    stroke: IM
  },
  title: {
    color: Cl,
    subtitleColor: Cl
  },
  style: {
    "guide-label": {
      fill: Cl
    },
    "guide-title": {
      fill: Cl
    }
  },
  axis: {
    domainColor: Cl,
    gridColor: IM,
    tickColor: Cl
  }
}, Ko = "#4572a7", fge = {
  background: "#fff",
  arc: {
    fill: Ko
  },
  area: {
    fill: Ko
  },
  line: {
    stroke: Ko,
    strokeWidth: 2
  },
  path: {
    stroke: Ko
  },
  rect: {
    fill: Ko
  },
  shape: {
    stroke: Ko
  },
  symbol: {
    fill: Ko,
    strokeWidth: 1.5,
    size: 50
  },
  axis: {
    bandPosition: 0.5,
    grid: !0,
    gridColor: "#000000",
    gridOpacity: 1,
    gridWidth: 0.5,
    labelPadding: 10,
    tickSize: 5,
    tickWidth: 0.5
  },
  axisBand: {
    grid: !1,
    tickExtra: !0
  },
  legend: {
    labelBaseline: "middle",
    labelFontSize: 11,
    symbolSize: 50,
    symbolType: "square"
  },
  range: {
    category: ["#4572a7", "#aa4643", "#8aa453", "#71598e", "#4598ae", "#d98445", "#94aace", "#d09393", "#b9cc98", "#a99cbc"]
  }
}, Jo = "#30a2da", cy = "#cbcbcb", dge = "#999", hge = "#333", zM = "#f0f0f0", BM = "#333", gge = {
  arc: {
    fill: Jo
  },
  area: {
    fill: Jo
  },
  axis: {
    domainColor: cy,
    grid: !0,
    gridColor: cy,
    gridWidth: 1,
    labelColor: dge,
    labelFontSize: 10,
    titleColor: hge,
    tickColor: cy,
    tickSize: 10,
    titleFontSize: 14,
    titlePadding: 10,
    labelPadding: 4
  },
  axisBand: {
    grid: !1
  },
  background: zM,
  group: {
    fill: zM
  },
  legend: {
    labelColor: BM,
    labelFontSize: 11,
    padding: 1,
    symbolSize: 30,
    symbolType: "square",
    titleColor: BM,
    titleFontSize: 14,
    titlePadding: 10
  },
  line: {
    stroke: Jo,
    strokeWidth: 2
  },
  path: {
    stroke: Jo,
    strokeWidth: 0.5
  },
  rect: {
    fill: Jo
  },
  range: {
    category: ["#30a2da", "#fc4f30", "#e5ae38", "#6d904f", "#8b8b8b", "#b96db8", "#ff9e27", "#56cc60", "#52d2ca", "#52689e", "#545454", "#9fe4f8"],
    diverging: ["#cc0020", "#e77866", "#f6e7e1", "#d6e8ed", "#91bfd9", "#1d78b5"],
    heatmap: ["#d6e8ed", "#cee0e5", "#91bfd9", "#549cc6", "#1d78b5"]
  },
  point: {
    filled: !0,
    shape: "circle"
  },
  shape: {
    stroke: Jo
  },
  bar: {
    binSpacing: 2,
    fill: Jo,
    stroke: null
  },
  title: {
    anchor: "start",
    fontSize: 24,
    fontWeight: 600,
    offset: 20
  }
}, Qo = "#000", pge = {
  group: {
    fill: "#e5e5e5"
  },
  arc: {
    fill: Qo
  },
  area: {
    fill: Qo
  },
  line: {
    stroke: Qo
  },
  path: {
    stroke: Qo
  },
  rect: {
    fill: Qo
  },
  shape: {
    stroke: Qo
  },
  symbol: {
    fill: Qo,
    size: 40
  },
  axis: {
    domain: !1,
    grid: !0,
    gridColor: "#FFFFFF",
    gridOpacity: 1,
    labelColor: "#7F7F7F",
    labelPadding: 4,
    tickColor: "#7F7F7F",
    tickSize: 5.67,
    titleFontSize: 16,
    titleFontWeight: "normal"
  },
  legend: {
    labelBaseline: "middle",
    labelFontSize: 11,
    symbolSize: 40
  },
  range: {
    category: ["#000000", "#7F7F7F", "#1A1A1A", "#999999", "#333333", "#B0B0B0", "#4D4D4D", "#C9C9C9", "#666666", "#DCDCDC"]
  }
}, mge = 22, yge = "normal", jM = "Benton Gothic, sans-serif", UM = 11.5, bge = "normal", Zo = "#82c6df", fy = "Benton Gothic Bold, sans-serif", qM = "normal", WM = 13, kc = {
  "category-6": ["#ec8431", "#829eb1", "#c89d29", "#3580b1", "#adc839", "#ab7fb4"],
  "fire-7": ["#fbf2c7", "#f9e39c", "#f8d36e", "#f4bb6a", "#e68a4f", "#d15a40", "#ab4232"],
  "fireandice-6": ["#e68a4f", "#f4bb6a", "#f9e39c", "#dadfe2", "#a6b7c6", "#849eae"],
  "ice-7": ["#edefee", "#dadfe2", "#c4ccd2", "#a6b7c6", "#849eae", "#607785", "#47525d"]
}, vge = {
  background: "#ffffff",
  title: {
    anchor: "start",
    color: "#000000",
    font: fy,
    fontSize: mge,
    fontWeight: yge
  },
  arc: {
    fill: Zo
  },
  area: {
    fill: Zo
  },
  line: {
    stroke: Zo,
    strokeWidth: 2
  },
  path: {
    stroke: Zo
  },
  rect: {
    fill: Zo
  },
  shape: {
    stroke: Zo
  },
  symbol: {
    fill: Zo,
    size: 30
  },
  axis: {
    labelFont: jM,
    labelFontSize: UM,
    labelFontWeight: bge,
    titleFont: fy,
    titleFontSize: WM,
    titleFontWeight: qM
  },
  axisX: {
    labelAngle: 0,
    labelPadding: 4,
    tickSize: 3
  },
  axisY: {
    labelBaseline: "middle",
    maxExtent: 45,
    minExtent: 45,
    tickSize: 2,
    titleAlign: "left",
    titleAngle: 0,
    titleX: -45,
    titleY: -11
  },
  legend: {
    labelFont: jM,
    labelFontSize: UM,
    symbolType: "square",
    titleFont: fy,
    titleFontSize: WM,
    titleFontWeight: qM
  },
  range: {
    category: kc["category-6"],
    diverging: kc["fireandice-6"],
    heatmap: kc["fire-7"],
    ordinal: kc["fire-7"],
    ramp: kc["fire-7"]
  }
}, ea = "#ab5787", Sh = "#979797", xge = {
  background: "#f9f9f9",
  arc: {
    fill: ea
  },
  area: {
    fill: ea
  },
  line: {
    stroke: ea
  },
  path: {
    stroke: ea
  },
  rect: {
    fill: ea
  },
  shape: {
    stroke: ea
  },
  symbol: {
    fill: ea,
    size: 30
  },
  axis: {
    domainColor: Sh,
    domainWidth: 0.5,
    gridWidth: 0.2,
    labelColor: Sh,
    tickColor: Sh,
    tickWidth: 0.2,
    titleColor: Sh
  },
  axisBand: {
    grid: !1
  },
  axisX: {
    grid: !0,
    tickSize: 10
  },
  axisY: {
    domain: !1,
    grid: !0,
    tickSize: 0
  },
  legend: {
    labelFontSize: 11,
    padding: 1,
    symbolSize: 30,
    symbolType: "square"
  },
  range: {
    category: ["#ab5787", "#51b2e5", "#703c5c", "#168dd9", "#d190b6", "#00609f", "#d365ba", "#154866", "#666666", "#c4c4c4"]
  }
}, ta = "#3e5c69", wge = {
  background: "#fff",
  arc: {
    fill: ta
  },
  area: {
    fill: ta
  },
  line: {
    stroke: ta
  },
  path: {
    stroke: ta
  },
  rect: {
    fill: ta
  },
  shape: {
    stroke: ta
  },
  symbol: {
    fill: ta
  },
  axis: {
    domainWidth: 0.5,
    grid: !0,
    labelPadding: 2,
    tickSize: 5,
    tickWidth: 0.5,
    titleFontWeight: "normal"
  },
  axisBand: {
    grid: !1
  },
  axisX: {
    gridWidth: 0.2
  },
  axisY: {
    gridDash: [3],
    gridWidth: 0.4
  },
  legend: {
    labelFontSize: 11,
    padding: 1,
    symbolType: "square"
  },
  range: {
    category: ["#3e5c69", "#6793a6", "#182429", "#0570b0", "#3690c0", "#74a9cf", "#a6bddb", "#e2ddf2"]
  }
}, fi = "#1696d2", HM = "#000000", _ge = "#FFFFFF", kh = "Lato", dy = "Lato", Ege = "Lato", Sge = "#DEDDDD", kge = 18, Ac = {
  "main-colors": ["#1696d2", "#d2d2d2", "#000000", "#fdbf11", "#ec008b", "#55b748", "#5c5859", "#db2b27"],
  "shades-blue": ["#CFE8F3", "#A2D4EC", "#73BFE2", "#46ABDB", "#1696D2", "#12719E", "#0A4C6A", "#062635"],
  "shades-gray": ["#F5F5F5", "#ECECEC", "#E3E3E3", "#DCDBDB", "#D2D2D2", "#9D9D9D", "#696969", "#353535"],
  "shades-yellow": ["#FFF2CF", "#FCE39E", "#FDD870", "#FCCB41", "#FDBF11", "#E88E2D", "#CA5800", "#843215"],
  "shades-magenta": ["#F5CBDF", "#EB99C2", "#E46AA7", "#E54096", "#EC008B", "#AF1F6B", "#761548", "#351123"],
  "shades-green": ["#DCEDD9", "#BCDEB4", "#98CF90", "#78C26D", "#55B748", "#408941", "#2C5C2D", "#1A2E19"],
  "shades-black": ["#D5D5D4", "#ADABAC", "#848081", "#5C5859", "#332D2F", "#262223", "#1A1717", "#0E0C0D"],
  "shades-red": ["#F8D5D4", "#F1AAA9", "#E9807D", "#E25552", "#DB2B27", "#A4201D", "#6E1614", "#370B0A"],
  "one-group": ["#1696d2", "#000000"],
  "two-groups-cat-1": ["#1696d2", "#000000"],
  "two-groups-cat-2": ["#1696d2", "#fdbf11"],
  "two-groups-cat-3": ["#1696d2", "#db2b27"],
  "two-groups-seq": ["#a2d4ec", "#1696d2"],
  "three-groups-cat": ["#1696d2", "#fdbf11", "#000000"],
  "three-groups-seq": ["#a2d4ec", "#1696d2", "#0a4c6a"],
  "four-groups-cat-1": ["#000000", "#d2d2d2", "#fdbf11", "#1696d2"],
  "four-groups-cat-2": ["#1696d2", "#ec0008b", "#fdbf11", "#5c5859"],
  "four-groups-seq": ["#cfe8f3", "#73bf42", "#1696d2", "#0a4c6a"],
  "five-groups-cat-1": ["#1696d2", "#fdbf11", "#d2d2d2", "#ec008b", "#000000"],
  "five-groups-cat-2": ["#1696d2", "#0a4c6a", "#d2d2d2", "#fdbf11", "#332d2f"],
  "five-groups-seq": ["#cfe8f3", "#73bf42", "#1696d2", "#0a4c6a", "#000000"],
  "six-groups-cat-1": ["#1696d2", "#ec008b", "#fdbf11", "#000000", "#d2d2d2", "#55b748"],
  "six-groups-cat-2": ["#1696d2", "#d2d2d2", "#ec008b", "#fdbf11", "#332d2f", "#0a4c6a"],
  "six-groups-seq": ["#cfe8f3", "#a2d4ec", "#73bfe2", "#46abdb", "#1696d2", "#12719e"],
  "diverging-colors": ["#ca5800", "#fdbf11", "#fdd870", "#fff2cf", "#cfe8f3", "#73bfe2", "#1696d2", "#0a4c6a"]
}, Age = {
  background: _ge,
  title: {
    anchor: "start",
    fontSize: kge,
    font: kh
  },
  axisX: {
    domain: !0,
    domainColor: HM,
    domainWidth: 1,
    grid: !1,
    labelFontSize: 12,
    labelFont: dy,
    labelAngle: 0,
    tickColor: HM,
    tickSize: 5,
    titleFontSize: 12,
    titlePadding: 10,
    titleFont: kh
  },
  axisY: {
    domain: !1,
    domainWidth: 1,
    grid: !0,
    gridColor: Sge,
    gridWidth: 1,
    labelFontSize: 12,
    labelFont: dy,
    labelPadding: 8,
    ticks: !1,
    titleFontSize: 12,
    titlePadding: 10,
    titleFont: kh,
    titleAngle: 0,
    titleY: -10,
    titleX: 18
  },
  legend: {
    labelFontSize: 12,
    labelFont: dy,
    symbolSize: 100,
    titleFontSize: 12,
    titlePadding: 10,
    titleFont: kh,
    orient: "right",
    offset: 10
  },
  view: {
    stroke: "transparent"
  },
  range: {
    category: Ac["six-groups-cat-1"],
    diverging: Ac["diverging-colors"],
    heatmap: Ac["diverging-colors"],
    ordinal: Ac["six-groups-seq"],
    ramp: Ac["shades-blue"]
  },
  area: {
    fill: fi
  },
  rect: {
    fill: fi
  },
  line: {
    color: fi,
    stroke: fi,
    strokeWidth: 5
  },
  trail: {
    color: fi,
    stroke: fi,
    strokeWidth: 0,
    size: 1
  },
  path: {
    stroke: fi,
    strokeWidth: 0.5
  },
  point: {
    filled: !0
  },
  text: {
    font: Ege,
    color: fi,
    fontSize: 11,
    align: "center",
    fontWeight: 400,
    size: 11
  },
  style: {
    bar: {
      fill: fi,
      stroke: null
    }
  },
  arc: {
    fill: fi
  },
  shape: {
    stroke: fi
  },
  symbol: {
    fill: fi,
    size: 30
  }
}, na = "#3366CC", GM = "#ccc", Ah = "Arial, sans-serif", Cge = {
  arc: {
    fill: na
  },
  area: {
    fill: na
  },
  path: {
    stroke: na
  },
  rect: {
    fill: na
  },
  shape: {
    stroke: na
  },
  symbol: {
    stroke: na
  },
  circle: {
    fill: na
  },
  background: "#fff",
  padding: {
    top: 10,
    right: 10,
    bottom: 10,
    left: 10
  },
  style: {
    "guide-label": {
      font: Ah,
      fontSize: 12
    },
    "guide-title": {
      font: Ah,
      fontSize: 12
    },
    "group-title": {
      font: Ah,
      fontSize: 12
    }
  },
  title: {
    font: Ah,
    fontSize: 14,
    fontWeight: "bold",
    dy: -3,
    anchor: "start"
  },
  axis: {
    gridColor: GM,
    tickColor: GM,
    domain: !1,
    grid: !0
  },
  range: {
    category: ["#4285F4", "#DB4437", "#F4B400", "#0F9D58", "#AB47BC", "#00ACC1", "#FF7043", "#9E9D24", "#5C6BC0", "#F06292", "#00796B", "#C2185B"],
    heatmap: ["#c6dafc", "#5e97f6", "#2a56c6"]
  }
}, cS = (e) => e * (1 / 3 + 1), VM = cS(9), YM = cS(10), XM = cS(12), Cc = "Segoe UI", KM = "wf_standard-font, helvetica, arial, sans-serif", JM = "#252423", $c = "#605E5C", QM = "transparent", $ge = "#C8C6C4", Di = "#118DFF", Mge = "#12239E", Fge = "#E66C37", Tge = "#6B007B", Oge = "#E044A7", Nge = "#744EC2", Dge = "#D9B300", Rge = "#D64550", fP = Di, dP = "#DEEFFF", ZM = [dP, fP], Lge = [dP, "#c7e4ff", "#b0d9ff", "#9aceff", "#83c3ff", "#6cb9ff", "#55aeff", "#3fa3ff", "#2898ff", fP], Pge = {
  view: {
    stroke: QM
  },
  background: QM,
  font: Cc,
  header: {
    titleFont: KM,
    titleFontSize: XM,
    titleColor: JM,
    labelFont: Cc,
    labelFontSize: YM,
    labelColor: $c
  },
  axis: {
    ticks: !1,
    grid: !1,
    domain: !1,
    labelColor: $c,
    labelFontSize: VM,
    titleFont: KM,
    titleColor: JM,
    titleFontSize: XM,
    titleFontWeight: "normal"
  },
  axisQuantitative: {
    tickCount: 3,
    grid: !0,
    gridColor: $ge,
    gridDash: [1, 5],
    labelFlush: !1
  },
  axisBand: {
    tickExtra: !0
  },
  axisX: {
    labelPadding: 5
  },
  axisY: {
    labelPadding: 10
  },
  bar: {
    fill: Di
  },
  line: {
    stroke: Di,
    strokeWidth: 3,
    strokeCap: "round",
    strokeJoin: "round"
  },
  text: {
    font: Cc,
    fontSize: VM,
    fill: $c
  },
  arc: {
    fill: Di
  },
  area: {
    fill: Di,
    line: !0,
    opacity: 0.6
  },
  path: {
    stroke: Di
  },
  rect: {
    fill: Di
  },
  point: {
    fill: Di,
    filled: !0,
    size: 75
  },
  shape: {
    stroke: Di
  },
  symbol: {
    fill: Di,
    strokeWidth: 1.5,
    size: 50
  },
  legend: {
    titleFont: Cc,
    titleFontWeight: "bold",
    titleColor: $c,
    labelFont: Cc,
    labelFontSize: YM,
    labelColor: $c,
    symbolType: "circle",
    symbolSize: 75
  },
  range: {
    category: [Di, Mge, Fge, Tge, Oge, Nge, Dge, Rge],
    diverging: ZM,
    heatmap: ZM,
    ordinal: Lge
  }
}, hy = 'IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif', e3 = 400, Ige = ["#8a3ffc", "#33b1ff", "#007d79", "#ff7eb6", "#fa4d56", "#fff1f1", "#6fdc8c", "#4589ff", "#d12771", "#d2a106", "#08bdba", "#bae6ff", "#ba4e00", "#d4bbff"], zge = ["#6929c4", "#1192e8", "#005d5d", "#9f1853", "#fa4d56", "#570408", "#198038", "#002d9c", "#ee538b", "#b28600", "#009d9a", "#012749", "#8a3800", "#a56eff"];
function W0({
  type: e,
  background: t
}) {
  const n = e === "dark" ? "#161616" : "#ffffff", i = e === "dark" ? "#f4f4f4" : "#161616", r = e === "dark" ? Ige : zge, s = e === "dark" ? "#d4bbff" : "#6929c4";
  return {
    background: t,
    arc: {
      fill: s
    },
    area: {
      fill: s
    },
    path: {
      stroke: s
    },
    rect: {
      fill: s
    },
    shape: {
      stroke: s
    },
    symbol: {
      stroke: s
    },
    circle: {
      fill: s
    },
    view: {
      fill: n,
      stroke: n
    },
    group: {
      fill: n
    },
    title: {
      color: i,
      anchor: "start",
      dy: -15,
      fontSize: 16,
      font: hy,
      fontWeight: 600
    },
    axis: {
      labelColor: i,
      labelFontSize: 12,
      grid: !0,
      gridColor: "#525252",
      titleColor: i,
      labelAngle: 0
    },
    style: {
      "guide-label": {
        font: hy,
        fill: i,
        fontWeight: e3
      },
      "guide-title": {
        font: hy,
        fill: i,
        fontWeight: e3
      }
    },
    range: {
      category: r,
      diverging: ["#750e13", "#a2191f", "#da1e28", "#fa4d56", "#ff8389", "#ffb3b8", "#ffd7d9", "#fff1f1", "#e5f6ff", "#bae6ff", "#82cfff", "#33b1ff", "#1192e8", "#0072c3", "#00539a", "#003a6d"],
      heatmap: ["#f6f2ff", "#e8daff", "#d4bbff", "#be95ff", "#a56eff", "#8a3ffc", "#6929c4", "#491d8b", "#31135e", "#1c0f30"]
    }
  };
}
const Bge = W0({
  type: "light",
  background: "#ffffff"
}), jge = W0({
  type: "light",
  background: "#f4f4f4"
}), Uge = W0({
  type: "dark",
  background: "#262626"
}), qge = W0({
  type: "dark",
  background: "#161616"
}), Wge = uge.version, Hge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  carbong10: jge,
  carbong100: qge,
  carbong90: Uge,
  carbonwhite: Bge,
  dark: cge,
  excel: fge,
  fivethirtyeight: gge,
  ggplot2: pge,
  googlecharts: Cge,
  latimes: vge,
  powerbi: Pge,
  quartz: xge,
  urbaninstitute: Age,
  version: Wge,
  vox: wge
}, Symbol.toStringTag, { value: "Module" }));
function Gge(e, t, n, i) {
  if (U(e))
    return `[${e.map((r) => t(te(r) ? r : t3(r, n))).join(", ")}]`;
  if (ne(e)) {
    let r = "";
    const {
      title: s,
      image: o,
      ...a
    } = e;
    s && (r += `<h2>${t(s)}</h2>`), o && (r += `<img src="${new URL(t(o), i || location.href).href}">`);
    const l = Object.keys(a);
    if (l.length > 0) {
      r += "<table>";
      for (const u of l) {
        let c = a[u];
        c !== void 0 && (ne(c) && (c = t3(c, n)), r += `<tr><td class="key">${t(u)}</td><td class="value">${t(c)}</td></tr>`);
      }
      r += "</table>";
    }
    return r || "{}";
  }
  return t(e);
}
function Vge(e) {
  const t = [];
  return function(n, i) {
    if (typeof i != "object" || i === null)
      return i;
    const r = t.indexOf(this) + 1;
    return t.length = r, t.length > e ? "[Object]" : t.indexOf(i) >= 0 ? "[Circular]" : (t.push(i), i);
  };
}
function t3(e, t) {
  return JSON.stringify(e, Vge(t));
}
var Yge = `#vg-tooltip-element {
  visibility: hidden;
  padding: 8px;
  position: fixed;
  z-index: 1000;
  font-family: sans-serif;
  font-size: 11px;
  border-radius: 3px;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  /* The default theme is the light theme. */
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid #d9d9d9;
  color: black;
}
#vg-tooltip-element.visible {
  visibility: visible;
}
#vg-tooltip-element h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 13px;
}
#vg-tooltip-element table {
  border-spacing: 0;
}
#vg-tooltip-element table tr {
  border: none;
}
#vg-tooltip-element table tr td {
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 2px;
  padding-bottom: 2px;
}
#vg-tooltip-element table tr td.key {
  color: #808080;
  max-width: 150px;
  text-align: right;
  padding-right: 4px;
}
#vg-tooltip-element table tr td.value {
  display: block;
  max-width: 300px;
  max-height: 7em;
  text-align: left;
}
#vg-tooltip-element.dark-theme {
  background-color: rgba(32, 32, 32, 0.9);
  border: 1px solid #f5f5f5;
  color: white;
}
#vg-tooltip-element.dark-theme td.key {
  color: #bfbfbf;
}
`;
const hP = "vg-tooltip-element", Xge = {
  /**
   * X offset.
   */
  offsetX: 10,
  /**
   * Y offset.
   */
  offsetY: 10,
  /**
   * ID of the tooltip element.
   */
  id: hP,
  /**
   * ID of the tooltip CSS style.
   */
  styleId: "vega-tooltip-style",
  /**
   * The name of the theme. You can use the CSS class called [THEME]-theme to style the tooltips.
   *
   * There are two predefined themes: "light" (default) and "dark".
   */
  theme: "light",
  /**
   * Do not use the default styles provided by Vega Tooltip. If you enable this option, you need to use your own styles. It is not necessary to disable the default style when using a custom theme.
   */
  disableDefaultStyle: !1,
  /**
   * HTML sanitizer function that removes dangerous HTML to prevent XSS.
   *
   * This should be a function from string to string. You may replace it with a formatter such as a markdown formatter.
   */
  sanitize: Kge,
  /**
   * The maximum recursion depth when printing objects in the tooltip.
   */
  maxDepth: 2,
  /**
   * A function to customize the rendered HTML of the tooltip.
   * @param value A value string, or object of value strings keyed by field
   * @param sanitize The `sanitize` function from `options.sanitize`
   * @param baseURL The `baseURL` from `options.baseURL`
   * @returns {string} The returned string will become the `innerHTML` of the tooltip element
   */
  formatTooltip: Gge,
  /**
   * The baseurl to use in image paths.
   */
  baseURL: ""
};
function Kge(e) {
  return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;");
}
function Jge(e) {
  if (!/^[A-Za-z]+[-:.\w]*$/.test(e))
    throw new Error("Invalid HTML ID");
  return Yge.toString().replace(hP, e);
}
function Qge(e, t, n, i) {
  let r = e.clientX + n;
  r + t.width > window.innerWidth && (r = +e.clientX - n - t.width);
  let s = e.clientY + i;
  return s + t.height > window.innerHeight && (s = +e.clientY - i - t.height), {
    x: r,
    y: s
  };
}
class Zge {
  /**
   * The handler function. We bind this to this function in the constructor.
   */
  /**
   * Complete tooltip options.
   */
  /**
   * The tooltip html element.
   */
  /**
   * Create the tooltip handler and initialize the element and style.
   *
   * @param options Tooltip Options
   */
  constructor(t) {
    this.options = {
      ...Xge,
      ...t
    };
    const n = this.options.id;
    if (this.el = null, this.call = this.tooltipHandler.bind(this), !this.options.disableDefaultStyle && !document.getElementById(this.options.styleId)) {
      const i = document.createElement("style");
      i.setAttribute("id", this.options.styleId), i.innerHTML = Jge(n);
      const r = document.head;
      r.childNodes.length > 0 ? r.insertBefore(i, r.childNodes[0]) : r.appendChild(i);
    }
  }
  /**
   * The tooltip handler function.
   */
  tooltipHandler(t, n, i, r) {
    if (this.el = document.getElementById(this.options.id), this.el || (this.el = document.createElement("div"), this.el.setAttribute("id", this.options.id), this.el.classList.add("vg-tooltip"), (document.fullscreenElement ?? document.body).appendChild(this.el)), r == null || r === "") {
      this.el.classList.remove("visible", `${this.options.theme}-theme`);
      return;
    }
    this.el.innerHTML = this.options.formatTooltip(r, this.options.sanitize, this.options.maxDepth, this.options.baseURL), this.el.classList.add("visible", `${this.options.theme}-theme`);
    const {
      x: s,
      y: o
    } = Qge(n, this.el.getBoundingClientRect(), this.options.offsetX, this.options.offsetY);
    this.el.style.top = `${o}px`, this.el.style.left = `${s}px`;
  }
}
function epe(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var gy, n3;
function tpe() {
  return n3 || (n3 = 1, gy = function(e) {
    e.prototype[Symbol.iterator] = function* () {
      for (let t = this.head; t; t = t.next)
        yield t.value;
    };
  }), gy;
}
var npe = Be;
Be.Node = Ka;
Be.create = Be;
function Be(e) {
  var t = this;
  if (t instanceof Be || (t = new Be()), t.tail = null, t.head = null, t.length = 0, e && typeof e.forEach == "function")
    e.forEach(function(r) {
      t.push(r);
    });
  else if (arguments.length > 0)
    for (var n = 0, i = arguments.length; n < i; n++)
      t.push(arguments[n]);
  return t;
}
Be.prototype.removeNode = function(e) {
  if (e.list !== this)
    throw new Error("removing node which does not belong to this list");
  var t = e.next, n = e.prev;
  return t && (t.prev = n), n && (n.next = t), e === this.head && (this.head = t), e === this.tail && (this.tail = n), e.list.length--, e.next = null, e.prev = null, e.list = null, t;
};
Be.prototype.unshiftNode = function(e) {
  if (e !== this.head) {
    e.list && e.list.removeNode(e);
    var t = this.head;
    e.list = this, e.next = t, t && (t.prev = e), this.head = e, this.tail || (this.tail = e), this.length++;
  }
};
Be.prototype.pushNode = function(e) {
  if (e !== this.tail) {
    e.list && e.list.removeNode(e);
    var t = this.tail;
    e.list = this, e.prev = t, t && (t.next = e), this.tail = e, this.head || (this.head = e), this.length++;
  }
};
Be.prototype.push = function() {
  for (var e = 0, t = arguments.length; e < t; e++)
    rpe(this, arguments[e]);
  return this.length;
};
Be.prototype.unshift = function() {
  for (var e = 0, t = arguments.length; e < t; e++)
    spe(this, arguments[e]);
  return this.length;
};
Be.prototype.pop = function() {
  if (this.tail) {
    var e = this.tail.value;
    return this.tail = this.tail.prev, this.tail ? this.tail.next = null : this.head = null, this.length--, e;
  }
};
Be.prototype.shift = function() {
  if (this.head) {
    var e = this.head.value;
    return this.head = this.head.next, this.head ? this.head.prev = null : this.tail = null, this.length--, e;
  }
};
Be.prototype.forEach = function(e, t) {
  t = t || this;
  for (var n = this.head, i = 0; n !== null; i++)
    e.call(t, n.value, i, this), n = n.next;
};
Be.prototype.forEachReverse = function(e, t) {
  t = t || this;
  for (var n = this.tail, i = this.length - 1; n !== null; i--)
    e.call(t, n.value, i, this), n = n.prev;
};
Be.prototype.get = function(e) {
  for (var t = 0, n = this.head; n !== null && t < e; t++)
    n = n.next;
  if (t === e && n !== null)
    return n.value;
};
Be.prototype.getReverse = function(e) {
  for (var t = 0, n = this.tail; n !== null && t < e; t++)
    n = n.prev;
  if (t === e && n !== null)
    return n.value;
};
Be.prototype.map = function(e, t) {
  t = t || this;
  for (var n = new Be(), i = this.head; i !== null; )
    n.push(e.call(t, i.value, this)), i = i.next;
  return n;
};
Be.prototype.mapReverse = function(e, t) {
  t = t || this;
  for (var n = new Be(), i = this.tail; i !== null; )
    n.push(e.call(t, i.value, this)), i = i.prev;
  return n;
};
Be.prototype.reduce = function(e, t) {
  var n, i = this.head;
  if (arguments.length > 1)
    n = t;
  else if (this.head)
    i = this.head.next, n = this.head.value;
  else
    throw new TypeError("Reduce of empty list with no initial value");
  for (var r = 0; i !== null; r++)
    n = e(n, i.value, r), i = i.next;
  return n;
};
Be.prototype.reduceReverse = function(e, t) {
  var n, i = this.tail;
  if (arguments.length > 1)
    n = t;
  else if (this.tail)
    i = this.tail.prev, n = this.tail.value;
  else
    throw new TypeError("Reduce of empty list with no initial value");
  for (var r = this.length - 1; i !== null; r--)
    n = e(n, i.value, r), i = i.prev;
  return n;
};
Be.prototype.toArray = function() {
  for (var e = new Array(this.length), t = 0, n = this.head; n !== null; t++)
    e[t] = n.value, n = n.next;
  return e;
};
Be.prototype.toArrayReverse = function() {
  for (var e = new Array(this.length), t = 0, n = this.tail; n !== null; t++)
    e[t] = n.value, n = n.prev;
  return e;
};
Be.prototype.slice = function(e, t) {
  t = t || this.length, t < 0 && (t += this.length), e = e || 0, e < 0 && (e += this.length);
  var n = new Be();
  if (t < e || t < 0)
    return n;
  e < 0 && (e = 0), t > this.length && (t = this.length);
  for (var i = 0, r = this.head; r !== null && i < e; i++)
    r = r.next;
  for (; r !== null && i < t; i++, r = r.next)
    n.push(r.value);
  return n;
};
Be.prototype.sliceReverse = function(e, t) {
  t = t || this.length, t < 0 && (t += this.length), e = e || 0, e < 0 && (e += this.length);
  var n = new Be();
  if (t < e || t < 0)
    return n;
  e < 0 && (e = 0), t > this.length && (t = this.length);
  for (var i = this.length, r = this.tail; r !== null && i > t; i--)
    r = r.prev;
  for (; r !== null && i > e; i--, r = r.prev)
    n.push(r.value);
  return n;
};
Be.prototype.splice = function(e, t, ...n) {
  e > this.length && (e = this.length - 1), e < 0 && (e = this.length + e);
  for (var i = 0, r = this.head; r !== null && i < e; i++)
    r = r.next;
  for (var s = [], i = 0; r && i < t; i++)
    s.push(r.value), r = this.removeNode(r);
  r === null && (r = this.tail), r !== this.head && r !== this.tail && (r = r.prev);
  for (var i = 0; i < n.length; i++)
    r = ipe(this, r, n[i]);
  return s;
};
Be.prototype.reverse = function() {
  for (var e = this.head, t = this.tail, n = e; n !== null; n = n.prev) {
    var i = n.prev;
    n.prev = n.next, n.next = i;
  }
  return this.head = t, this.tail = e, this;
};
function ipe(e, t, n) {
  var i = t === e.head ? new Ka(n, null, t, e) : new Ka(n, t, t.next, e);
  return i.next === null && (e.tail = i), i.prev === null && (e.head = i), e.length++, i;
}
function rpe(e, t) {
  e.tail = new Ka(t, e.tail, null, e), e.head || (e.head = e.tail), e.length++;
}
function spe(e, t) {
  e.head = new Ka(t, null, e.head, e), e.tail || (e.tail = e.head), e.length++;
}
function Ka(e, t, n, i) {
  if (!(this instanceof Ka))
    return new Ka(e, t, n, i);
  this.list = i, this.value = e, t ? (t.next = this, this.prev = t) : this.prev = null, n ? (n.prev = this, this.next = n) : this.next = null;
}
try {
  tpe()(Be);
} catch {
}
const ope = npe, fa = Symbol("max"), rs = Symbol("length"), $l = Symbol("lengthCalculator"), mf = Symbol("allowStale"), ya = Symbol("maxAge"), ts = Symbol("dispose"), i3 = Symbol("noDisposeOnSet"), At = Symbol("lruList"), Ri = Symbol("cache"), gP = Symbol("updateAgeOnGet"), py = () => 1;
class ape {
  constructor(t) {
    if (typeof t == "number" && (t = {
      max: t
    }), t || (t = {}), t.max && (typeof t.max != "number" || t.max < 0))
      throw new TypeError("max must be a non-negative number");
    this[fa] = t.max || 1 / 0;
    const n = t.length || py;
    if (this[$l] = typeof n != "function" ? py : n, this[mf] = t.stale || !1, t.maxAge && typeof t.maxAge != "number")
      throw new TypeError("maxAge must be a number");
    this[ya] = t.maxAge || 0, this[ts] = t.dispose, this[i3] = t.noDisposeOnSet || !1, this[gP] = t.updateAgeOnGet || !1, this.reset();
  }
  // resize the cache when the max changes.
  set max(t) {
    if (typeof t != "number" || t < 0)
      throw new TypeError("max must be a non-negative number");
    this[fa] = t || 1 / 0, Mc(this);
  }
  get max() {
    return this[fa];
  }
  set allowStale(t) {
    this[mf] = !!t;
  }
  get allowStale() {
    return this[mf];
  }
  set maxAge(t) {
    if (typeof t != "number")
      throw new TypeError("maxAge must be a non-negative number");
    this[ya] = t, Mc(this);
  }
  get maxAge() {
    return this[ya];
  }
  // resize the cache when the lengthCalculator changes.
  set lengthCalculator(t) {
    typeof t != "function" && (t = py), t !== this[$l] && (this[$l] = t, this[rs] = 0, this[At].forEach((n) => {
      n.length = this[$l](n.value, n.key), this[rs] += n.length;
    })), Mc(this);
  }
  get lengthCalculator() {
    return this[$l];
  }
  get length() {
    return this[rs];
  }
  get itemCount() {
    return this[At].length;
  }
  rforEach(t, n) {
    n = n || this;
    for (let i = this[At].tail; i !== null; ) {
      const r = i.prev;
      r3(this, t, i, n), i = r;
    }
  }
  forEach(t, n) {
    n = n || this;
    for (let i = this[At].head; i !== null; ) {
      const r = i.next;
      r3(this, t, i, n), i = r;
    }
  }
  keys() {
    return this[At].toArray().map((t) => t.key);
  }
  values() {
    return this[At].toArray().map((t) => t.value);
  }
  reset() {
    this[ts] && this[At] && this[At].length && this[At].forEach((t) => this[ts](t.key, t.value)), this[Ri] = /* @__PURE__ */ new Map(), this[At] = new ope(), this[rs] = 0;
  }
  dump() {
    return this[At].map((t) => Lp(this, t) ? !1 : {
      k: t.key,
      v: t.value,
      e: t.now + (t.maxAge || 0)
    }).toArray().filter((t) => t);
  }
  dumpLru() {
    return this[At];
  }
  set(t, n, i) {
    if (i = i || this[ya], i && typeof i != "number")
      throw new TypeError("maxAge must be a number");
    const r = i ? Date.now() : 0, s = this[$l](n, t);
    if (this[Ri].has(t)) {
      if (s > this[fa])
        return Jl(this, this[Ri].get(t)), !1;
      const l = this[Ri].get(t).value;
      return this[ts] && (this[i3] || this[ts](t, l.value)), l.now = r, l.maxAge = i, l.value = n, this[rs] += s - l.length, l.length = s, this.get(t), Mc(this), !0;
    }
    const o = new lpe(t, n, s, r, i);
    return o.length > this[fa] ? (this[ts] && this[ts](t, n), !1) : (this[rs] += o.length, this[At].unshift(o), this[Ri].set(t, this[At].head), Mc(this), !0);
  }
  has(t) {
    if (!this[Ri].has(t))
      return !1;
    const n = this[Ri].get(t).value;
    return !Lp(this, n);
  }
  get(t) {
    return my(this, t, !0);
  }
  peek(t) {
    return my(this, t, !1);
  }
  pop() {
    const t = this[At].tail;
    return t ? (Jl(this, t), t.value) : null;
  }
  del(t) {
    Jl(this, this[Ri].get(t));
  }
  load(t) {
    this.reset();
    const n = Date.now();
    for (let i = t.length - 1; i >= 0; i--) {
      const r = t[i], s = r.e || 0;
      if (s === 0)
        this.set(r.k, r.v);
      else {
        const o = s - n;
        o > 0 && this.set(r.k, r.v, o);
      }
    }
  }
  prune() {
    this[Ri].forEach((t, n) => my(this, n, !1));
  }
}
const my = (e, t, n) => {
  const i = e[Ri].get(t);
  if (i) {
    const r = i.value;
    if (Lp(e, r)) {
      if (Jl(e, i), !e[mf])
        return;
    } else
      n && (e[gP] && (i.value.now = Date.now()), e[At].unshiftNode(i));
    return r.value;
  }
}, Lp = (e, t) => {
  if (!t || !t.maxAge && !e[ya])
    return !1;
  const n = Date.now() - t.now;
  return t.maxAge ? n > t.maxAge : e[ya] && n > e[ya];
}, Mc = (e) => {
  if (e[rs] > e[fa])
    for (let t = e[At].tail; e[rs] > e[fa] && t !== null; ) {
      const n = t.prev;
      Jl(e, t), t = n;
    }
}, Jl = (e, t) => {
  if (t) {
    const n = t.value;
    e[ts] && e[ts](n.key, n.value), e[rs] -= n.length, e[Ri].delete(n.key), e[At].removeNode(t);
  }
};
class lpe {
  constructor(t, n, i, r, s) {
    this.key = t, this.value = n, this.length = i, this.now = r, this.maxAge = s || 0;
  }
}
const r3 = (e, t, n, i) => {
  let r = n.value;
  Lp(e, r) && (Jl(e, n), e[mf] || (r = void 0)), r && t.call(i, r.value, r.key, e);
};
var upe = ape;
const cpe = Object.freeze({
  loose: !0
}), fpe = Object.freeze({}), dpe = (e) => e ? typeof e != "object" ? cpe : e : fpe;
var fS = dpe, Nv = { exports: {} };
const hpe = "2.0.0", pP = 256, gpe = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
9007199254740991, ppe = 16, mpe = pP - 6, ype = ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];
var dS = {
  MAX_LENGTH: pP,
  MAX_SAFE_COMPONENT_LENGTH: ppe,
  MAX_SAFE_BUILD_LENGTH: mpe,
  MAX_SAFE_INTEGER: gpe,
  RELEASE_TYPES: ype,
  SEMVER_SPEC_VERSION: hpe,
  FLAG_INCLUDE_PRERELEASE: 1,
  FLAG_LOOSE: 2
};
const bpe = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => {
};
var H0 = bpe;
(function(e, t) {
  const {
    MAX_SAFE_COMPONENT_LENGTH: n,
    MAX_SAFE_BUILD_LENGTH: i,
    MAX_LENGTH: r
  } = dS, s = H0;
  t = e.exports = {};
  const o = t.re = [], a = t.safeRe = [], l = t.src = [], u = t.t = {};
  let c = 0;
  const f = "[a-zA-Z0-9-]", d = [["\\s", 1], ["\\d", r], [f, i]], h = (p) => {
    for (const [m, y] of d)
      p = p.split(`${m}*`).join(`${m}{0,${y}}`).split(`${m}+`).join(`${m}{1,${y}}`);
    return p;
  }, g = (p, m, y) => {
    const b = h(m), v = c++;
    s(p, v, m), u[p] = v, l[v] = m, o[v] = new RegExp(m, y ? "g" : void 0), a[v] = new RegExp(b, y ? "g" : void 0);
  };
  g("NUMERICIDENTIFIER", "0|[1-9]\\d*"), g("NUMERICIDENTIFIERLOOSE", "\\d+"), g("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${f}*`), g("MAINVERSION", `(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})`), g("MAINVERSIONLOOSE", `(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})`), g("PRERELEASEIDENTIFIER", `(?:${l[u.NUMERICIDENTIFIER]}|${l[u.NONNUMERICIDENTIFIER]})`), g("PRERELEASEIDENTIFIERLOOSE", `(?:${l[u.NUMERICIDENTIFIERLOOSE]}|${l[u.NONNUMERICIDENTIFIER]})`), g("PRERELEASE", `(?:-(${l[u.PRERELEASEIDENTIFIER]}(?:\\.${l[u.PRERELEASEIDENTIFIER]})*))`), g("PRERELEASELOOSE", `(?:-?(${l[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[u.PRERELEASEIDENTIFIERLOOSE]})*))`), g("BUILDIDENTIFIER", `${f}+`), g("BUILD", `(?:\\+(${l[u.BUILDIDENTIFIER]}(?:\\.${l[u.BUILDIDENTIFIER]})*))`), g("FULLPLAIN", `v?${l[u.MAINVERSION]}${l[u.PRERELEASE]}?${l[u.BUILD]}?`), g("FULL", `^${l[u.FULLPLAIN]}$`), g("LOOSEPLAIN", `[v=\\s]*${l[u.MAINVERSIONLOOSE]}${l[u.PRERELEASELOOSE]}?${l[u.BUILD]}?`), g("LOOSE", `^${l[u.LOOSEPLAIN]}$`), g("GTLT", "((?:<|>)?=?)"), g("XRANGEIDENTIFIERLOOSE", `${l[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), g("XRANGEIDENTIFIER", `${l[u.NUMERICIDENTIFIER]}|x|X|\\*`), g("XRANGEPLAIN", `[v=\\s]*(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:${l[u.PRERELEASE]})?${l[u.BUILD]}?)?)?`), g("XRANGEPLAINLOOSE", `[v=\\s]*(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:${l[u.PRERELEASELOOSE]})?${l[u.BUILD]}?)?)?`), g("XRANGE", `^${l[u.GTLT]}\\s*${l[u.XRANGEPLAIN]}$`), g("XRANGELOOSE", `^${l[u.GTLT]}\\s*${l[u.XRANGEPLAINLOOSE]}$`), g("COERCE", `(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?(?:$|[^\\d])`), g("COERCERTL", l[u.COERCE], !0), g("LONETILDE", "(?:~>?)"), g("TILDETRIM", `(\\s*)${l[u.LONETILDE]}\\s+`, !0), t.tildeTrimReplace = "$1~", g("TILDE", `^${l[u.LONETILDE]}${l[u.XRANGEPLAIN]}$`), g("TILDELOOSE", `^${l[u.LONETILDE]}${l[u.XRANGEPLAINLOOSE]}$`), g("LONECARET", "(?:\\^)"), g("CARETTRIM", `(\\s*)${l[u.LONECARET]}\\s+`, !0), t.caretTrimReplace = "$1^", g("CARET", `^${l[u.LONECARET]}${l[u.XRANGEPLAIN]}$`), g("CARETLOOSE", `^${l[u.LONECARET]}${l[u.XRANGEPLAINLOOSE]}$`), g("COMPARATORLOOSE", `^${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]})$|^$`), g("COMPARATOR", `^${l[u.GTLT]}\\s*(${l[u.FULLPLAIN]})$|^$`), g("COMPARATORTRIM", `(\\s*)${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]}|${l[u.XRANGEPLAIN]})`, !0), t.comparatorTrimReplace = "$1$2$3", g("HYPHENRANGE", `^\\s*(${l[u.XRANGEPLAIN]})\\s+-\\s+(${l[u.XRANGEPLAIN]})\\s*$`), g("HYPHENRANGELOOSE", `^\\s*(${l[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[u.XRANGEPLAINLOOSE]})\\s*$`), g("STAR", "(<|>)?=?\\s*\\*"), g("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), g("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
})(Nv, Nv.exports);
var hS = Nv.exports;
const s3 = /^[0-9]+$/, mP = (e, t) => {
  const n = s3.test(e), i = s3.test(t);
  return n && i && (e = +e, t = +t), e === t ? 0 : n && !i ? -1 : i && !n ? 1 : e < t ? -1 : 1;
}, vpe = (e, t) => mP(t, e);
var xpe = {
  compareIdentifiers: mP,
  rcompareIdentifiers: vpe
};
const Ch = H0, {
  MAX_LENGTH: o3,
  MAX_SAFE_INTEGER: $h
} = dS, {
  safeRe: a3,
  t: l3
} = hS, wpe = fS, {
  compareIdentifiers: Ml
} = xpe;
let _pe = class hr {
  constructor(t, n) {
    if (n = wpe(n), t instanceof hr) {
      if (t.loose === !!n.loose && t.includePrerelease === !!n.includePrerelease)
        return t;
      t = t.version;
    } else if (typeof t != "string")
      throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);
    if (t.length > o3)
      throw new TypeError(`version is longer than ${o3} characters`);
    Ch("SemVer", t, n), this.options = n, this.loose = !!n.loose, this.includePrerelease = !!n.includePrerelease;
    const i = t.trim().match(n.loose ? a3[l3.LOOSE] : a3[l3.FULL]);
    if (!i)
      throw new TypeError(`Invalid Version: ${t}`);
    if (this.raw = t, this.major = +i[1], this.minor = +i[2], this.patch = +i[3], this.major > $h || this.major < 0)
      throw new TypeError("Invalid major version");
    if (this.minor > $h || this.minor < 0)
      throw new TypeError("Invalid minor version");
    if (this.patch > $h || this.patch < 0)
      throw new TypeError("Invalid patch version");
    i[4] ? this.prerelease = i[4].split(".").map((r) => {
      if (/^[0-9]+$/.test(r)) {
        const s = +r;
        if (s >= 0 && s < $h)
          return s;
      }
      return r;
    }) : this.prerelease = [], this.build = i[5] ? i[5].split(".") : [], this.format();
  }
  format() {
    return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
  }
  toString() {
    return this.version;
  }
  compare(t) {
    if (Ch("SemVer.compare", this.version, this.options, t), !(t instanceof hr)) {
      if (typeof t == "string" && t === this.version)
        return 0;
      t = new hr(t, this.options);
    }
    return t.version === this.version ? 0 : this.compareMain(t) || this.comparePre(t);
  }
  compareMain(t) {
    return t instanceof hr || (t = new hr(t, this.options)), Ml(this.major, t.major) || Ml(this.minor, t.minor) || Ml(this.patch, t.patch);
  }
  comparePre(t) {
    if (t instanceof hr || (t = new hr(t, this.options)), this.prerelease.length && !t.prerelease.length)
      return -1;
    if (!this.prerelease.length && t.prerelease.length)
      return 1;
    if (!this.prerelease.length && !t.prerelease.length)
      return 0;
    let n = 0;
    do {
      const i = this.prerelease[n], r = t.prerelease[n];
      if (Ch("prerelease compare", n, i, r), i === void 0 && r === void 0)
        return 0;
      if (r === void 0)
        return 1;
      if (i === void 0)
        return -1;
      if (i === r)
        continue;
      return Ml(i, r);
    } while (++n);
  }
  compareBuild(t) {
    t instanceof hr || (t = new hr(t, this.options));
    let n = 0;
    do {
      const i = this.build[n], r = t.build[n];
      if (Ch("prerelease compare", n, i, r), i === void 0 && r === void 0)
        return 0;
      if (r === void 0)
        return 1;
      if (i === void 0)
        return -1;
      if (i === r)
        continue;
      return Ml(i, r);
    } while (++n);
  }
  // preminor will bump the version up to the next minor release, and immediately
  // down to pre-release. premajor and prepatch work the same way.
  inc(t, n, i) {
    switch (t) {
      case "premajor":
        this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", n, i);
        break;
      case "preminor":
        this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", n, i);
        break;
      case "prepatch":
        this.prerelease.length = 0, this.inc("patch", n, i), this.inc("pre", n, i);
        break;
      case "prerelease":
        this.prerelease.length === 0 && this.inc("patch", n, i), this.inc("pre", n, i);
        break;
      case "major":
        (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
        break;
      case "minor":
        (this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = [];
        break;
      case "patch":
        this.prerelease.length === 0 && this.patch++, this.prerelease = [];
        break;
      case "pre": {
        const r = Number(i) ? 1 : 0;
        if (!n && i === !1)
          throw new Error("invalid increment argument: identifier is empty");
        if (this.prerelease.length === 0)
          this.prerelease = [r];
        else {
          let s = this.prerelease.length;
          for (; --s >= 0; )
            typeof this.prerelease[s] == "number" && (this.prerelease[s]++, s = -2);
          if (s === -1) {
            if (n === this.prerelease.join(".") && i === !1)
              throw new Error("invalid increment argument: identifier already exists");
            this.prerelease.push(r);
          }
        }
        if (n) {
          let s = [n, r];
          i === !1 && (s = [n]), Ml(this.prerelease[0], n) === 0 ? isNaN(this.prerelease[1]) && (this.prerelease = s) : this.prerelease = s;
        }
        break;
      }
      default:
        throw new Error(`invalid increment argument: ${t}`);
    }
    return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this;
  }
};
var gS = _pe;
const u3 = gS, Epe = (e, t, n) => new u3(e, n).compare(new u3(t, n));
var ic = Epe;
const Spe = ic, kpe = (e, t, n) => Spe(e, t, n) === 0;
var Ape = kpe;
const Cpe = ic, $pe = (e, t, n) => Cpe(e, t, n) !== 0;
var Mpe = $pe;
const Fpe = ic, Tpe = (e, t, n) => Fpe(e, t, n) > 0;
var Ope = Tpe;
const Npe = ic, Dpe = (e, t, n) => Npe(e, t, n) >= 0;
var Rpe = Dpe;
const Lpe = ic, Ppe = (e, t, n) => Lpe(e, t, n) < 0;
var Ipe = Ppe;
const zpe = ic, Bpe = (e, t, n) => zpe(e, t, n) <= 0;
var jpe = Bpe;
const Upe = Ape, qpe = Mpe, Wpe = Ope, Hpe = Rpe, Gpe = Ipe, Vpe = jpe, Ype = (e, t, n, i) => {
  switch (t) {
    case "===":
      return typeof e == "object" && (e = e.version), typeof n == "object" && (n = n.version), e === n;
    case "!==":
      return typeof e == "object" && (e = e.version), typeof n == "object" && (n = n.version), e !== n;
    case "":
    case "=":
    case "==":
      return Upe(e, n, i);
    case "!=":
      return qpe(e, n, i);
    case ">":
      return Wpe(e, n, i);
    case ">=":
      return Hpe(e, n, i);
    case "<":
      return Gpe(e, n, i);
    case "<=":
      return Vpe(e, n, i);
    default:
      throw new TypeError(`Invalid operator: ${t}`);
  }
};
var Xpe = Ype, yy, c3;
function Kpe() {
  if (c3)
    return yy;
  c3 = 1;
  const e = Symbol("SemVer ANY");
  class t {
    static get ANY() {
      return e;
    }
    constructor(c, f) {
      if (f = n(f), c instanceof t) {
        if (c.loose === !!f.loose)
          return c;
        c = c.value;
      }
      c = c.trim().split(/\s+/).join(" "), o("comparator", c, f), this.options = f, this.loose = !!f.loose, this.parse(c), this.semver === e ? this.value = "" : this.value = this.operator + this.semver.version, o("comp", this);
    }
    parse(c) {
      const f = this.options.loose ? i[r.COMPARATORLOOSE] : i[r.COMPARATOR], d = c.match(f);
      if (!d)
        throw new TypeError(`Invalid comparator: ${c}`);
      this.operator = d[1] !== void 0 ? d[1] : "", this.operator === "=" && (this.operator = ""), d[2] ? this.semver = new a(d[2], this.options.loose) : this.semver = e;
    }
    toString() {
      return this.value;
    }
    test(c) {
      if (o("Comparator.test", c, this.options.loose), this.semver === e || c === e)
        return !0;
      if (typeof c == "string")
        try {
          c = new a(c, this.options);
        } catch {
          return !1;
        }
      return s(c, this.operator, this.semver, this.options);
    }
    intersects(c, f) {
      if (!(c instanceof t))
        throw new TypeError("a Comparator is required");
      return this.operator === "" ? this.value === "" ? !0 : new l(c.value, f).test(this.value) : c.operator === "" ? c.value === "" ? !0 : new l(this.value, f).test(c.semver) : (f = n(f), f.includePrerelease && (this.value === "<0.0.0-0" || c.value === "<0.0.0-0") || !f.includePrerelease && (this.value.startsWith("<0.0.0") || c.value.startsWith("<0.0.0")) ? !1 : !!(this.operator.startsWith(">") && c.operator.startsWith(">") || this.operator.startsWith("<") && c.operator.startsWith("<") || this.semver.version === c.semver.version && this.operator.includes("=") && c.operator.includes("=") || s(this.semver, "<", c.semver, f) && this.operator.startsWith(">") && c.operator.startsWith("<") || s(this.semver, ">", c.semver, f) && this.operator.startsWith("<") && c.operator.startsWith(">")));
    }
  }
  yy = t;
  const n = fS, {
    safeRe: i,
    t: r
  } = hS, s = Xpe, o = H0, a = gS, l = yP();
  return yy;
}
var by, f3;
function yP() {
  if (f3)
    return by;
  f3 = 1;
  class e {
    constructor(D, M) {
      if (M = i(M), D instanceof e)
        return D.loose === !!M.loose && D.includePrerelease === !!M.includePrerelease ? D : new e(D.raw, M);
      if (D instanceof r)
        return this.raw = D.value, this.set = [[D]], this.format(), this;
      if (this.options = M, this.loose = !!M.loose, this.includePrerelease = !!M.includePrerelease, this.raw = D.trim().split(/\s+/).join(" "), this.set = this.raw.split("||").map((w) => this.parseRange(w.trim())).filter((w) => w.length), !this.set.length)
        throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
      if (this.set.length > 1) {
        const w = this.set[0];
        if (this.set = this.set.filter((k) => !g(k[0])), this.set.length === 0)
          this.set = [w];
        else if (this.set.length > 1) {
          for (const k of this.set)
            if (k.length === 1 && p(k[0])) {
              this.set = [k];
              break;
            }
        }
      }
      this.format();
    }
    format() {
      return this.range = this.set.map((D) => D.join(" ").trim()).join("||").trim(), this.range;
    }
    toString() {
      return this.range;
    }
    parseRange(D) {
      const w = ((this.options.includePrerelease && d) | (this.options.loose && h)) + ":" + D, k = n.get(w);
      if (k)
        return k;
      const A = this.options.loose, F = A ? a[l.HYPHENRANGELOOSE] : a[l.HYPHENRANGE];
      D = D.replace(F, O(this.options.includePrerelease)), s("hyphen replace", D), D = D.replace(a[l.COMPARATORTRIM], u), s("comparator trim", D), D = D.replace(a[l.TILDETRIM], c), s("tilde trim", D), D = D.replace(a[l.CARETTRIM], f), s("caret trim", D);
      let R = D.split(" ").map((Q) => y(Q, this.options)).join(" ").split(/\s+/).map((Q) => N(Q, this.options));
      A && (R = R.filter((Q) => (s("loose invalid filter", Q, this.options), !!Q.match(a[l.COMPARATORLOOSE])))), s("range list", R);
      const L = /* @__PURE__ */ new Map(), V = R.map((Q) => new r(Q, this.options));
      for (const Q of V) {
        if (g(Q))
          return [Q];
        L.set(Q.value, Q);
      }
      L.size > 1 && L.has("") && L.delete("");
      const K = [...L.values()];
      return n.set(w, K), K;
    }
    intersects(D, M) {
      if (!(D instanceof e))
        throw new TypeError("a Range is required");
      return this.set.some((w) => m(w, M) && D.set.some((k) => m(k, M) && w.every((A) => k.every((F) => A.intersects(F, M)))));
    }
    // if ANY of the sets match ALL of its comparators, then pass
    test(D) {
      if (!D)
        return !1;
      if (typeof D == "string")
        try {
          D = new o(D, this.options);
        } catch {
          return !1;
        }
      for (let M = 0; M < this.set.length; M++)
        if (P(this.set[M], D, this.options))
          return !0;
      return !1;
    }
  }
  by = e;
  const t = upe, n = new t({
    max: 1e3
  }), i = fS, r = Kpe(), s = H0, o = gS, {
    safeRe: a,
    t: l,
    comparatorTrimReplace: u,
    tildeTrimReplace: c,
    caretTrimReplace: f
  } = hS, {
    FLAG_INCLUDE_PRERELEASE: d,
    FLAG_LOOSE: h
  } = dS, g = (T) => T.value === "<0.0.0-0", p = (T) => T.value === "", m = (T, D) => {
    let M = !0;
    const w = T.slice();
    let k = w.pop();
    for (; M && w.length; )
      M = w.every((A) => k.intersects(A, D)), k = w.pop();
    return M;
  }, y = (T, D) => (s("comp", T, D), T = x(T, D), s("caret", T), T = v(T, D), s("tildes", T), T = E(T, D), s("xrange", T), T = $(T, D), s("stars", T), T), b = (T) => !T || T.toLowerCase() === "x" || T === "*", v = (T, D) => T.trim().split(/\s+/).map((M) => _(M, D)).join(" "), _ = (T, D) => {
    const M = D.loose ? a[l.TILDELOOSE] : a[l.TILDE];
    return T.replace(M, (w, k, A, F, R) => {
      s("tilde", T, w, k, A, F, R);
      let L;
      return b(k) ? L = "" : b(A) ? L = `>=${k}.0.0 <${+k + 1}.0.0-0` : b(F) ? L = `>=${k}.${A}.0 <${k}.${+A + 1}.0-0` : R ? (s("replaceTilde pr", R), L = `>=${k}.${A}.${F}-${R} <${k}.${+A + 1}.0-0`) : L = `>=${k}.${A}.${F} <${k}.${+A + 1}.0-0`, s("tilde return", L), L;
    });
  }, x = (T, D) => T.trim().split(/\s+/).map((M) => S(M, D)).join(" "), S = (T, D) => {
    s("caret", T, D);
    const M = D.loose ? a[l.CARETLOOSE] : a[l.CARET], w = D.includePrerelease ? "-0" : "";
    return T.replace(M, (k, A, F, R, L) => {
      s("caret", T, k, A, F, R, L);
      let V;
      return b(A) ? V = "" : b(F) ? V = `>=${A}.0.0${w} <${+A + 1}.0.0-0` : b(R) ? A === "0" ? V = `>=${A}.${F}.0${w} <${A}.${+F + 1}.0-0` : V = `>=${A}.${F}.0${w} <${+A + 1}.0.0-0` : L ? (s("replaceCaret pr", L), A === "0" ? F === "0" ? V = `>=${A}.${F}.${R}-${L} <${A}.${F}.${+R + 1}-0` : V = `>=${A}.${F}.${R}-${L} <${A}.${+F + 1}.0-0` : V = `>=${A}.${F}.${R}-${L} <${+A + 1}.0.0-0`) : (s("no pr"), A === "0" ? F === "0" ? V = `>=${A}.${F}.${R}${w} <${A}.${F}.${+R + 1}-0` : V = `>=${A}.${F}.${R}${w} <${A}.${+F + 1}.0-0` : V = `>=${A}.${F}.${R} <${+A + 1}.0.0-0`), s("caret return", V), V;
    });
  }, E = (T, D) => (s("replaceXRanges", T, D), T.split(/\s+/).map((M) => C(M, D)).join(" ")), C = (T, D) => {
    T = T.trim();
    const M = D.loose ? a[l.XRANGELOOSE] : a[l.XRANGE];
    return T.replace(M, (w, k, A, F, R, L) => {
      s("xRange", T, w, k, A, F, R, L);
      const V = b(A), K = V || b(F), Q = K || b(R), ie = Q;
      return k === "=" && ie && (k = ""), L = D.includePrerelease ? "-0" : "", V ? k === ">" || k === "<" ? w = "<0.0.0-0" : w = "*" : k && ie ? (K && (F = 0), R = 0, k === ">" ? (k = ">=", K ? (A = +A + 1, F = 0, R = 0) : (F = +F + 1, R = 0)) : k === "<=" && (k = "<", K ? A = +A + 1 : F = +F + 1), k === "<" && (L = "-0"), w = `${k + A}.${F}.${R}${L}`) : K ? w = `>=${A}.0.0${L} <${+A + 1}.0.0-0` : Q && (w = `>=${A}.${F}.0${L} <${A}.${+F + 1}.0-0`), s("xRange return", w), w;
    });
  }, $ = (T, D) => (s("replaceStars", T, D), T.trim().replace(a[l.STAR], "")), N = (T, D) => (s("replaceGTE0", T, D), T.trim().replace(a[D.includePrerelease ? l.GTE0PRE : l.GTE0], "")), O = (T) => (D, M, w, k, A, F, R, L, V, K, Q, ie, Le) => (b(w) ? M = "" : b(k) ? M = `>=${w}.0.0${T ? "-0" : ""}` : b(A) ? M = `>=${w}.${k}.0${T ? "-0" : ""}` : F ? M = `>=${M}` : M = `>=${M}${T ? "-0" : ""}`, b(V) ? L = "" : b(K) ? L = `<${+V + 1}.0.0-0` : b(Q) ? L = `<${V}.${+K + 1}.0-0` : ie ? L = `<=${V}.${K}.${Q}-${ie}` : T ? L = `<${V}.${K}.${+Q + 1}-0` : L = `<=${L}`, `${M} ${L}`.trim()), P = (T, D, M) => {
    for (let w = 0; w < T.length; w++)
      if (!T[w].test(D))
        return !1;
    if (D.prerelease.length && !M.includePrerelease) {
      for (let w = 0; w < T.length; w++)
        if (s(T[w].semver), T[w].semver !== r.ANY && T[w].semver.prerelease.length > 0) {
          const k = T[w].semver;
          if (k.major === D.major && k.minor === D.minor && k.patch === D.patch)
            return !0;
        }
      return !1;
    }
    return !0;
  };
  return by;
}
const Jpe = yP(), Qpe = (e, t, n) => {
  try {
    t = new Jpe(t, n);
  } catch {
    return !1;
  }
  return t.test(e);
};
var Zpe = Qpe, bP = /* @__PURE__ */ epe(Zpe);
function eme(e, t, n) {
  const i = e.open(t), r = 1e4, s = 250, {
    origin: o
  } = new URL(t);
  let a = ~~(r / s);
  function l(c) {
    c.source === i && (a = 0, e.removeEventListener("message", l, !1));
  }
  e.addEventListener("message", l, !1);
  function u() {
    a <= 0 || (i.postMessage(n, o), setTimeout(u, s), a -= 1);
  }
  setTimeout(u, s);
}
var tme = `.vega-embed {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
}
.vega-embed.has-actions {
  padding-right: 38px;
}
.vega-embed details:not([open]) > :not(summary) {
  display: none !important;
}
.vega-embed summary {
  list-style: none;
  position: absolute;
  top: 0;
  right: 0;
  padding: 6px;
  z-index: 1000;
  background: white;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
  color: #1b1e23;
  border: 1px solid #aaa;
  border-radius: 999px;
  opacity: 0.2;
  transition: opacity 0.4s ease-in;
  cursor: pointer;
  line-height: 0px;
}
.vega-embed summary::-webkit-details-marker {
  display: none;
}
.vega-embed summary:active {
  box-shadow: #aaa 0px 0px 0px 1px inset;
}
.vega-embed summary svg {
  width: 14px;
  height: 14px;
}
.vega-embed details[open] summary {
  opacity: 0.7;
}
.vega-embed:hover summary, .vega-embed:focus-within summary {
  opacity: 1 !important;
  transition: opacity 0.2s ease;
}
.vega-embed .vega-actions {
  position: absolute;
  z-index: 1001;
  top: 35px;
  right: -9px;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
  padding-top: 8px;
  border-radius: 4px;
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);
  border: 1px solid #d9d9d9;
  background: white;
  animation-duration: 0.15s;
  animation-name: scale-in;
  animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5);
  text-align: left;
}
.vega-embed .vega-actions a {
  padding: 8px 16px;
  font-family: sans-serif;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: #434a56;
  text-decoration: none;
}
.vega-embed .vega-actions a:hover, .vega-embed .vega-actions a:focus {
  background-color: #f7f7f9;
  color: black;
}
.vega-embed .vega-actions::before, .vega-embed .vega-actions::after {
  content: "";
  display: inline-block;
  position: absolute;
}
.vega-embed .vega-actions::before {
  left: auto;
  right: 14px;
  top: -16px;
  border: 8px solid rgba(0, 0, 0, 0);
  border-bottom-color: #d9d9d9;
}
.vega-embed .vega-actions::after {
  left: auto;
  right: 15px;
  top: -14px;
  border: 7px solid rgba(0, 0, 0, 0);
  border-bottom-color: #fff;
}
.vega-embed .chart-wrapper.fit-x {
  width: 100%;
}
.vega-embed .chart-wrapper.fit-y {
  height: 100%;
}

.vega-embed-wrapper {
  max-width: 100%;
  overflow: auto;
  padding-right: 14px;
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
`;
function vP(e, ...t) {
  for (const n of t)
    nme(e, n);
  return e;
}
function nme(e, t) {
  for (const n of Object.keys(t))
    Ru(e, n, t[n], !0);
}
const Li = jre;
let Qf = Whe;
const Mh = typeof window < "u" ? window : void 0;
var M3;
Qf === void 0 && ((M3 = Mh == null ? void 0 : Mh.vl) != null && M3.compile) && (Qf = Mh.vl);
const ime = {
  export: {
    svg: !0,
    png: !0
  },
  source: !0,
  compiled: !0,
  editor: !0
}, rme = {
  CLICK_TO_VIEW_ACTIONS: "Click to view actions",
  COMPILED_ACTION: "View Compiled Vega",
  EDITOR_ACTION: "Open in Vega Editor",
  PNG_ACTION: "Save as PNG",
  SOURCE_ACTION: "View Source",
  SVG_ACTION: "Save as SVG"
}, Zc = {
  vega: "Vega",
  "vega-lite": "Vega-Lite"
}, Pp = {
  vega: Li.version,
  "vega-lite": Qf ? Qf.version : "not available"
}, sme = {
  vega: (e) => e,
  "vega-lite": (e, t) => Qf.compile(e, {
    config: t
  }).spec
}, ome = `
<svg viewBox="0 0 16 16" fill="currentColor" stroke="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
  <circle r="2" cy="8" cx="2"></circle>
  <circle r="2" cy="8" cx="8"></circle>
  <circle r="2" cy="8" cx="14"></circle>
</svg>`, ame = "chart-wrapper";
function lme(e) {
  return typeof e == "function";
}
function d3(e, t, n, i) {
  const r = `<html><head>${t}</head><body><pre><code class="json">`, s = `</code></pre>${n}</body></html>`, o = window.open("");
  o.document.write(r + e + s), o.document.title = `${Zc[i]} JSON Source`;
}
function ume(e, t) {
  if (e.$schema) {
    const n = cP(e.$schema);
    t && t !== n.library && console.warn(`The given visualization spec is written in ${Zc[n.library]}, but mode argument sets ${Zc[t] ?? t}.`);
    const i = n.library;
    return bP(Pp[i], `^${n.version.slice(1)}`) || console.warn(`The input spec uses ${Zc[i]} ${n.version}, but the current version of ${Zc[i]} is v${Pp[i]}.`), i;
  }
  return "mark" in e || "encoding" in e || "layer" in e || "hconcat" in e || "vconcat" in e || "facet" in e || "repeat" in e ? "vega-lite" : "marks" in e || "signals" in e || "scales" in e || "axes" in e ? "vega" : t ?? "vega";
}
function xP(e) {
  return !!(e && "load" in e);
}
function h3(e) {
  return xP(e) ? e : Li.loader(e);
}
function cme(e) {
  var n;
  const t = ((n = e.usermeta) == null ? void 0 : n.embedOptions) ?? {};
  return te(t.defaultStyle) && (t.defaultStyle = !1), t;
}
async function fme(e, t, n = {}) {
  let i, r;
  te(t) ? (r = h3(n.loader), i = JSON.parse(await r.load(t))) : i = t;
  const s = cme(i), o = s.loader;
  (!r || o) && (r = h3(n.loader ?? o));
  const a = await g3(s, r), l = await g3(n, r), u = {
    ...vP(l, a),
    config: Du(l.config ?? {}, a.config ?? {})
  };
  return await hme(e, i, u, r);
}
async function g3(e, t) {
  const n = te(e.config) ? JSON.parse(await t.load(e.config)) : e.config ?? {}, i = te(e.patch) ? JSON.parse(await t.load(e.patch)) : e.patch;
  return {
    ...e,
    ...i ? {
      patch: i
    } : {},
    ...n ? {
      config: n
    } : {}
  };
}
function dme(e) {
  const t = e.getRootNode ? e.getRootNode() : document;
  return t instanceof ShadowRoot ? {
    root: t,
    rootContainer: t
  } : {
    root: document,
    rootContainer: document.head ?? document.body
  };
}
async function hme(e, t, n = {}, i) {
  const r = n.theme ? Du(Hge[n.theme], n.config ?? {}) : n.config, s = To(n.actions) ? n.actions : vP({}, ime, n.actions ?? {}), o = {
    ...rme,
    ...n.i18n
  }, a = n.renderer ?? "canvas", l = n.logLevel ?? Li.Warn, u = n.downloadFileName ?? "visualization", c = typeof e == "string" ? document.querySelector(e) : e;
  if (!c)
    throw new Error(`${e} does not exist`);
  if (n.defaultStyle !== !1) {
    const x = "vega-embed-style", {
      root: S,
      rootContainer: E
    } = dme(c);
    if (!S.getElementById(x)) {
      const C = document.createElement("style");
      C.id = x, C.innerHTML = n.defaultStyle === void 0 || n.defaultStyle === !0 ? tme.toString() : n.defaultStyle, E.appendChild(C);
    }
  }
  const f = ume(t, n.mode);
  let d = sme[f](t, r);
  if (f === "vega-lite" && d.$schema) {
    const x = cP(d.$schema);
    bP(Pp.vega, `^${x.version.slice(1)}`) || console.warn(`The compiled spec uses Vega ${x.version}, but current version is v${Pp.vega}.`);
  }
  c.classList.add("vega-embed"), s && c.classList.add("has-actions"), c.innerHTML = "";
  let h = c;
  if (s) {
    const x = document.createElement("div");
    x.classList.add(ame), c.appendChild(x), h = x;
  }
  const g = n.patch;
  if (g && (d = g instanceof Function ? g(d) : zp(d, g, !0, !1).newDocument), n.formatLocale && Li.formatLocale(n.formatLocale), n.timeFormatLocale && Li.timeFormatLocale(n.timeFormatLocale), n.expressionFunctions)
    for (const x in n.expressionFunctions) {
      const S = n.expressionFunctions[x];
      "fn" in S ? Li.expressionFunction(x, S.fn, S.visitor) : S instanceof Function && Li.expressionFunction(x, S);
    }
  const {
    ast: p
  } = n, m = Li.parse(d, f === "vega-lite" ? {} : r, {
    ast: p
  }), y = new (n.viewClass || Li.View)(m, {
    loader: i,
    logLevel: l,
    renderer: a,
    ...p ? {
      expr: Li.expressionInterpreter ?? n.expr ?? Jre
    } : {}
  });
  if (y.addSignalListener("autosize", (x, S) => {
    const {
      type: E
    } = S;
    E == "fit-x" ? (h.classList.add("fit-x"), h.classList.remove("fit-y")) : E == "fit-y" ? (h.classList.remove("fit-x"), h.classList.add("fit-y")) : E == "fit" ? h.classList.add("fit-x", "fit-y") : h.classList.remove("fit-x", "fit-y");
  }), n.tooltip !== !1) {
    const {
      loader: x,
      tooltip: S
    } = n, E = x && !xP(x) ? x == null ? void 0 : x.baseURL : void 0, C = lme(S) ? S : (
      // user provided boolean true or tooltip options
      new Zge({
        baseURL: E,
        ...S === !0 ? {} : S
      }).call
    );
    y.tooltip(C);
  }
  let {
    hover: b
  } = n;
  if (b === void 0 && (b = f === "vega"), b) {
    const {
      hoverSet: x,
      updateSet: S
    } = typeof b == "boolean" ? {} : b;
    y.hover(x, S);
  }
  n && (n.width != null && y.width(n.width), n.height != null && y.height(n.height), n.padding != null && y.padding(n.padding)), await y.initialize(h, n.bind).runAsync();
  let v;
  if (s !== !1) {
    let x = c;
    if (n.defaultStyle !== !1 || n.forceActionsMenu) {
      const E = document.createElement("details");
      E.title = o.CLICK_TO_VIEW_ACTIONS, c.append(E), x = E;
      const C = document.createElement("summary");
      C.innerHTML = ome, E.append(C), v = ($) => {
        E.contains($.target) || E.removeAttribute("open");
      }, document.addEventListener("click", v);
    }
    const S = document.createElement("div");
    if (x.append(S), S.classList.add("vega-actions"), s === !0 || s.export !== !1) {
      for (const E of ["svg", "png"])
        if (s === !0 || s.export === !0 || s.export[E]) {
          const C = o[`${E.toUpperCase()}_ACTION`], $ = document.createElement("a"), N = ne(n.scaleFactor) ? n.scaleFactor[E] : n.scaleFactor;
          $.text = C, $.href = "#", $.target = "_blank", $.download = `${u}.${E}`, $.addEventListener("mousedown", async function(O) {
            O.preventDefault();
            const P = await y.toImageURL(E, N);
            this.href = P;
          }), S.append($);
        }
    }
    if (s === !0 || s.source !== !1) {
      const E = document.createElement("a");
      E.text = o.SOURCE_ACTION, E.href = "#", E.addEventListener("click", function(C) {
        d3(V0(t), n.sourceHeader ?? "", n.sourceFooter ?? "", f), C.preventDefault();
      }), S.append(E);
    }
    if (f === "vega-lite" && (s === !0 || s.compiled !== !1)) {
      const E = document.createElement("a");
      E.text = o.COMPILED_ACTION, E.href = "#", E.addEventListener("click", function(C) {
        d3(V0(d), n.sourceHeader ?? "", n.sourceFooter ?? "", "vega"), C.preventDefault();
      }), S.append(E);
    }
    if (s === !0 || s.editor !== !1) {
      const E = n.editorUrl ?? "https://vega.github.io/editor/", C = document.createElement("a");
      C.text = o.EDITOR_ACTION, C.href = "#", C.addEventListener("click", function($) {
        eme(window, E, {
          config: r,
          mode: f,
          renderer: a,
          spec: V0(t)
        }), $.preventDefault();
      }), S.append(C);
    }
  }
  function _() {
    v && document.removeEventListener("click", v), y.finalize();
  }
  return {
    view: y,
    spec: t,
    vgSpec: d,
    finalize: _,
    embedOptions: n
  };
}
const gme = /* @__PURE__ */ new Set(["width", "height"]);
var pme = function e(t, n) {
  if (t === n)
    return !0;
  if (t && n && typeof t == "object" && typeof n == "object") {
    if (t.constructor !== n.constructor)
      return !1;
    var i, r, s;
    if (Array.isArray(t)) {
      if (i = t.length, i != n.length)
        return !1;
      for (r = i; r-- !== 0; )
        if (!e(t[r], n[r]))
          return !1;
      return !0;
    }
    if (t.constructor === RegExp)
      return t.source === n.source && t.flags === n.flags;
    if (t.valueOf !== Object.prototype.valueOf)
      return t.valueOf() === n.valueOf();
    if (t.toString !== Object.prototype.toString)
      return t.toString() === n.toString();
    if (s = Object.keys(t), i = s.length, i !== Object.keys(n).length)
      return !1;
    for (r = i; r-- !== 0; )
      if (!Object.prototype.hasOwnProperty.call(n, s[r]))
        return !1;
    for (r = i; r-- !== 0; ) {
      var o = s[r];
      if (!e(t[o], n[o]))
        return !1;
    }
    return !0;
  }
  return t !== t && n !== n;
};
const mme = /* @__PURE__ */ I3(pme);
function yme(e, t) {
  for (const [n, i] of Object.entries(t))
    i && (i && {}.toString.call(i) === "[object Function]" ? i(e.data(n)) : e.change(n, Li.changeset().remove(() => !0).insert(i)));
}
function Fh(e = {}, t = {}, n = /* @__PURE__ */ new Set()) {
  const i = Object.keys(e), r = Object.keys(t);
  return e === t || i.length === r.length && i.filter((s) => !n.has(s)).every((s) => e[s] === t[s]);
}
function p3(e, t) {
  const n = Object.keys(t);
  for (const i of n)
    try {
      e.removeSignalListener(i, t[i]);
    } catch (r) {
      console.warn("Cannot remove invalid signal listener.", r);
    }
  return n.length > 0;
}
function vy(e, t) {
  const n = Object.keys(t);
  for (const i of n)
    try {
      e.addSignalListener(i, t[i]);
    } catch (r) {
      console.warn("Cannot add invalid signal listener.", r);
    }
  return n.length > 0;
}
function bme(e) {
  return new Set(e.flatMap((t) => Object.keys(t)));
}
function vme(e, t) {
  if (e === t)
    return !1;
  const n = {
    width: !1,
    height: !1,
    isExpensive: !1
  }, i = "width" in e || "width" in t, r = "height" in e || "height" in t;
  return i && (!("width" in e) || !("width" in t) || e.width !== t.width) && ("width" in e && typeof e.width == "number" ? n.width = e.width : n.isExpensive = !0), r && (!("height" in e) || !("height" in t) || e.height !== t.height) && ("height" in e && typeof e.height == "number" ? n.height = e.height : n.isExpensive = !0), [...bme([e, t])].filter((o) => o !== "width" && o !== "height").some((o) => !(o in e) || !(o in t) || !mme(e[o], t[o])) && (n.isExpensive = !0), n.width !== !1 || n.height !== !1 || n.isExpensive ? n : !1;
}
function m3(e, t) {
  const { width: n, height: i } = t;
  return typeof n < "u" && typeof i < "u" ? { ...e, width: n, height: i } : typeof n < "u" ? { ...e, width: n } : typeof i < "u" ? { ...e, height: i } : e;
}
function xme(e) {
  let t;
  return {
    c() {
      t = pe("div");
    },
    m(n, i) {
      Se(n, t, i), e[11](t);
    },
    p: Zn,
    i: Zn,
    o: Zn,
    d(n) {
      n && _e(t), e[11](null);
    }
  };
}
function wme(e, t, n) {
  let { options: i } = t, { spec: r } = t, { view: s } = t, { signalListeners: o = {} } = t, { data: a = {} } = t;
  const l = Bv();
  let u, c = {}, f = {}, d = {}, h = {}, g;
  DP(() => {
    m();
  });
  async function p() {
    m();
    try {
      n(6, u = await fme(g, r, i)), n(1, s = u.view), vy(s, o) && s.runAsync(), b(s);
    } catch (x) {
      y(x);
    }
  }
  function m() {
    u && (u.finalize(), n(6, u = void 0), n(1, s = void 0));
  }
  function y(x) {
    l("onError", { error: x }), console.warn(x);
  }
  function b(x) {
    v(), l("onNewView", { view: x });
  }
  async function v() {
    a && Object.keys(a).length > 0 && u !== void 0 && (n(1, s = u.view), yme(s, a), await s.resize().runAsync());
  }
  function _(x) {
    Ql[x ? "unshift" : "push"](() => {
      g = x, n(0, g);
    });
  }
  return e.$$set = (x) => {
    "options" in x && n(2, i = x.options), "spec" in x && n(3, r = x.spec), "view" in x && n(1, s = x.view), "signalListeners" in x && n(4, o = x.signalListeners), "data" in x && n(5, a = x.data);
  }, e.$$.update = () => {
    if (e.$$.dirty & /*data, prevData*/
    1056 && (Fh(a, h) || v(), n(10, h = a)), e.$$.dirty & /*chartContainer, options, prevOptions, spec, prevSpec, signalListeners, prevSignalListeners, result, view*/
    991 && g !== void 0) {
      if (!Fh(i, c, gme))
        p();
      else {
        const x = vme(m3(r, i), m3(d, c)), S = o, E = f;
        if (x) {
          if (x.isExpensive)
            p();
          else if (u !== void 0) {
            const C = !Fh(S, E);
            n(1, s = u.view), x.width !== !1 && s.width(x.width), x.height !== !1 && s.height(x.height), C && (E && p3(s, E), S && vy(s, S)), s.runAsync();
          }
        } else
          !Fh(S, E) && u !== void 0 && (n(1, s = u.view), E && p3(s, E), S && vy(s, S), s.runAsync());
      }
      n(7, c = i), n(8, f = o), n(9, d = r);
    }
  }, [
    g,
    s,
    i,
    r,
    o,
    a,
    u,
    c,
    f,
    d,
    h,
    _
  ];
}
class _me extends Ms {
  constructor(t) {
    super(), $s(this, t, wme, xme, Cs, {
      options: 2,
      spec: 3,
      view: 1,
      signalListeners: 4,
      data: 5
    });
  }
}
function Eme(e) {
  let t, n, i;
  function r(o) {
    e[6](o);
  }
  let s = {
    spec: (
      /*spec*/
      e[1]
    ),
    data: (
      /*data*/
      e[2]
    ),
    signalListeners: (
      /*signalListeners*/
      e[3]
    ),
    options: (
      /*vegaLiteOptions*/
      e[4]
    )
  };
  return (
    /*view*/
    e[0] !== void 0 && (s.view = /*view*/
    e[0]), t = new _me({ props: s }), Ql.push(() => Uv(t, "view", r)), t.$on(
      "onNewView",
      /*onNewView_handler*/
      e[7]
    ), t.$on(
      "onError",
      /*onError_handler*/
      e[8]
    ), {
      c() {
        ii(t.$$.fragment);
      },
      m(o, a) {
        Ln(t, o, a), i = !0;
      },
      p(o, [a]) {
        const l = {};
        a & /*spec*/
        2 && (l.spec = /*spec*/
        o[1]), a & /*data*/
        4 && (l.data = /*data*/
        o[2]), a & /*signalListeners*/
        8 && (l.signalListeners = /*signalListeners*/
        o[3]), a & /*vegaLiteOptions*/
        16 && (l.options = /*vegaLiteOptions*/
        o[4]), !n && a & /*view*/
        1 && (n = !0, l.view = /*view*/
        o[0], jv(() => n = !1)), t.$set(l);
      },
      i(o) {
        i || (ge(t.$$.fragment, o), i = !0);
      },
      o(o) {
        Ce(t.$$.fragment, o), i = !1;
      },
      d(o) {
        Pn(t, o);
      }
    }
  );
}
const Sme = "vega-lite";
function kme(e, t, n) {
  let i, { spec: r } = t, { options: s = {} } = t, { data: o = {} } = t, { signalListeners: a = {} } = t, { view: l = void 0 } = t;
  function u(d) {
    l = d, n(0, l);
  }
  function c(d) {
    xS.call(this, e, d);
  }
  function f(d) {
    xS.call(this, e, d);
  }
  return e.$$set = (d) => {
    "spec" in d && n(1, r = d.spec), "options" in d && n(5, s = d.options), "data" in d && n(2, o = d.data), "signalListeners" in d && n(3, a = d.signalListeners), "view" in d && n(0, l = d.view);
  }, e.$$.update = () => {
    e.$$.dirty & /*options*/
    32 && n(4, i = { ...s, mode: Sme });
  }, [
    l,
    r,
    o,
    a,
    i,
    s,
    u,
    c,
    f
  ];
}
class wP extends Ms {
  constructor(t) {
    super(), $s(this, t, kme, Eme, Cs, {
      spec: 1,
      options: 5,
      data: 2,
      signalListeners: 3,
      view: 0
    });
  }
}
function Ame(e) {
  let t, n, i, r;
  function s(a) {
    e[5](a);
  }
  let o = {
    data: (
      /*data*/
      e[0]
    ),
    spec: (
      /*specVL*/
      e[2]
    ),
    options: { actions: !1 }
  };
  return (
    /*viewVL*/
    e[1] !== void 0 && (o.view = /*viewVL*/
    e[1]), n = new wP({ props: o }), Ql.push(() => Uv(n, "view", s)), {
      c() {
        t = pe("div"), ii(n.$$.fragment), he(t, "class", "chart");
      },
      m(a, l) {
        Se(a, t, l), Ln(n, t, null), r = !0;
      },
      p(a, [l]) {
        const u = {};
        l & /*data*/
        1 && (u.data = /*data*/
        a[0]), !i && l & /*viewVL*/
        2 && (i = !0, u.view = /*viewVL*/
        a[1], jv(() => i = !1)), n.$set(u);
      },
      i(a) {
        r || (ge(n.$$.fragment, a), r = !0);
      },
      o(a) {
        Ce(n.$$.fragment, a), r = !1;
      },
      d(a) {
        a && _e(t), Pn(n);
      }
    }
  );
}
function Cme(e, t, n) {
  let { rows: i = [] } = t, { filterItems: r } = t, s, o;
  function a(c, f) {
    c = c.filter((h) => {
      let g = !0;
      for (let [p, m] of Object.entries(f))
        h[p] != m && (g = !1);
      return g;
    }), n(0, s = { rows: c });
  }
  a(i, r);
  let l = {
    $schema: "https://vega.github.io/schema/vega-lite/v5.json",
    description: "A simple bar chart with embedded data.",
    data: { name: "rows" },
    mark: { type: "bar" },
    title: "Concept Prevalence",
    width: 200,
    height: 150,
    encoding: {
      y: {
        field: "concept_score_orig",
        type: "quantitative",
        aggregate: "sum",
        // scale: {
        //     domain: [0, 1]
        // },
        title: "Concept Prevalence"
      },
      x: {
        field: "id",
        type: "ordinal",
        axis: { labelLimit: 100, labelAngle: -45 },
        title: "Group",
        sort: null
      },
      tooltip: {
        field: "concept_score_orig",
        type: "quantitative",
        aggregate: "sum"
      }
      // format: '.2f',
    }
  };
  function u(c) {
    o = c, n(1, o);
  }
  return e.$$set = (c) => {
    "rows" in c && n(3, i = c.rows), "filterItems" in c && n(4, r = c.filterItems);
  }, e.$$.update = () => {
    e.$$.dirty & /*rows, filterItems*/
    24 && a(i, r);
  }, [s, o, l, i, r, u];
}
class $me extends Ms {
  constructor(t) {
    super(), $s(this, t, Cme, Ame, Cs, { rows: 3, filterItems: 4 });
  }
}
function y3(e, t, n) {
  const i = e.slice();
  return i[14] = t[n][0], i[15] = t[n][1], i;
}
function b3(e) {
  let t, n;
  return {
    c() {
      t = pe("h2"), n = ei(
        /*selectedTitle*/
        e[1]
      );
    },
    m(i, r) {
      Se(i, t, r), ve(t, n);
    },
    p(i, r) {
      r & /*selectedTitle*/
      2 && xs(
        n,
        /*selectedTitle*/
        i[1]
      );
    },
    d(i) {
      i && _e(t);
    }
  };
}
function v3(e) {
  let t, n, i, r, s, o, a, l, u = Rn(Object.entries(
    /*selectedMetadata*/
    e[2]
  )), c = [];
  for (let f = 0; f < u.length; f += 1)
    c[f] = x3(y3(e, u, f));
  return a = new $me({
    props: {
      rows: (
        /*rowsMatch*/
        e[5]
      ),
      filterItems: (
        /*filterItems*/
        e[0]
      )
    }
  }), {
    c() {
      t = pe("h3"), t.textContent = "CONCEPT SUMMARY", n = ft(), i = pe("div"), r = pe("div");
      for (let f = 0; f < c.length; f += 1)
        c[f].c();
      s = ft(), o = pe("div"), ii(a.$$.fragment), he(t, "class", "card-title"), he(r, "class", "overview-card-left"), he(o, "class", "overview-card-right"), he(i, "class", "overview-card");
    },
    m(f, d) {
      Se(f, t, d), Se(f, n, d), Se(f, i, d), ve(i, r);
      for (let h = 0; h < c.length; h += 1)
        c[h] && c[h].m(r, null);
      ve(i, s), ve(i, o), Ln(a, o, null), l = !0;
    },
    p(f, d) {
      if (d & /*Object, selectedMetadata*/
      4) {
        u = Rn(Object.entries(
          /*selectedMetadata*/
          f[2]
        ));
        let g;
        for (g = 0; g < u.length; g += 1) {
          const p = y3(f, u, g);
          c[g] ? c[g].p(p, d) : (c[g] = x3(p), c[g].c(), c[g].m(r, null));
        }
        for (; g < c.length; g += 1)
          c[g].d(1);
        c.length = u.length;
      }
      const h = {};
      d & /*rowsMatch*/
      32 && (h.rows = /*rowsMatch*/
      f[5]), d & /*filterItems*/
      1 && (h.filterItems = /*filterItems*/
      f[0]), a.$set(h);
    },
    i(f) {
      l || (ge(a.$$.fragment, f), l = !0);
    },
    o(f) {
      Ce(a.$$.fragment, f), l = !1;
    },
    d(f) {
      f && (_e(t), _e(n), _e(i)), Ja(c, f), Pn(a);
    }
  };
}
function x3(e) {
  let t, n, i = (
    /*key*/
    e[14] + ""
  ), r, s, o, a = (
    /*value*/
    e[15] + ""
  );
  return {
    c() {
      t = pe("p"), n = pe("b"), r = ei(i), s = ei(": "), o = new Ip(!1), o.a = null;
    },
    m(l, u) {
      Se(l, t, u), ve(t, n), ve(n, r), ve(t, s), o.m(a, t);
    },
    p(l, u) {
      u & /*selectedMetadata*/
      4 && i !== (i = /*key*/
      l[14] + "") && xs(r, i), u & /*selectedMetadata*/
      4 && a !== (a = /*value*/
      l[15] + "") && o.p(a);
    },
    d(l) {
      l && _e(t);
    }
  };
}
function w3(e) {
  let t, n;
  return t = new qv({
    props: {
      columns: (
        /*columns*/
        e[7]
      ),
      rows: (
        /*rowsMatchAll*/
        e[3]
      ),
      filterSelections: (
        /*filterItems*/
        e[0]
      )
    }
  }), {
    c() {
      ii(t.$$.fragment);
    },
    m(i, r) {
      Ln(t, i, r), n = !0;
    },
    p(i, r) {
      const s = {};
      r & /*rowsMatchAll*/
      8 && (s.rows = /*rowsMatchAll*/
      i[3]), r & /*filterItems*/
      1 && (s.filterSelections = /*filterItems*/
      i[0]), t.$set(s);
    },
    i(i) {
      n || (ge(t.$$.fragment, i), n = !0);
    },
    o(i) {
      Ce(t.$$.fragment, i), n = !1;
    },
    d(i) {
      Pn(t, i);
    }
  };
}
function _3(e) {
  let t, n;
  return t = new qv({
    props: {
      columns: (
        /*columns*/
        e[7]
      ),
      rows: (
        /*rowsNonMatchAll*/
        e[4]
      ),
      filterSelections: (
        /*filterItems*/
        e[0]
      ),
      sortBy: Fme,
      sortOrder: (
        /*sortOrder*/
        e[8]
      )
    }
  }), {
    c() {
      ii(t.$$.fragment);
    },
    m(i, r) {
      Ln(t, i, r), n = !0;
    },
    p(i, r) {
      const s = {};
      r & /*rowsNonMatchAll*/
      16 && (s.rows = /*rowsNonMatchAll*/
      i[4]), r & /*filterItems*/
      1 && (s.filterSelections = /*filterItems*/
      i[0]), t.$set(s);
    },
    i(i) {
      n || (ge(t.$$.fragment, i), n = !0);
    },
    o(i) {
      Ce(t.$$.fragment, i), n = !1;
    },
    d(i) {
      Pn(t, i);
    }
  };
}
function Mme(e) {
  let t, n, i, r, s, o, a, l, u, c, f, d, h = (
    /*selectedTitle*/
    e[1] && b3(e)
  ), g = (
    /*selectedMetadata*/
    e[2] && v3(e)
  ), p = (
    /*remount*/
    e[6] && w3(e)
  ), m = (
    /*remount*/
    e[6] && _3(e)
  );
  return {
    c() {
      t = pe("div"), h && h.c(), n = ft(), i = pe("div"), g && g.c(), r = ft(), s = pe("h3"), s.textContent = "POTENTIAL CONCEPT MATCHES", o = ft(), a = pe("div"), p && p.c(), l = ft(), u = pe("h3"), u.textContent = "CONCEPT NON-MATCHES", c = ft(), f = pe("div"), m && m.c(), he(s, "class", "card-title"), he(a, "class", "highlight-card"), he(u, "class", "card-title"), TP(u, "margin-top", "20px"), he(f, "class", "highlight-card"), he(i, "class", "row");
    },
    m(y, b) {
      Se(y, t, b), h && h.m(t, null), ve(t, n), ve(t, i), g && g.m(i, null), ve(i, r), ve(i, s), ve(i, o), ve(i, a), p && p.m(a, null), ve(i, l), ve(i, u), ve(i, c), ve(i, f), m && m.m(f, null), d = !0;
    },
    p(y, [b]) {
      /*selectedTitle*/
      y[1] ? h ? h.p(y, b) : (h = b3(y), h.c(), h.m(t, n)) : h && (h.d(1), h = null), /*selectedMetadata*/
      y[2] ? g ? (g.p(y, b), b & /*selectedMetadata*/
      4 && ge(g, 1)) : (g = v3(y), g.c(), ge(g, 1), g.m(i, r)) : g && (bi(), Ce(g, 1, 1, () => {
        g = null;
      }), vi()), /*remount*/
      y[6] ? p ? (p.p(y, b), b & /*remount*/
      64 && ge(p, 1)) : (p = w3(y), p.c(), ge(p, 1), p.m(a, null)) : p && (bi(), Ce(p, 1, 1, () => {
        p = null;
      }), vi()), /*remount*/
      y[6] ? m ? (m.p(y, b), b & /*remount*/
      64 && ge(m, 1)) : (m = _3(y), m.c(), ge(m, 1), m.m(f, null)) : m && (bi(), Ce(m, 1, 1, () => {
        m = null;
      }), vi());
    },
    i(y) {
      d || (ge(g), ge(p), ge(m), d = !0);
    },
    o(y) {
      Ce(g), Ce(p), Ce(m), d = !1;
    },
    d(y) {
      y && _e(t), h && h.d(), g && g.d(), p && p.d(), m && m.d();
    }
  };
}
let Fme = "concept score";
function Tme(e, t, n) {
  let { data: i } = t, { el: r } = t, { filterItems: s } = t, { selectedTitle: o } = t, { selectedMetadata: a } = t, l = [], u = [], c = [], f = [], d = [], h = !0, g = ["concept_score_orig"], p = -1;
  zv(() => {
    m(i);
  });
  function m(y) {
    if (y != null) {
      let v = document.createElement("div");
      l = JSON.parse(y);
      for (var b = 0; b < Object.keys(l[0]).length; b++) {
        const x = Object.keys(l[0])[b];
        g.includes(x) || u.push({
          key: x,
          title: x,
          value: (S) => S[x],
          sortable: !0,
          parseHTML: !0
        });
      }
      n(6, h = !1), setTimeout(() => n(6, h = !0), 0), r.appendChild(v), n(3, c = l.filter((x) => x.concept_score_orig == 1 && x.id == "All")), n(4, f = l.filter((x) => x.concept_score_orig < 1 && x.id == "All")), n(5, d = l.filter((x) => x.concept_score_orig == 1));
    }
  }
  return e.$$set = (y) => {
    "data" in y && n(9, i = y.data), "el" in y && n(10, r = y.el), "filterItems" in y && n(0, s = y.filterItems), "selectedTitle" in y && n(1, o = y.selectedTitle), "selectedMetadata" in y && n(2, a = y.selectedMetadata);
  }, [
    s,
    o,
    a,
    c,
    f,
    d,
    h,
    u,
    p,
    i,
    r
  ];
}
class Ome extends Ms {
  constructor(t) {
    super(), $s(this, t, Tme, Mme, Cs, {
      data: 9,
      el: 10,
      filterItems: 0,
      selectedTitle: 1,
      selectedMetadata: 2
    });
  }
}
function Nme(e) {
  let t, n, i, r;
  function s(a) {
    e[5](a);
  }
  let o = {
    data: (
      /*data*/
      e[0]
    ),
    spec: (
      /*specVL*/
      e[2]
    ),
    options: { actions: !1 }
  };
  return (
    /*viewVL*/
    e[1] !== void 0 && (o.view = /*viewVL*/
    e[1]), n = new wP({ props: o }), Ql.push(() => Uv(n, "view", s)), {
      c() {
        t = pe("div"), ii(n.$$.fragment), he(t, "class", "chart");
      },
      m(a, l) {
        Se(a, t, l), Ln(n, t, null), r = !0;
      },
      p(a, [l]) {
        const u = {};
        l & /*data*/
        1 && (u.data = /*data*/
        a[0]), !i && l & /*viewVL*/
        2 && (i = !0, u.view = /*viewVL*/
        a[1], jv(() => i = !1)), n.$set(u);
      },
      i(a) {
        r || (ge(n.$$.fragment, a), r = !0);
      },
      o(a) {
        Ce(n.$$.fragment, a), r = !1;
      },
      d(a) {
        a && _e(t), Pn(n);
      }
    }
  );
}
function Dme(e, t, n) {
  let { rows: i = [] } = t, { filterItems: r } = t, s, o;
  function a(c, f) {
    c = c.filter((h) => {
      let g = !0;
      for (let [p, m] of Object.entries(f))
        h[p] != m && (g = !1);
      return h.concept_score_orig < 1 && (g = !1), g;
    }), n(0, s = { rows: c });
  }
  a(i, r);
  let l = {
    $schema: "https://vega.github.io/schema/vega-lite/v5.json",
    description: "A simple bar chart with embedded data.",
    data: { name: "rows" },
    mark: { type: "bar" },
    width: 150,
    encoding: {
      x: {
        field: "concept_score_orig",
        type: "quantitative",
        aggregate: "sum",
        // scale: {
        //     domain: [0, 1]
        // },
        title: "Concept Prevalence"
      },
      y: {
        field: "concept",
        type: "nominal",
        axis: { labelLimit: 100 },
        sort: null,
        title: "Concept"
      },
      color: { field: "concept", legend: null },
      tooltip: {
        field: "concept_score_orig",
        type: "quantitative",
        aggregate: "sum"
      }
      // format: '.2f',
    }
  };
  function u(c) {
    o = c, n(1, o);
  }
  return e.$$set = (c) => {
    "rows" in c && n(3, i = c.rows), "filterItems" in c && n(4, r = c.filterItems);
  }, e.$$.update = () => {
    e.$$.dirty & /*rows, filterItems*/
    24 && a(i, r);
  }, [s, o, l, i, r, u];
}
class Rme extends Ms {
  constructor(t) {
    super(), $s(this, t, Dme, Nme, Cs, { rows: 3, filterItems: 4 });
  }
}
function E3(e, t, n) {
  const i = e.slice();
  return i[13] = t[n][0], i[14] = t[n][1], i;
}
function S3(e) {
  let t, n;
  return {
    c() {
      t = pe("h2"), n = ei(
        /*selectedTitle*/
        e[3]
      );
    },
    m(i, r) {
      Se(i, t, r), ve(t, n);
    },
    p(i, r) {
      r & /*selectedTitle*/
      8 && xs(
        n,
        /*selectedTitle*/
        i[3]
      );
    },
    d(i) {
      i && _e(t);
    }
  };
}
function k3(e) {
  let t, n, i, r, s, o, a = Rn(Object.entries(
    /*selectedMetadata*/
    e[4]
  )), l = [];
  for (let u = 0; u < a.length; u += 1)
    l[u] = A3(E3(e, a, u));
  return s = new Rme({
    props: {
      rows: (
        /*rowsLong*/
        e[6]
      ),
      filterItems: (
        /*filterItems*/
        e[0]
      )
    }
  }), {
    c() {
      t = pe("h3"), t.textContent = "SLICE SUMMARY", n = ft(), i = pe("div");
      for (let u = 0; u < l.length; u += 1)
        l[u].c();
      r = ft(), ii(s.$$.fragment), he(t, "class", "card-title"), he(i, "class", "overview-card");
    },
    m(u, c) {
      Se(u, t, c), Se(u, n, c), Se(u, i, c);
      for (let f = 0; f < l.length; f += 1)
        l[f] && l[f].m(i, null);
      ve(i, r), Ln(s, i, null), o = !0;
    },
    p(u, c) {
      if (c & /*Object, selectedMetadata*/
      16) {
        a = Rn(Object.entries(
          /*selectedMetadata*/
          u[4]
        ));
        let d;
        for (d = 0; d < a.length; d += 1) {
          const h = E3(u, a, d);
          l[d] ? l[d].p(h, c) : (l[d] = A3(h), l[d].c(), l[d].m(i, r));
        }
        for (; d < l.length; d += 1)
          l[d].d(1);
        l.length = a.length;
      }
      const f = {};
      c & /*rowsLong*/
      64 && (f.rows = /*rowsLong*/
      u[6]), c & /*filterItems*/
      1 && (f.filterItems = /*filterItems*/
      u[0]), s.$set(f);
    },
    i(u) {
      o || (ge(s.$$.fragment, u), o = !0);
    },
    o(u) {
      Ce(s.$$.fragment, u), o = !1;
    },
    d(u) {
      u && (_e(t), _e(n), _e(i)), Ja(l, u), Pn(s);
    }
  };
}
function A3(e) {
  let t, n, i = (
    /*key*/
    e[13] + ""
  ), r, s, o = (
    /*value*/
    e[14] + ""
  ), a;
  return {
    c() {
      t = pe("p"), n = pe("b"), r = ei(i), s = ei(": "), a = ei(o);
    },
    m(l, u) {
      Se(l, t, u), ve(t, n), ve(n, r), ve(t, s), ve(t, a);
    },
    p(l, u) {
      u & /*selectedMetadata*/
      16 && i !== (i = /*key*/
      l[13] + "") && xs(r, i), u & /*selectedMetadata*/
      16 && o !== (o = /*value*/
      l[14] + "") && xs(a, o);
    },
    d(l) {
      l && _e(t);
    }
  };
}
function C3(e) {
  let t, n;
  return t = new qv({
    props: {
      columns: (
        /*columns*/
        e[8]
      ),
      rows: (
        /*rows*/
        e[5]
      ),
      sortBy: (
        /*sortBy*/
        e[1]
      ),
      sortOrder: (
        /*sortOrder*/
        e[2]
      ),
      filterSelections: (
        /*filterItems*/
        e[0]
      )
    }
  }), {
    c() {
      ii(t.$$.fragment);
    },
    m(i, r) {
      Ln(t, i, r), n = !0;
    },
    p(i, r) {
      const s = {};
      r & /*rows*/
      32 && (s.rows = /*rows*/
      i[5]), r & /*sortBy*/
      2 && (s.sortBy = /*sortBy*/
      i[1]), r & /*sortOrder*/
      4 && (s.sortOrder = /*sortOrder*/
      i[2]), r & /*filterItems*/
      1 && (s.filterSelections = /*filterItems*/
      i[0]), t.$set(s);
    },
    i(i) {
      n || (ge(t.$$.fragment, i), n = !0);
    },
    o(i) {
      Ce(t.$$.fragment, i), n = !1;
    },
    d(i) {
      Pn(t, i);
    }
  };
}
function Lme(e) {
  let t, n, i, r, s, o, a, l, u = (
    /*selectedTitle*/
    e[3] && S3(e)
  ), c = (
    /*selectedMetadata*/
    e[4] && k3(e)
  ), f = (
    /*remount*/
    e[7] && C3(e)
  );
  return {
    c() {
      t = pe("div"), u && u.c(), n = ft(), i = pe("div"), c && c.c(), r = ft(), s = pe("h3"), s.textContent = "SLICE EXAMPLES", o = ft(), a = pe("div"), f && f.c(), he(s, "class", "card-title"), he(a, "class", "highlight-card"), he(i, "class", "row");
    },
    m(d, h) {
      Se(d, t, h), u && u.m(t, null), ve(t, n), ve(t, i), c && c.m(i, null), ve(i, r), ve(i, s), ve(i, o), ve(i, a), f && f.m(a, null), l = !0;
    },
    p(d, [h]) {
      /*selectedTitle*/
      d[3] ? u ? u.p(d, h) : (u = S3(d), u.c(), u.m(t, n)) : u && (u.d(1), u = null), /*selectedMetadata*/
      d[4] ? c ? (c.p(d, h), h & /*selectedMetadata*/
      16 && ge(c, 1)) : (c = k3(d), c.c(), ge(c, 1), c.m(i, r)) : c && (bi(), Ce(c, 1, 1, () => {
        c = null;
      }), vi()), /*remount*/
      d[7] ? f ? (f.p(d, h), h & /*remount*/
      128 && ge(f, 1)) : (f = C3(d), f.c(), ge(f, 1), f.m(a, null)) : f && (bi(), Ce(f, 1, 1, () => {
        f = null;
      }), vi());
    },
    i(d) {
      l || (ge(c), ge(f), l = !0);
    },
    o(d) {
      Ce(c), Ce(f), l = !1;
    },
    d(d) {
      d && _e(t), u && u.d(), c && c.d(), f && f.d();
    }
  };
}
function Pme(e, t, n) {
  let { data: i } = t, { dataLong: r } = t, { el: s } = t, { filterItems: o } = t, { sortBy: a } = t, { sortOrder: l } = t, { selectedTitle: u } = t, { selectedMetadata: c } = t, f = [], d = [], h = [], g = !0;
  zv(() => {
    p(i, r);
  });
  function p(m, y) {
    if (m != null && y != null) {
      let v = document.createElement("div"), _ = JSON.parse(m);
      n(5, f = _);
      let x = JSON.parse(y);
      n(6, h = x);
      for (var b = 0; b < Object.keys(f[0]).length; b++) {
        const S = Object.keys(f[0])[b];
        d.push({
          key: S,
          title: S,
          value: (E) => E[S],
          sortable: !0,
          parseHTML: !0
        });
      }
      n(7, g = !1), setTimeout(() => n(7, g = !0), 0), s.appendChild(v);
    }
  }
  return e.$$set = (m) => {
    "data" in m && n(9, i = m.data), "dataLong" in m && n(10, r = m.dataLong), "el" in m && n(11, s = m.el), "filterItems" in m && n(0, o = m.filterItems), "sortBy" in m && n(1, a = m.sortBy), "sortOrder" in m && n(2, l = m.sortOrder), "selectedTitle" in m && n(3, u = m.selectedTitle), "selectedMetadata" in m && n(4, c = m.selectedMetadata);
  }, [
    o,
    a,
    l,
    u,
    c,
    f,
    h,
    g,
    d,
    i,
    r,
    s
  ];
}
class Ime extends Ms {
  constructor(t) {
    super(), $s(this, t, Pme, Lme, Cs, {
      data: 9,
      dataLong: 10,
      el: 11,
      filterItems: 0,
      sortBy: 1,
      sortOrder: 2,
      selectedTitle: 3,
      selectedMetadata: 4
    });
  }
}
function $3(e) {
  let t, n, i, r, s, o;
  t = new VP({
    props: {
      data: (
        /*data*/
        e[1]
      ),
      div: (
        /*matrixDiv*/
        e[12]
      ),
      numConcepts: (
        /*numConcepts*/
        e[4]
      ),
      numSlices: (
        /*numSlices*/
        e[5]
      )
    }
  }), t.$on(
    "message",
    /*handleMatrixEvent*/
    e[13]
  );
  const a = [Bme, zme], l = [];
  function u(c, f) {
    return (
      /*selectedMatrixElem*/
      c[6] == "cell" || /*selectedMatrixElem*/
      c[6] == "concept" ? 0 : (
        /*selectedMatrixElem*/
        c[6] == "group" ? 1 : -1
      )
    );
  }
  return ~(r = u(e)) && (s = l[r] = a[r](e)), {
    c() {
      ii(t.$$.fragment), n = ft(), i = pe("div"), s && s.c(), he(i, "class", "tables");
    },
    m(c, f) {
      Ln(t, c, f), Se(c, n, f), Se(c, i, f), ~r && l[r].m(i, null), o = !0;
    },
    p(c, f) {
      const d = {};
      f & /*data*/
      2 && (d.data = /*data*/
      c[1]), f & /*numConcepts*/
      16 && (d.numConcepts = /*numConcepts*/
      c[4]), f & /*numSlices*/
      32 && (d.numSlices = /*numSlices*/
      c[5]), t.$set(d);
      let h = r;
      r = u(c), r === h ? ~r && l[r].p(c, f) : (s && (bi(), Ce(l[h], 1, 1, () => {
        l[h] = null;
      }), vi()), ~r ? (s = l[r], s ? s.p(c, f) : (s = l[r] = a[r](c), s.c()), ge(s, 1), s.m(i, null)) : s = null);
    },
    i(c) {
      o || (ge(t.$$.fragment, c), ge(s), o = !0);
    },
    o(c) {
      Ce(t.$$.fragment, c), Ce(s), o = !1;
    },
    d(c) {
      c && (_e(n), _e(i)), Pn(t, c), ~r && l[r].d();
    }
  };
}
function zme(e) {
  let t, n;
  return t = new Ime({
    props: {
      data: (
        /*dataItemsWide*/
        e[3]
      ),
      dataLong: (
        /*dataItems*/
        e[2]
      ),
      el: (
        /*el*/
        e[0]
      ),
      filterItems: (
        /*filterItems*/
        e[7]
      ),
      sortBy: (
        /*sortBy*/
        e[8]
      ),
      sortOrder: (
        /*sortOrder*/
        e[9]
      ),
      selectedTitle: (
        /*selectedTitle*/
        e[10]
      ),
      selectedMetadata: (
        /*selectedMetadata*/
        e[11]
      )
    }
  }), {
    c() {
      ii(t.$$.fragment);
    },
    m(i, r) {
      Ln(t, i, r), n = !0;
    },
    p(i, r) {
      const s = {};
      r & /*dataItemsWide*/
      8 && (s.data = /*dataItemsWide*/
      i[3]), r & /*dataItems*/
      4 && (s.dataLong = /*dataItems*/
      i[2]), r & /*el*/
      1 && (s.el = /*el*/
      i[0]), r & /*filterItems*/
      128 && (s.filterItems = /*filterItems*/
      i[7]), r & /*sortBy*/
      256 && (s.sortBy = /*sortBy*/
      i[8]), r & /*sortOrder*/
      512 && (s.sortOrder = /*sortOrder*/
      i[9]), r & /*selectedTitle*/
      1024 && (s.selectedTitle = /*selectedTitle*/
      i[10]), r & /*selectedMetadata*/
      2048 && (s.selectedMetadata = /*selectedMetadata*/
      i[11]), t.$set(s);
    },
    i(i) {
      n || (ge(t.$$.fragment, i), n = !0);
    },
    o(i) {
      Ce(t.$$.fragment, i), n = !1;
    },
    d(i) {
      Pn(t, i);
    }
  };
}
function Bme(e) {
  let t, n;
  return t = new Ome({
    props: {
      data: (
        /*dataItems*/
        e[2]
      ),
      el: (
        /*el*/
        e[0]
      ),
      filterItems: (
        /*filterItems*/
        e[7]
      ),
      selectedTitle: (
        /*selectedTitle*/
        e[10]
      ),
      selectedMetadata: (
        /*selectedMetadata*/
        e[11]
      )
    }
  }), {
    c() {
      ii(t.$$.fragment);
    },
    m(i, r) {
      Ln(t, i, r), n = !0;
    },
    p(i, r) {
      const s = {};
      r & /*dataItems*/
      4 && (s.data = /*dataItems*/
      i[2]), r & /*el*/
      1 && (s.el = /*el*/
      i[0]), r & /*filterItems*/
      128 && (s.filterItems = /*filterItems*/
      i[7]), r & /*selectedTitle*/
      1024 && (s.selectedTitle = /*selectedTitle*/
      i[10]), r & /*selectedMetadata*/
      2048 && (s.selectedMetadata = /*selectedMetadata*/
      i[11]), t.$set(s);
    },
    i(i) {
      n || (ge(t.$$.fragment, i), n = !0);
    },
    o(i) {
      Ce(t.$$.fragment, i), n = !1;
    },
    d(i) {
      Pn(t, i);
    }
  };
}
function jme(e) {
  let t, n, i = (
    /*numConcepts*/
    e[4] > 0 && $3(e)
  );
  return {
    c() {
      i && i.c(), t = Zf();
    },
    m(r, s) {
      i && i.m(r, s), Se(r, t, s), n = !0;
    },
    p(r, [s]) {
      /*numConcepts*/
      r[4] > 0 ? i ? (i.p(r, s), s & /*numConcepts*/
      16 && ge(i, 1)) : (i = $3(r), i.c(), ge(i, 1), i.m(t.parentNode, t)) : i && (bi(), Ce(i, 1, 1, () => {
        i = null;
      }), vi());
    },
    i(r) {
      n || (ge(i), n = !0);
    },
    o(r) {
      Ce(i), n = !1;
    },
    d(r) {
      r && _e(t), i && i.d(r);
    }
  };
}
function Ume(e, t, n) {
  let { model: i } = t, { el: r } = t, s, o, a, l, u, c, f, d, h, g, p, m, y;
  s = i.get("data"), o = i.get("data_items"), a = i.get("data_items_wide"), l = i.get("metadata"), u = JSON.parse(l), c = Object.keys(u.concepts).length, f = Object.keys(u.items).length;
  let b = document.createElement("div");
  b.classList.add("matrix"), r.appendChild(b), r.classList.add("matrix-widget");
  function v() {
    n(6, d = null), n(7, h = {}), n(10, m = null), n(11, y = null);
  }
  function _(x) {
    let S = x.detail.col, E = x.detail.row, C = x.detail.selection_type;
    if (C == "cell") {
      if (S == null)
        v();
      else {
        n(6, d = "cell"), n(7, h = { id: S, concept: E }), n(10, m = "Slice: " + S + ", Concept: " + E);
        let $ = u.items[S], N = u.concepts[E];
        n(11, y = Object.assign($, N));
      }
      n(8, g = null), n(9, p = 0);
    } else if (C == "col") {
      let $ = x.detail.sortOrder;
      S == null ? v() : (n(6, d = "group"), n(7, h = { id: S }), n(10, m = "Slice: " + S), n(11, y = u.items[S]), n(8, g = "concept_score"), $ == 0 ? n(9, p = 0) : $ == 1 ? n(9, p = 1) : $ == 2 && n(9, p = -1));
    } else if (C == "row") {
      let $ = x.detail.sortOrder;
      E == null ? (v(), n(9, p = 0)) : (n(6, d = "concept"), n(7, h = { concept: E }), n(10, m = "Concept: " + E), n(11, y = u.concepts[E]), n(8, g = "concept_score"), $ == 0 ? n(9, p = 0) : $ == 1 ? n(9, p = 1) : $ == 2 && n(9, p = -1));
    }
  }
  return e.$$set = (x) => {
    "model" in x && n(14, i = x.model), "el" in x && n(0, r = x.el);
  }, [
    r,
    s,
    o,
    a,
    c,
    f,
    d,
    h,
    g,
    p,
    m,
    y,
    b,
    _,
    i
  ];
}
class qme extends Ms {
  constructor(t) {
    super(), $s(this, t, Ume, jme, Cs, { model: 14, el: 0 });
  }
}
function $0e({ model: e, el: t }) {
  let n = new qme({ target: t, props: { model: e, el: t } });
  return () => n.$destroy();
}
export {
  $0e as render
};
